Update main.py
Browse files
main.py
CHANGED
@@ -28,11 +28,11 @@ from transformers import pipeline
|
|
28 |
app = FastAPI()
|
29 |
|
30 |
# 更改pipeline类型到text-generation,并使用一个示例模型(如GPT-2)
|
31 |
-
pipe_gpt = pipeline("text-generation", model="FreedomIntelligence/Apollo-
|
32 |
|
33 |
@app.get("/infer_t5")
|
34 |
def infer_gpt(input: str):
|
35 |
-
output = pipe_gpt(input, max_length=
|
36 |
return {"output": output[0]["generated_text"]}
|
37 |
|
38 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
|
|
28 |
app = FastAPI()
|
29 |
|
30 |
# 更改pipeline类型到text-generation,并使用一个示例模型(如GPT-2)
|
31 |
+
pipe_gpt = pipeline("text-generation", model="FreedomIntelligence/Apollo-6B",trust_remote_code=True)
|
32 |
|
33 |
@app.get("/infer_t5")
|
34 |
def infer_gpt(input: str):
|
35 |
+
output = pipe_gpt(input, max_length=500) # 你可以调整max_length来控制生成文本的长度
|
36 |
return {"output": output[0]["generated_text"]}
|
37 |
|
38 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|