Skip to content

feat (core): add responseMessages to generateText result#1732

Merged
lgrammel merged 5 commits intomainfrom
lg/response-messages
May 29, 2024
Merged

feat (core): add responseMessages to generateText result#1732
lgrammel merged 5 commits intomainfrom
lg/response-messages

Conversation

@lgrammel
Copy link
Copy Markdown
Collaborator

@lgrammel lgrammel commented May 29, 2024

Summary

Adds a resultMessages property to the generateText result. It contains (potentially multiple) CoreMessage objects representing the assistant response and any available tool results.

These messages can be appended to the chat history. This lays the groundwork for adding automatic roundtrips to generateText.

Tasks

  • implement
  • test
  • update example
  • reference docs
  • changeset

@lgrammel lgrammel self-assigned this May 29, 2024
Comment on lines -52 to -59
messages.push({
role: 'assistant',
content: [{ type: 'text', text }, ...(toolCalls ?? [])],
});

if (toolResults.length > 0) {
messages.push({ role: 'tool', content: toolResults });
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is in essence the benefit of this PR. It'll make automatic tool calling loops in agents simpler.

@lgrammel lgrammel marked this pull request as ready for review May 29, 2024 14:19
@lgrammel lgrammel merged commit 1c0ebf8 into main May 29, 2024
@lgrammel lgrammel deleted the lg/response-messages branch May 29, 2024 14:27
Rajaniraiyn pushed a commit to Rajaniraiyn/ai that referenced this pull request Jun 1, 2024
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