Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
@@ -19,7 +19,7 @@ repo_id=os.environ.get('repo_id')
|
|
19 |
#port = os.getenv('port')
|
20 |
|
21 |
llm = HuggingFaceHub(repo_id=repo_id, # for StarChat
|
22 |
-
huggingfacehub_api_token=hf_token,
|
23 |
model_kwargs={"min_length": 512, # for StarChat
|
24 |
"max_new_tokens": 1024, "do_sample": True, # for StarChat
|
25 |
"temperature": 0.01,
|
@@ -55,11 +55,12 @@ async def chat(chat_request: ChatRequest):
|
|
55 |
loader = WebBaseLoader(target_url)
|
56 |
print(target_url)
|
57 |
docs = loader.load()
|
58 |
-
|
59 |
-
result=
|
|
|
60 |
print("AI Summarization: " + result)
|
61 |
#return {'response': result} #FastAPI方式下,这个返回形式,有问题? - NO!不是的!可以工作!
|
62 |
-
return JSONResponse({'response': result})
|
63 |
|
64 |
#对比FlaskAPI的:return jsonify({'response': result}),JSONResponse vs jsonify(都需要相应的from ... import ...)
|
65 |
except Exception as e:
|
|
|
19 |
#port = os.getenv('port')
|
20 |
|
21 |
llm = HuggingFaceHub(repo_id=repo_id, # for StarChat
|
22 |
+
huggingfacehub_api_token=hf_token, #这个变量huggingfacehub_api_token名称似乎没有问题!
|
23 |
model_kwargs={"min_length": 512, # for StarChat
|
24 |
"max_new_tokens": 1024, "do_sample": True, # for StarChat
|
25 |
"temperature": 0.01,
|
|
|
55 |
loader = WebBaseLoader(target_url)
|
56 |
print(target_url)
|
57 |
docs = loader.load()
|
58 |
+
result = chain.run(docs)
|
59 |
+
result=str(result)
|
60 |
+
#result="Hi FastAPI" #用这个调试OK
|
61 |
print("AI Summarization: " + result)
|
62 |
#return {'response': result} #FastAPI方式下,这个返回形式,有问题? - NO!不是的!可以工作!
|
63 |
+
return JSONResponse({'response': result}) #这个形式也是OK的 - 只要result是字符形式即可?
|
64 |
|
65 |
#对比FlaskAPI的:return jsonify({'response': result}),JSONResponse vs jsonify(都需要相应的from ... import ...)
|
66 |
except Exception as e:
|