Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Llama Index
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
run-llama
Llama Index
Commits
c5a49e0f
Unverified
Commit
c5a49e0f
authored
11 months ago
by
Logan
Committed by
GitHub
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
remove error ignoring during streaming (#13160)
parent
805d8ef2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llama-index-core/llama_index/core/chat_engine/types.py
+25
-8
25 additions, 8 deletions
llama-index-core/llama_index/core/chat_engine/types.py
with
25 additions
and
8 deletions
llama-index-core/llama_index/core/chat_engine/types.py
+
25
−
8
View file @
c5a49e0f
...
...
@@ -111,6 +111,8 @@ class StreamingAgentChatResponse:
_is_function_false_event
:
Optional
[
asyncio
.
Event
]
=
None
# signal when an OpenAI function is being executed
_is_function_not_none_thread_event
:
Event
=
field
(
default_factory
=
Event
)
# Track if an exception occurred
_exception
:
Optional
[
Exception
]
=
None
def
__post_init__
(
self
)
->
None
:
if
self
.
sources
and
not
self
.
source_nodes
:
...
...
@@ -147,7 +149,6 @@ class StreamingAgentChatResponse:
self
,
memory
:
BaseMemory
,
on_stream_end_fn
:
Optional
[
callable
]
=
None
,
raise_error
:
bool
=
False
,
)
->
None
:
if
self
.
chat_stream
is
None
:
raise
ValueError
(
...
...
@@ -176,12 +177,14 @@ class StreamingAgentChatResponse:
memory
.
put
(
chat
.
message
)
except
Exception
as
e
:
dispatch_event
(
StreamChatErrorEvent
(
exception
=
e
))
if
not
raise_error
:
logger
.
warning
(
f
"
Encountered exception writing response to history:
{
e
}
"
)
else
:
raise
self
.
_exception
=
e
# This act as is_done events for any consumers waiting
self
.
_is_function_not_none_thread_event
.
set
()
# force the queue reader to see the exception
self
.
put_in_queue
(
""
)
raise
dispatch_event
(
StreamChatEndEvent
())
self
.
_is_done
=
True
...
...
@@ -230,7 +233,15 @@ class StreamingAgentChatResponse:
memory
.
put
(
chat
.
message
)
except
Exception
as
e
:
dispatch_event
(
StreamChatErrorEvent
(
exception
=
e
))
logger
.
warning
(
f
"
Encountered exception writing response to history:
{
e
}
"
)
self
.
_exception
=
e
# These act as is_done events for any consumers waiting
self
.
_is_function_false_event
.
set
()
self
.
_new_item_event
.
set
()
# force the queue reader to see the exception
self
.
aput_in_queue
(
""
)
raise
dispatch_event
(
StreamChatEndEvent
())
self
.
_is_done
=
True
...
...
@@ -243,6 +254,9 @@ class StreamingAgentChatResponse:
@property
def
response_gen
(
self
)
->
Generator
[
str
,
None
,
None
]:
while
not
self
.
_is_done
or
not
self
.
_queue
.
empty
():
if
self
.
_exception
is
not
None
:
raise
self
.
_exception
try
:
delta
=
self
.
_queue
.
get
(
block
=
False
)
self
.
_unformatted_response
+=
delta
...
...
@@ -256,6 +270,9 @@ class StreamingAgentChatResponse:
self
.
_ensure_async_setup
()
while
True
:
if
not
self
.
_aqueue
.
empty
()
or
not
self
.
_is_done
:
if
self
.
_exception
is
not
None
:
raise
self
.
_exception
try
:
delta
=
await
asyncio
.
wait_for
(
self
.
_aqueue
.
get
(),
timeout
=
0.1
)
except
asyncio
.
TimeoutError
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment