paper query for main and api supported
This commit is contained in:
parent
85a4106e18
commit
6b016481f1
@ -26,13 +26,13 @@ def __new_set():
|
|||||||
|
|
||||||
colId = __new_set()
|
colId = __new_set()
|
||||||
|
|
||||||
def submit_data(q,a):
|
def upload2fastgpt(data):
|
||||||
try:
|
try:
|
||||||
headers = {"Authorization": f"Bearer {key}", "Content-Type": "application/json"}
|
headers = {"Authorization": f"Bearer {key}", "Content-Type": "application/json"}
|
||||||
payload = {
|
payload = {
|
||||||
"collectionId": colId,
|
"collectionId": colId,
|
||||||
"trainingMode": "chunk",
|
"trainingMode": "chunk",
|
||||||
"data": [{"q":q,"a":a}]
|
"data": data
|
||||||
}
|
}
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
url + "/core/dataset/data/pushData", headers=headers, data=json.dumps(payload)
|
url + "/core/dataset/data/pushData", headers=headers, data=json.dumps(payload)
|
||||||
|
29
main.py
29
main.py
@ -1,7 +1,28 @@
|
|||||||
import config
|
import config
|
||||||
import mysql_connector
|
import json
|
||||||
import fastgpt_uploader
|
from fastapi import FastAPI
|
||||||
|
|
||||||
config.end_mysql()
|
# import mysql_connector
|
||||||
|
from fastgpt_uploader import upload2fastgpt
|
||||||
|
from semanticscholar import search_paper
|
||||||
|
|
||||||
mysql_connector.end_mysql()
|
app = FastAPI()
|
||||||
|
|
||||||
|
def query(query:str):
|
||||||
|
res = []
|
||||||
|
list = search_paper(json.loads(query))
|
||||||
|
for i in list:
|
||||||
|
res.append({'q':i['title'], 'a':i['abstract']})
|
||||||
|
print(i['title'])
|
||||||
|
return res
|
||||||
|
|
||||||
|
@app.get("/fastdoi")
|
||||||
|
async def get_reference(questions):
|
||||||
|
res = query(questions)
|
||||||
|
upload2fastgpt(res)
|
||||||
|
return res
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import uvicorn
|
||||||
|
uvicorn.run(app, host="127.0.0.1", port=2501)
|
||||||
|
# mysql_connector.end_mysql()
|
Loading…
Reference in New Issue
Block a user