openmcp-document/sdk-tutorial/usage/send-multi-message.md

24 lines
819 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Send Multi-turn Conversation
If you want more granular control over the conversation context, you can pass an array to the `ainvoke` method:
```typescript
import { AssistantMessage, UserMessage } from 'openmcp-sdk/service/sdk';
const messages = [
UserMessage('I just had an amazing bowl of Jiming soup dumplings today'),
AssistantMessage('Got it, Ive made a note'),
UserMessage('Can you recall what I ate today?')
]
const result = await agent.ainvoke({ messages });
console.log(result);
```
Running the above code will give you the following response:
```
Based on our previous conversation, you mentioned having **Jiming soup dumplings** today and described them as "amazing"! 😊
Would you like recommendations for similar dishes or to chat more about what made these dumplings special?
```