Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete aiconfig_complete stream response, replace with aiconfig #911

Merged
merged 1 commit into from
Jan 14, 2024

Conversation

rossdanlm
Copy link
Contributor

@rossdanlm rossdanlm commented Jan 13, 2024

Delete aiconfig_complete stream response, replace with aiconfig

Before we used to not support streaming, so when we would return aiconfig it would be from a blocking hanging operation. This meant that we needed to set isRunning prompt state to be true while we were waiting, but now we don't need to do that anymore after we migrated all run events to return in streaming response format, even for non-streaming models: #806

Also we are now no longer using the streamApi helper since we added and are now using streamingApiChain, which was added in #789

Finally, if you want more resources on how streaming is connected, you can check out #910 which is a teaching guide I built for adding explaining how the code is connected

Test Plan

Both streaming and non-streaming models work as before

b120c319-fa11-40e7-a31f-2bdb5bbe3ec7.mp4

Stack created with Sapling. Best reviewed with ReviewStack.

Before we used to not support streaming, so when we would return `aiconfig` it would be from a blocking hanging operation. This meant that we needed to set `isRunning` prompt state to be true while we were waiting, but now we don't need to do that anymore after we migrated all run events to return in streaming response format, even for non-streaming models: #806

Also we are now no longer using the `streamApi` helper since we added and are now using `streamingApiChain`, which was added in #789

Finally, if you want more resources on how streaming is connected, you can check out #910 which is a teaching guide I built for adding explaining how the code is connected

## Test Plan
Both streaming and non-streaming models work as before

https://github.com/lastmile-ai/aiconfig/assets/151060367/b62e7887-20af-4c0c-ab85-eeaacaab64e0
@@ -641,17 +637,9 @@ export default function EditorContainer({
type: "CONSOLIDATE_AICONFIG",
action: {
...action,
// Ensure we keep the prompt in a running state since this is an in-progress update
isRunning: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also remove this property from the CONSOLIDATE_AICONFIG action in aiConfigReducer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't this added specifically to support streaming? It wasn't needed for the single awaited request run calls. Also, just noting that we still probably want to support non-streaming execution since external deployments might not have streaming implemented

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

010f499

Fixed some bugs on the frontend along the way -- specifically, because we return the full aiconfig on every chunk update, we were resetting isRunning to false after the first chunk was received (by dispatching CONSOLIDATE_AICONFIG). Ideally, we update just the output chunk, but to fix this I've added a separate aiconfig_complete event to distinguish the finalized aiconfig from the in-progress one

I guess my main concern is will this be needed for gradio streaming?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that's a good point. Gradio would need the full updated value

Copy link
Contributor Author

@rossdanlm rossdanlm Jan 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, just noting that we still probably want to support non-streaming execution since external deployments might not have streaming implemented

We still have another CONSOLIDATE_AICONFIG call at the end after the stream outputs that listens for the non-streaming aiconfig responses (server must return a response instead of yielding)

Wasn't this added specifically to support streaming? It wasn't needed for the single awaited request run calls.

I think you're right about this, if we return the entire AIConfig as a streamed response this will incorrectly make the isRunning param to false. However if we keep it here, we'll never terminate the isRunning state to false, because everything we return from the server is in stream format.

b120c319-fa11-40e7-a31f-2bdb5bbe3ec7.mp4

What I will do in a followup PR is add another streaming event called aiconfig_stream and have the isRunning there set to true (kind of the equivalent of aiconfig stream event today, while aiconfig_complete is now the same functionality as aiconfig). I just feel the names for that are a bit simpler and it's apparent that one is for streaming, while the other is for "regular" output as a "non-stream" (even if it's being implemented by our particular backend as a streaming event, other people can implement it as a non-stream event and know what it is supposed to do)

@rossdanlm rossdanlm merged commit 68c2c3e into main Jan 14, 2024
2 checks passed
@rossdanlm rossdanlm deleted the pr911 branch January 14, 2024 00:12
rossdanlm pushed a commit that referenced this pull request Jan 14, 2024
I think this is cleaner and better for us to deal with. It also breaks down the aiconfig streaming logic to be more explicitly handled for next PR.

See comments about this in

- #907 (comment)
- #911 (comment)

## Test Plan
Both the streaming and non-streaming models work the same as before
rossdanlm pushed a commit that referenced this pull request Jan 14, 2024
I think this is cleaner and better for us to deal with. It also breaks down the aiconfig streaming logic to be more explicitly handled for next PR.

See comments about this in

- #907 (comment)
- #911 (comment)

## Test Plan
Both the streaming and non-streaming models work the same as before

https://github.com/lastmile-ai/aiconfig/assets/151060367/2c3fd802-e95e-417c-ac80-7b6e18983520
rossdanlm pushed a commit that referenced this pull request Jan 15, 2024
I think this is cleaner and better for us to deal with. It also breaks down the aiconfig streaming logic to be more explicitly handled for next PR.

See comments about this in

- #907 (comment)
- #911 (comment)

## Test Plan
Both the streaming and non-streaming models work the same as before

https://github.com/lastmile-ai/aiconfig/assets/151060367/2c3fd802-e95e-417c-ac80-7b6e18983520
rossdanlm added a commit that referenced this pull request Jan 15, 2024
…914)

Add explicit "stop_streaming" event to signal streaming is finished



I think this is cleaner and better for us to deal with. It also breaks
down the aiconfig streaming logic to be more explicitly handled for next
PR.

See comments about this in

-
#907 (comment)
-
#911 (comment)

## Test Plan
Both the streaming and non-streaming models work the same as before


https://github.com/lastmile-ai/aiconfig/assets/151060367/2c3fd802-e95e-417c-ac80-7b6e18983520
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants