Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -3,6 +3,7 @@ from dotenv import load_dotenv
|
|
| 3 |
from fastapi import FastAPI, Request, HTTPException
|
| 4 |
from langchain.document_loaders import WebBaseLoader
|
| 5 |
from langchain.chains.summarize import load_summarize_chain
|
|
|
|
| 6 |
from langchain import HuggingFaceHub
|
| 7 |
from huggingface_hub import InferenceClient
|
| 8 |
#from bs4 import BeautifulSoup
|
|
@@ -45,7 +46,8 @@ async def chat(request: Request):
|
|
| 45 |
docs = loader.load()
|
| 46 |
result = chain.run(docs)
|
| 47 |
print("AI Summarization: " + result)
|
| 48 |
-
return {'response': result}
|
|
|
|
| 49 |
except Exception as e:
|
| 50 |
err_msg = "Wrong URL or URL not parsable."
|
| 51 |
print(err_msg)
|
|
|
|
| 3 |
from fastapi import FastAPI, Request, HTTPException
|
| 4 |
from langchain.document_loaders import WebBaseLoader
|
| 5 |
from langchain.chains.summarize import load_summarize_chain
|
| 6 |
+
#https://python.langchain.com/docs/use_cases/summarization
|
| 7 |
from langchain import HuggingFaceHub
|
| 8 |
from huggingface_hub import InferenceClient
|
| 9 |
#from bs4 import BeautifulSoup
|
|
|
|
| 46 |
docs = loader.load()
|
| 47 |
result = chain.run(docs)
|
| 48 |
print("AI Summarization: " + result)
|
| 49 |
+
#return {'response': result} #FastAPI方式下,这个返回形式,有问题?
|
| 50 |
+
return JSONResponse({'response': result})
|
| 51 |
except Exception as e:
|
| 52 |
err_msg = "Wrong URL or URL not parsable."
|
| 53 |
print(err_msg)
|