Commit 652c33e5 authored by chenych's avatar chenych
Browse files

Fix bugs

parent cf14b883
......@@ -65,7 +65,7 @@ def stream_query(query, user_id=None):
'query': query,
'history': []
}
resp = requests.get(url,
resp = requests.post(url,
headers=headers,
data=json.dumps(data),
timeout=300,
......
......@@ -4,7 +4,7 @@ import json
import httpx
import configparser
import torch
import requests
import numpy as np
from loguru import logger
from BCEmbedding.tools.langchain import BCERerank
......@@ -48,9 +48,9 @@ class OpenAPIClient:
continue
yield output
async def get_response(self, headers, data):
async with httpx.AsyncClient() as client:
resp = await client.post(self.url, json=data, headers=headers, timeout=300)
def get_response(self, headers, data):
resp = requests.post(self.url, json=data, headers=headers, timeout=300)
try:
result = json.loads(resp.content.decode("utf-8"))
output = result['choices'][0]['message']['content']
......
......@@ -137,10 +137,8 @@ class Worker:
if len(chunks) == 0:
logger.debug('Response by finetune model')
response = self.response_by_finetune(query, history=history)
data = json.loads(response.content.decode("utf-8"))
chunks = [output]
response = await self.response_by_finetune(query, history=history)
chunks = [response]
elif use_template:
logger.debug('Response by template')
response = self.format_rag_result(chunks, references, stream=stream)
......
......@@ -14,7 +14,7 @@ from BCEmbedding.tools.langchain import BCERerank
from langchain.retrievers import ContextualCompressionRetriever
from langchain_community.vectorstores.utils import DistanceStrategy
from requests.exceptions import RequestException
from elastic_keywords_search import ElasticKeywordsSearch
from .elastic_keywords_search import ElasticKeywordsSearch
app = FastAPI()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment