meet fastGPT knowledge base requirement

This commit is contained in:
mxr612 2024-08-21 14:24:31 +08:00
parent 6b016481f1
commit b4aa5b1147
2 changed files with 6 additions and 7 deletions

View File

@ -24,13 +24,13 @@ def __new_set():
).json()
return result["data"]
colId = __new_set()
__CONFIG__['colId'] = __new_set()
def upload2fastgpt(data):
try:
headers = {"Authorization": f"Bearer {key}", "Content-Type": "application/json"}
payload = {
"collectionId": colId,
"collectionId": __CONFIG__['colId'],
"trainingMode": "chunk",
"data": data
}

View File

@ -1,7 +1,6 @@
import config
import json
from fastapi import FastAPI
from config import __CONFIG__
# import mysql_connector
from fastgpt_uploader import upload2fastgpt
from semanticscholar import search_paper
@ -10,9 +9,9 @@ app = FastAPI()
def query(query:str):
res = []
list = search_paper(json.loads(query))
list = search_paper(query)
for i in list:
res.append({'q':i['title'], 'a':i['abstract']})
res.append({'id':'','datasetId':__CONFIG__['setId'], 'collectionId':__CONFIG__['colId'], 'sourceName':'Semantic Scholar','sourceId?':'', 'q':i['title'], 'a':i['abstract']})
print(i['title'])
return res
@ -24,5 +23,5 @@ async def get_reference(questions):
if __name__ == '__main__':
import uvicorn
uvicorn.run(app, host="127.0.0.1", port=2501)
uvicorn.run(app, host="127.0.0.1", port=8964)
# mysql_connector.end_mysql()