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
|
from fastapi import FastAPI
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
from config import __CONFIG__
|
from config import __CONFIG__
|
||||||
import mysql_connector
|
import mysql_connector
|
||||||
@ -11,36 +12,24 @@ def query(query:str):
|
|||||||
res = []
|
res = []
|
||||||
list = search_paper(query)
|
list = search_paper(query)
|
||||||
for i in list:
|
for i in list:
|
||||||
|
if not mysql_connector.is_loaded(i['paperId']):
|
||||||
res.append({
|
res.append({
|
||||||
'id':i['paperId'],
|
'id':i['paperId'],
|
||||||
'datasetId':__CONFIG__['fastgpt_setId'],
|
|
||||||
'collectionId':__CONFIG__['fastgpt_colId'],
|
|
||||||
'sourceName':'Semantic Scholar',
|
|
||||||
'sourceId?':'',
|
|
||||||
'q':str(i['title']),
|
'q':str(i['title']),
|
||||||
'a':str(i['abstract']),
|
'a':str(i['abstract']),
|
||||||
'score':[
|
'score':[]
|
||||||
{
|
|
||||||
'type': 'rrf',
|
|
||||||
'value':0.8
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@app.get("/fastdoi")
|
@app.get("/fastdoi")
|
||||||
async def get_reference(questions):
|
async def get_reference(questions):
|
||||||
print('Search: '+questions)
|
print('Search: '+questions)
|
||||||
res = query(questions)
|
res = query(urllib.parse.quote(questions))
|
||||||
new = []
|
if(upload2fastgpt(res)):
|
||||||
for i in 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'])
|
mysql_connector.new_load(i['id'])
|
||||||
print('New: '+i['q'])
|
print('New: '+i['q'])
|
||||||
return new
|
return res
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import uvicorn
|
import uvicorn
|
||||||
|
Loading…
Reference in New Issue
Block a user