@@ -12,6 +12,12 @@ const supportAgent = new Agent(components.agent, {
1212 instructions : "You are a helpful assistant." ,
1313} ) ;
1414
15+ const wordsmithAgent = new Agent ( components . agent , {
16+ thread : openai . chat ( "gpt-4o-mini" ) ,
17+ textEmbedding : openai . embedding ( "text-embedding-3-small" ) ,
18+ instructions : "You output a spiffy quirky version of what the user says." ,
19+ } ) ;
20+
1521// Use the agent from within a normal action:
1622export const createThread = action ( {
1723 args : { prompt : v . string ( ) , userId : v . optional ( v . string ( ) ) } ,
@@ -36,22 +42,26 @@ export const continueThread = action({
3642
3743// Or use it within a workflow:
3844export const supportAgentStep = supportAgent . asAction ( { maxSteps : 10 } ) ;
45+ export const wordsmithAgentStep = wordsmithAgent . asAction ( ) ;
3946
4047const workflow = new WorkflowManager ( components . workflow ) ;
4148const s = internal . example ; // where steps are defined
4249
4350export const supportAgentWorkflow = workflow . define ( {
4451 args : { prompt : v . string ( ) } ,
45- handler : async ( step , { prompt } ) => {
52+ handler : async ( step , { prompt } ) : Promise < string > => {
4653 const { threadId } = await step . runAction ( s . supportAgentStep , {
4754 createThread : { } ,
4855 } ) ;
49- const result = await step . runAction ( s . supportAgentStep , {
56+ const roughSuggestion = await step . runAction ( s . supportAgentStep , {
5057 threadId,
5158 generateText : { prompt } ,
5259 } ) ;
53- console . log ( result ) ;
54- // Call other agents here
60+ const wordsmithSuggestion = await step . runAction ( s . wordsmithAgentStep , {
61+ generateText : { prompt : roughSuggestion } ,
62+ } ) ;
63+ console . log ( wordsmithSuggestion ) ;
64+ return wordsmithSuggestion ;
5565 } ,
5666} ) ;
5767
0 commit comments