Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenych
chat_demo
Commits
652c33e5
Commit
652c33e5
authored
Sep 14, 2024
by
chenych
Browse files
Fix bugs
parent
cf14b883
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
17 deletions
+15
-17
client.py
client.py
+1
-1
llm_service/http_client.py
llm_service/http_client.py
+11
-11
llm_service/worker.py
llm_service/worker.py
+2
-4
rag/retriever.py
rag/retriever.py
+1
-1
No files found.
client.py
View file @
652c33e5
...
@@ -65,7 +65,7 @@ def stream_query(query, user_id=None):
...
@@ -65,7 +65,7 @@ def stream_query(query, user_id=None):
'query'
:
query
,
'query'
:
query
,
'history'
:
[]
'history'
:
[]
}
}
resp
=
requests
.
ge
t
(
url
,
resp
=
requests
.
pos
t
(
url
,
headers
=
headers
,
headers
=
headers
,
data
=
json
.
dumps
(
data
),
data
=
json
.
dumps
(
data
),
timeout
=
300
,
timeout
=
300
,
...
...
llm_service/http_client.py
View file @
652c33e5
...
@@ -4,7 +4,7 @@ import json
...
@@ -4,7 +4,7 @@ import json
import
httpx
import
httpx
import
configparser
import
configparser
import
torch
import
torch
import
requests
import
numpy
as
np
import
numpy
as
np
from
loguru
import
logger
from
loguru
import
logger
from
BCEmbedding.tools.langchain
import
BCERerank
from
BCEmbedding.tools.langchain
import
BCERerank
...
@@ -48,9 +48,9 @@ class OpenAPIClient:
...
@@ -48,9 +48,9 @@ class OpenAPIClient:
continue
continue
yield
output
yield
output
async
def
get_response
(
self
,
headers
,
data
):
def
get_response
(
self
,
headers
,
data
):
async
with
httpx
.
AsyncClient
()
as
client
:
resp
=
await
client
.
post
(
self
.
url
,
json
=
data
,
headers
=
headers
,
timeout
=
300
)
resp
=
requests
.
post
(
self
.
url
,
json
=
data
,
headers
=
headers
,
timeout
=
300
)
try
:
try
:
result
=
json
.
loads
(
resp
.
content
.
decode
(
"utf-8"
))
result
=
json
.
loads
(
resp
.
content
.
decode
(
"utf-8"
))
output
=
result
[
'choices'
][
0
][
'message'
][
'content'
]
output
=
result
[
'choices'
][
0
][
'message'
][
'content'
]
...
...
llm_service/worker.py
View file @
652c33e5
...
@@ -137,10 +137,8 @@ class Worker:
...
@@ -137,10 +137,8 @@ class Worker:
if
len
(
chunks
)
==
0
:
if
len
(
chunks
)
==
0
:
logger
.
debug
(
'Response by finetune model'
)
logger
.
debug
(
'Response by finetune model'
)
response
=
self
.
response_by_finetune
(
query
,
history
=
history
)
response
=
await
self
.
response_by_finetune
(
query
,
history
=
history
)
data
=
json
.
loads
(
response
.
content
.
decode
(
"utf-8"
))
chunks
=
[
response
]
chunks
=
[
output
]
elif
use_template
:
elif
use_template
:
logger
.
debug
(
'Response by template'
)
logger
.
debug
(
'Response by template'
)
response
=
self
.
format_rag_result
(
chunks
,
references
,
stream
=
stream
)
response
=
self
.
format_rag_result
(
chunks
,
references
,
stream
=
stream
)
...
...
rag/retriever.py
View file @
652c33e5
...
@@ -14,7 +14,7 @@ from BCEmbedding.tools.langchain import BCERerank
...
@@ -14,7 +14,7 @@ from BCEmbedding.tools.langchain import BCERerank
from
langchain.retrievers
import
ContextualCompressionRetriever
from
langchain.retrievers
import
ContextualCompressionRetriever
from
langchain_community.vectorstores.utils
import
DistanceStrategy
from
langchain_community.vectorstores.utils
import
DistanceStrategy
from
requests.exceptions
import
RequestException
from
requests.exceptions
import
RequestException
from
elastic_keywords_search
import
ElasticKeywordsSearch
from
.
elastic_keywords_search
import
ElasticKeywordsSearch
app
=
FastAPI
()
app
=
FastAPI
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment