Skip to content

Commit

Permalink
Fixups to code sample
Browse files Browse the repository at this point in the history
  • Loading branch information
hemanth authored Oct 17, 2024
1 parent 42cf59c commit fa45f9d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ Because of their special behavior of being preserved on context window overflow,
A special case of the above is using the assistant role to emulate tool use or function-calling, by marking a response as coming from the assistant side of the conversation:

```js
const session = await ai.assistant.create({
const session = await ai.languageModel.create({
systemPrompt: `
You are a helpful assistant. You have access to the following tools:
- calculator: A calculator. To use it, write "CALCULATOR: <expression>" where <expression> is a valid mathematical expression.
`
});

async function promptWithCalculator(prompt) {
const result = await session.prompt("What is 2 + 2?");
const result = await session.prompt(prompt);

// Check if the assistant wants to use the calculator tool.
const match = /^CALCULATOR: (.*)$/.exec(result);
Expand Down

0 comments on commit fa45f9d

Please sign in to comment.