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

protocol: Support complex stream protocol #345

Open
634750802 opened this issue Oct 28, 2024 · 0 comments · May be fixed by #348
Open

protocol: Support complex stream protocol #345

634750802 opened this issue Oct 28, 2024 · 0 comments · May be fixed by #348
Assignees

Comments

@634750802
Copy link
Collaborator

634750802 commented Oct 28, 2024

Current Stream Protocol

Reuse stream protocol part of Vercel AI SDK

Non-StackVM Engine

[DATA]: chat and message object
[MESSAGE_ANNOTATION]: SOURCE_NODES, KG_RETRIEVAL, REFINE_QUESTION, ...
[MESSAGE_ANNOTATION]: SOURCE_NODES, KG_RETRIEVAL, REFINE_QUESTION, ...
[TEXT] Hello,
[TEXT] world.

StackVM Engine

[DATA]: chat and message object
- [MESSAGE_ANNOTATION]: SOURCE_NODES, KG_RETRIEVAL, REFINE_QUESTION, ...
+ [MESSAGE_ANNOTATION]: { state: StackVM.State }
+ [TOOL_CALL]: ...
+ [TOOL_RESULT]: ...
+ [MESSAGE_ANNOTATION]: { state: StackVM.State }
[TEXT] Hello,
[TEXT] world.
+ [FINISH_MESSAGE]

Goal

Support other states in External Engine protocol:

[DATA]: chat and message object

# We still can send old annotations before enter StackVM stream
[MESSAGE_ANNOTATION]: SOURCE_NODES, KG_RETRIEVAL, REFINE_QUESTION, ...

# From here we start to proxy external
+ [MESSAGE_ANNOTATION]: EXTERNAL_STREAM_START, { type: 'StackVM' }
+ [external.MESSAGE_ANNOTATION]: { state: StackVM.State }
+ [external.TOOL_CALL]: ...
+ [external.TOOL_RESULT]: ...
+ [external.MESSAGE_ANNOTATION]: { state: StackVM.State }
+ [external.TOOL_CALL]: ...
+ [external.TOOL_RESULT]: ...
+ [external.TEXT] Hello,
+ [external.TEXT] world.
+ [external.FINISH_MESSAGE]
# From here we stop to proxy external stream

[MESSAGE_ANNOTATION]: SOURCE_NODES, KG_RETRIEVAL, REFINE_QUESTION, ...

# Texts are generated from StackVM,no more text should be sent after the external stream
- [TEXT] Hello,
- [TEXT] world.
  • External stream must conform to Vercel AI SDK's stream protocol.
  • External stream must finish with a FINISH_MESSAGE part.
  • All TiDB.ai clients could ignore all MESSAGE_ANNOTATION parts.
  • TOOL_CALL and TOOL_RESULT can be used for tracking process of a external chat request.
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 a pull request may close this issue.

1 participant