Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a32b1a2

Browse files
fix typo and add missing check
1 parent cc5fe19 commit a32b1a2

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

‎src/backend/fastapi_app/rag_advanced.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ async def run_stream(
183183
stream=True,
184184
)
185185

186-
# Forcefully Close the database session before yielding the response
186+
# Forcefully close the database session before yielding the response
187187
# Yielding keeps the connection open while streaming the response until the end
188188
# The connection closes when it returns back to the context manger in the dependencies
189189
await self.searcher.db_session.close()
@@ -230,5 +230,7 @@ async def run_stream(
230230
)
231231

232232
async for response_chunk in chat_completion_async_stream:
233-
yield Message(content=str(response_chunk.choices[0].delta.content), role="assistant")
233+
# first response has empty choices
234+
if response_chunk.choices:
235+
yield Message(content=str(response_chunk.choices[0].delta.content), role="assistant")
234236
return

‎src/backend/fastapi_app/rag_simple.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ async def run_stream(
201201
stream=True,
202202
)
203203

204-
# Forcefully Close the database session before yielding the response
204+
# Forcefully close the database session before yielding the response
205205
# Yielding keeps the connection open while streaming the response until the end
206206
# The connection closes when it returns back to the context manger in the dependencies
207207
await self.searcher.db_session.close()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /