Skip to content

Commit

Permalink
Fix session_id bug (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
moria97 authored Sep 6, 2024
1 parent dda3ed6 commit 82a7125
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
16 changes: 4 additions & 12 deletions src/pai_rag/app/web/rag_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,14 @@ def query_search(
raise RagApiError(code=r.status_code, msg=r.text)
if not stream:
response = dotdict(json.loads(r.text))
yield self._format_rag_response(
text, response, session_id=session_id, stream=stream
)
yield self._format_rag_response(text, response, stream=stream)
else:
full_content = ""
for chunk in r.iter_lines(chunk_size=8192, decode_unicode=True):
chunk_response = dotdict(json.loads(chunk))
full_content += chunk_response.delta
chunk_response.delta = full_content
yield self._format_rag_response(
text, chunk_response, session_id=session_id, stream=stream
)
yield self._format_rag_response(text, chunk_response, stream=stream)

def query_data_analysis(
self,
Expand All @@ -228,18 +224,14 @@ def query_data_analysis(
raise RagApiError(code=r.status_code, msg=r.text)
if not stream:
response = dotdict(json.loads(r.text))
yield self._format_rag_response(
text, response, session_id=session_id, stream=stream
)
yield self._format_rag_response(text, response, stream=stream)
else:
full_content = ""
for chunk in r.iter_lines(chunk_size=8192, decode_unicode=True):
chunk_response = dotdict(json.loads(chunk))
full_content += chunk_response.delta
chunk_response.delta = full_content
yield self._format_rag_response(
text, chunk_response, session_id=session_id, stream=stream
)
yield self._format_rag_response(text, chunk_response, stream=stream)

def query_llm(
self,
Expand Down
3 changes: 1 addition & 2 deletions src/pai_rag/app/web/tabs/agent_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ def respond(agent_question, agent_chatbot):


def clear_history(chatbot):
rag_client.clear_history()
chatbot = []
global current_session_id
current_session_id = None
return chatbot


Expand Down
3 changes: 1 addition & 2 deletions src/pai_rag/app/web/tabs/data_analysis_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ def analysis_respond(question, chatbot):


def clear_history(chatbot):
rag_client.clear_history()
chatbot = []
global current_session_id
current_session_id = None
return chatbot


Expand Down

0 comments on commit 82a7125

Please sign in to comment.