Hosted inference API 补充

#8
by TimVan1 - opened

主页的Hosted inference API 补充

import requests
from flask import Flask, request, jsonify

app = Flask(__name__)
app.config.from_pyfile('config.py')
PROMPT_DICT = app.config["PROMPT_DICT"]

API_URL = "https://api-inference.huggingface.co/models/funstoryai/immersiveL-exp"
headers = {"Authorization": "Bearer hf_YOUR_TOKEN"}

def query(prompt):
    payload = {
        "inputs": prompt,
        "parameters": {"do_sample": False,
                 		"max_length": 500,
                 		"repetition_penalty": 1.4,
                        "temperature":0},

    }
    
    response = requests.post(API_URL, headers=headers, json=payload)
    return response.json()

text="这是一个测试句子"
task = 'zh2en'
prompt = generate_input_prompt(text, task)

output = query(prompt)
TimVan1 changed discussion status to closed

Sign up or log in to comment