adding AI SDK by Vercel sample to AI Cookbook#23
Conversation
8033b55 to
98359f4
Compare
98359f4 to
f2da28e
Compare
Signed-off-by: Cornelia Davis <cornelia.davis@temporal.io>
cdavisafc
left a comment
There was a problem hiding this comment.
Runs fine. See comments throughout.
I've added one commit to this to exclude the node_modules directory - standard practice for typescript projects. I did this by adding the the root cookbook .gitignore in anticipation of more typescript example.
| - Automatically wraps the LLM invocation as an activity | ||
| - Configures `temporalProvider` to point to `gpt-4o-mini` but you can use any model of your choice that is compatible with the AI SDK here. | ||
| - **Tools-as-Activities**: `proxyActivities` wires the `getWeather` and `calculateCircleArea` Activities into the Workflows so `toolsAgent` can offer tool schemas to the AI model, wait for results durably, and retry requests if needed. | ||
| - **Minimal orchestration**: The Workflow starter (`src/client.ts`) picks a Workflow name (`haiku` or `tools`) and runs it through a connected Temporal cluster, keeping the CLI code simple. |
There was a problem hiding this comment.
Is this really a key pattern. Seems like an implementation detail.
| }, | ||
| }); | ||
|
|
||
| export async function haikuAgent(prompt: string): Promise<string> { |
There was a problem hiding this comment.
Why are we including two workflows in this example. What value does the haiku workflow offer in this recipe?
| @@ -0,0 +1,16 @@ | |||
| export async function getWeather(input: { | |||
There was a problem hiding this comment.
Should we make a real API call to National Weather Service APIs, for example.
| }; | ||
| } | ||
|
|
||
| export async function calculateAreaOfCircle(input: { |
There was a problem hiding this comment.
Good example of an activity that doesn't go external.
| workflowId: 'workflow-' + nanoid(), | ||
| }); | ||
| break; | ||
| case 'haiku': |
There was a problem hiding this comment.
Same comment from the workflow code - why are we including haiku?
| model: temporalProvider.languageModel('gpt-4o-mini'), | ||
| prompt: question, | ||
| system: 'You are a helpful agent.', | ||
| tools: { |
There was a problem hiding this comment.
Are there any APIs that create the tool json from function signatures?
| npm run workflow tools | ||
| ``` | ||
|
|
||
| ## Example prompts |
There was a problem hiding this comment.
How can these example prompts be supplied. The client looks like it just has some hardcoded things.
Signed-off-by: Cornelia Davis <cornelia.davis@temporal.io>
What was changed
added AI SDK by Vercel sample to AI Cookbook
Why?
Checklist
Closes
How was this tested:
Tested locally with the instructions in the README