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

refactor: unify response and agent response #930

Merged
merged 6 commits into from
Jun 17, 2024

Conversation

marcusschiesser
Copy link
Collaborator

No description provided.

Copy link

vercel bot commented Jun 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
llama-index-ts-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2024 4:06pm

Copy link

changeset-bot bot commented Jun 14, 2024

🦋 Changeset detected

Latest commit: 0899592

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
llamaindex Minor
docs Patch
@llamaindex/autotool Major
@llamaindex/community Patch
@llamaindex/experimental Patch
@llamaindex/cloudflare-worker-agent-test Patch
@llamaindex/next-agent-test Patch
@llamaindex/nextjs-edge-runtime-test Patch
@llamaindex/waku-query-engine-test Patch
@llamaindex/autotool-02-next-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

sources: ToolOutput[];
};

export type AgentChatResponse<Options extends object> = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AgentChatResponse is better than Response but most people are using normal chat engines I assume, so we better improve the existing Response class (see above)

* Response is the output of a LLM
*/
export class Response {
export class Response implements ChatResponse {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Idea: we include message and raw from ChatResponse instead of adding chatResponse: ChatResponse as an attribute to Response

Note: we ChatResponse supports extension with Options we have to add this to this PR (after we agree on the contract)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

another advantage is that Reponse behaves like ChatReponse

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TBD: how to deal with chunks? We have ChatReponseChunks as type returned by LLMs but chat engines are just streaming Response objects.

Suggestion: we add an optional delta attribute to Response

*/
export class Response {
export class Response implements ChatResponse {
// @deprecated use 'message' instead
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we tell the user to not use response instead migrate to message

* Response is the output of a LLM
*/
export class Response {
export class Response implements ChatResponse {
Copy link
Member

Choose a reason for hiding this comment

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

could we don't naming Response it's already a Web API

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

how about EngineResponse (see new code)?

@@ -0,0 +1,5 @@
---
"llamaindex": minor
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@himself65 minor because agent chat interface is breaking

message: "What is the weather in San Francisco?",
});
consola.debug("response:", response.message.content);

strictEqual(sources.length, 1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@himself65 i removed sources (the tooloutput) 1. the name is confusing 2. it can be retrieved with events

@marcusschiesser marcusschiesser marked this pull request as ready for review June 17, 2024 15:31
@himself65 himself65 merged commit 436bc41 into main Jun 17, 2024
15 of 16 checks passed
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.

2 participants