fix url bugs and improve speed
This commit is contained in:
parent
d47042302d
commit
d777202863
23
main.py
23
main.py
@ -1,4 +1,5 @@
|
||||
from fastapi import FastAPI
|
||||
import urllib.parse
|
||||
|
||||
from config import __CONFIG__
|
||||
import mysql_connector
|
||||
@ -11,36 +12,24 @@ def query(query:str):
|
||||
res = []
|
||||
list = search_paper(query)
|
||||
for i in list:
|
||||
if not mysql_connector.is_loaded(i['paperId']):
|
||||
res.append({
|
||||
'id':i['paperId'],
|
||||
'datasetId':__CONFIG__['fastgpt_setId'],
|
||||
'collectionId':__CONFIG__['fastgpt_colId'],
|
||||
'sourceName':'Semantic Scholar',
|
||||
'sourceId?':'',
|
||||
'q':str(i['title']),
|
||||
'a':str(i['abstract']),
|
||||
'score':[
|
||||
{
|
||||
'type': 'rrf',
|
||||
'value':0.8
|
||||
}
|
||||
]
|
||||
'score':[]
|
||||
})
|
||||
return res
|
||||
|
||||
@app.get("/fastdoi")
|
||||
async def get_reference(questions):
|
||||
print('Search: '+questions)
|
||||
res = query(questions)
|
||||
new = []
|
||||
res = query(urllib.parse.quote(questions))
|
||||
if(upload2fastgpt(res)):
|
||||
for i in res:
|
||||
if not mysql_connector.is_loaded(i['id']):
|
||||
new.append(i)
|
||||
if(upload2fastgpt(new)):
|
||||
for i in new:
|
||||
mysql_connector.new_load(i['id'])
|
||||
print('New: '+i['q'])
|
||||
return new
|
||||
return res
|
||||
|
||||
if __name__ == '__main__':
|
||||
import uvicorn
|
||||
|
Loading…
Reference in New Issue
Block a user