-
Notifications
You must be signed in to change notification settings - Fork 11
adding AI SDK by Vercel sample to AI Cookbook #23
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
base: main
Are you sure you want to change the base?
Conversation
8033b55 to
98359f4
Compare
98359f4 to
f2da28e
Compare
Signed-off-by: Cornelia Davis <[email protected]>
cdavisafc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good example of an activity that doesn't go external.
| workflowId: 'workflow-' + nanoid(), | ||
| }); | ||
| break; | ||
| case 'haiku': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can these example prompts be supplied. The client looks like it just has some hardcoded things.
Signed-off-by: Cornelia Davis <[email protected]>
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