@upstash/workflow 0.2.5-agent-1 → 0.2.5-agents-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/astro.d.mts +3 -1
- package/astro.d.ts +3 -1
- package/astro.js +292 -23
- package/astro.mjs +1 -1
- package/{chunk-ETDFMXER.mjs → chunk-VOM3CFYZ.mjs} +292 -23
- package/cloudflare.d.mts +3 -1
- package/cloudflare.d.ts +3 -1
- package/cloudflare.js +292 -23
- package/cloudflare.mjs +1 -1
- package/express.d.mts +3 -1
- package/express.d.ts +3 -1
- package/express.js +292 -23
- package/express.mjs +1 -1
- package/h3.d.mts +3 -1
- package/h3.d.ts +3 -1
- package/h3.js +292 -23
- package/h3.mjs +1 -1
- package/hono.d.mts +3 -1
- package/hono.d.ts +3 -1
- package/hono.js +292 -23
- package/hono.mjs +1 -1
- package/index.d.mts +4 -2
- package/index.d.ts +4 -2
- package/index.js +292 -23
- package/index.mjs +1 -1
- package/nextjs.d.mts +3 -1
- package/nextjs.d.ts +3 -1
- package/nextjs.js +292 -23
- package/nextjs.mjs +1 -1
- package/package.json +1 -1
- package/solidjs.d.mts +3 -1
- package/solidjs.d.ts +3 -1
- package/solidjs.js +292 -23
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +3 -1
- package/svelte.d.ts +3 -1
- package/svelte.js +292 -23
- package/svelte.mjs +1 -1
- package/{types-Bt4-paRy.d.mts → types-D9gwTj2n.d.mts} +237 -0
- package/{types-Bt4-paRy.d.ts → types-D9gwTj2n.d.ts} +237 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { PublishRequest, Client, Receiver, HTTPMethods as HTTPMethods$1 } from '@upstash/qstash';
|
|
2
|
+
import * as ai from 'ai';
|
|
3
|
+
import { CoreTool, generateText } from 'ai';
|
|
4
|
+
import * as _ai_sdk_openai from '@ai-sdk/openai';
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* Base class outlining steps. Basically, each step kind (run/sleep/sleepUntil)
|
|
@@ -387,6 +390,239 @@ declare class WorkflowApi extends BaseWorkflowApi {
|
|
|
387
390
|
get anthropic(): AnthropicAPI;
|
|
388
391
|
}
|
|
389
392
|
|
|
393
|
+
/**
|
|
394
|
+
* An Agent which utilizes the model and tools available to it
|
|
395
|
+
* to achieve a given task
|
|
396
|
+
*
|
|
397
|
+
* @param name Name of the agent
|
|
398
|
+
* @param background Background of the agent
|
|
399
|
+
* @param model LLM model to use
|
|
400
|
+
* @param tools tools available to the agent
|
|
401
|
+
* @param maxSteps number of times the agent can call the LLM at most. If
|
|
402
|
+
* the agent abruptly stops execution after calling tools, you may need
|
|
403
|
+
* to increase maxSteps
|
|
404
|
+
* @param temparature temparature used when calling the LLM
|
|
405
|
+
*/
|
|
406
|
+
declare class Agent {
|
|
407
|
+
readonly name: AgentParameters["name"];
|
|
408
|
+
readonly tools: AgentParameters["tools"];
|
|
409
|
+
readonly maxSteps: AgentParameters["maxSteps"];
|
|
410
|
+
readonly background: AgentParameters["background"];
|
|
411
|
+
readonly model: AgentParameters["model"];
|
|
412
|
+
readonly temparature: AgentParameters["temparature"];
|
|
413
|
+
constructor({ tools, maxSteps, background, name, model, temparature }: AgentParameters);
|
|
414
|
+
/**
|
|
415
|
+
* Trigger the agent by passing a prompt
|
|
416
|
+
*
|
|
417
|
+
* @param prompt task to assign to the agent
|
|
418
|
+
* @returns Response as `{ text: string }`
|
|
419
|
+
*/
|
|
420
|
+
call({ prompt }: {
|
|
421
|
+
prompt: string;
|
|
422
|
+
}): Promise<{
|
|
423
|
+
text: string;
|
|
424
|
+
}>;
|
|
425
|
+
/**
|
|
426
|
+
* Convert the agent to a tool which can be used by other agents.
|
|
427
|
+
*
|
|
428
|
+
* @returns the agent as a tool
|
|
429
|
+
*/
|
|
430
|
+
asTool(): AISDKTool;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
type AISDKTool = CoreTool;
|
|
434
|
+
type LangchainTool = {
|
|
435
|
+
description: string;
|
|
436
|
+
schema: AISDKTool["parameters"];
|
|
437
|
+
invoke: (...params: any[]) => any;
|
|
438
|
+
};
|
|
439
|
+
type GenerateTextParams = Parameters<typeof generateText>[0];
|
|
440
|
+
type Model = GenerateTextParams["model"];
|
|
441
|
+
type AgentParameters<TTool extends AISDKTool | LangchainTool = AISDKTool> = {
|
|
442
|
+
/**
|
|
443
|
+
* number of times the agent can call the LLM at most. If
|
|
444
|
+
* the agent abruptly stops execution after calling tools, you may need
|
|
445
|
+
* to increase maxSteps
|
|
446
|
+
*/
|
|
447
|
+
maxSteps: number;
|
|
448
|
+
/**
|
|
449
|
+
* Background of the agent
|
|
450
|
+
*/
|
|
451
|
+
background: string;
|
|
452
|
+
/**
|
|
453
|
+
* tools available to the agent
|
|
454
|
+
*/
|
|
455
|
+
tools: Record<string, TTool>;
|
|
456
|
+
/**
|
|
457
|
+
* Name of the agent
|
|
458
|
+
*/
|
|
459
|
+
name: string;
|
|
460
|
+
/**
|
|
461
|
+
* LLM model to use
|
|
462
|
+
*/
|
|
463
|
+
model: Model;
|
|
464
|
+
/**
|
|
465
|
+
* temparature used when calling the LLM
|
|
466
|
+
*
|
|
467
|
+
* @default 0.1
|
|
468
|
+
*/
|
|
469
|
+
temparature?: number;
|
|
470
|
+
};
|
|
471
|
+
type TaskParams = {
|
|
472
|
+
/**
|
|
473
|
+
* task assigned to the agent
|
|
474
|
+
*/
|
|
475
|
+
prompt: string;
|
|
476
|
+
};
|
|
477
|
+
type SingleAgentTaskParams = TaskParams & {
|
|
478
|
+
/**
|
|
479
|
+
* agent to perform the task
|
|
480
|
+
*/
|
|
481
|
+
agent: Agent;
|
|
482
|
+
};
|
|
483
|
+
type MultiAgentTaskParams = TaskParams & {
|
|
484
|
+
/**
|
|
485
|
+
* Agents which will collaborate to achieve the task
|
|
486
|
+
*/
|
|
487
|
+
agents: Agent[];
|
|
488
|
+
/**
|
|
489
|
+
* number of times the manager agent can call the LLM at most.
|
|
490
|
+
* If the agent abruptly stops execution after calling other agents, you may
|
|
491
|
+
* need to increase maxSteps
|
|
492
|
+
*/
|
|
493
|
+
maxSteps: number;
|
|
494
|
+
/**
|
|
495
|
+
* LLM model to use
|
|
496
|
+
*/
|
|
497
|
+
model: Model;
|
|
498
|
+
/**
|
|
499
|
+
* Background of the agent. If not passed, default will be used.
|
|
500
|
+
*/
|
|
501
|
+
background?: string;
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* creates an AI SDK openai client with a custom
|
|
506
|
+
* fetch implementation which uses context.call.
|
|
507
|
+
*
|
|
508
|
+
* @param context workflow context
|
|
509
|
+
* @returns ai sdk openai
|
|
510
|
+
*/
|
|
511
|
+
declare const createWorkflowOpenAI: (context: WorkflowContext) => _ai_sdk_openai.OpenAIProvider;
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* An Agent Task
|
|
515
|
+
*
|
|
516
|
+
* Can be run to make the agent(s) complete it using the tools available to them
|
|
517
|
+
*
|
|
518
|
+
* Can consist of a single agent or multiple agents.
|
|
519
|
+
*
|
|
520
|
+
* Single agent:
|
|
521
|
+
*
|
|
522
|
+
* ```ts
|
|
523
|
+
* const task = context.agents.task({
|
|
524
|
+
* agent: researcherAgent,
|
|
525
|
+
* prompt: "Tell me about 5 topics in advanced physics.",
|
|
526
|
+
* });
|
|
527
|
+
* const { text } = await task.run();
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* Multi Agent:
|
|
531
|
+
*
|
|
532
|
+
* ```ts
|
|
533
|
+
* const task = context.agents.task({
|
|
534
|
+
* model,
|
|
535
|
+
* maxSteps: 3,
|
|
536
|
+
* agents: [researcherAgent, mathAgent],
|
|
537
|
+
* prompt: "Tell me about 3 cities in Japan and calculate the sum of their populations",
|
|
538
|
+
* });
|
|
539
|
+
* const { text } = await task.run();
|
|
540
|
+
* ```
|
|
541
|
+
*/
|
|
542
|
+
declare class Task {
|
|
543
|
+
private readonly context;
|
|
544
|
+
private readonly taskParameters;
|
|
545
|
+
constructor({ context, taskParameters, }: {
|
|
546
|
+
context: WorkflowContext;
|
|
547
|
+
taskParameters: SingleAgentTaskParams | MultiAgentTaskParams;
|
|
548
|
+
});
|
|
549
|
+
/**
|
|
550
|
+
* Run the agents to complete the task
|
|
551
|
+
*
|
|
552
|
+
* @returns Result of the task as { text: string }
|
|
553
|
+
*/
|
|
554
|
+
run(): Promise<{
|
|
555
|
+
text: string;
|
|
556
|
+
}>;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Workflow Agents API
|
|
561
|
+
*
|
|
562
|
+
* https://upstash.com/docs/workflow/agents/overview
|
|
563
|
+
*
|
|
564
|
+
* Allows defining agents which can complete a given task
|
|
565
|
+
* using tools available to them.
|
|
566
|
+
*/
|
|
567
|
+
declare class WorkflowAgents {
|
|
568
|
+
private context;
|
|
569
|
+
constructor({ context }: {
|
|
570
|
+
context: WorkflowContext;
|
|
571
|
+
});
|
|
572
|
+
/**
|
|
573
|
+
* Defines an agent
|
|
574
|
+
*
|
|
575
|
+
* ```ts
|
|
576
|
+
* const researcherAgent = context.agents.agent({
|
|
577
|
+
* model,
|
|
578
|
+
* name: 'academic',
|
|
579
|
+
* maxSteps: 2,
|
|
580
|
+
* tools: {
|
|
581
|
+
* wikiTool: new WikipediaQueryRun({
|
|
582
|
+
* topKResults: 1,
|
|
583
|
+
* maxDocContentLength: 500,
|
|
584
|
+
* })
|
|
585
|
+
* },
|
|
586
|
+
* background:
|
|
587
|
+
* 'You are researcher agent with access to Wikipedia. ' +
|
|
588
|
+
* 'Utilize Wikipedia as much as possible for correct information',
|
|
589
|
+
* });
|
|
590
|
+
* ```
|
|
591
|
+
*
|
|
592
|
+
* @param params agent parameters
|
|
593
|
+
* @returns
|
|
594
|
+
*/
|
|
595
|
+
agent(params: AgentParameters<AISDKTool | LangchainTool>): Agent;
|
|
596
|
+
/**
|
|
597
|
+
* Defines a task to be executed by a single agent
|
|
598
|
+
*
|
|
599
|
+
* ```ts
|
|
600
|
+
* const task = context.agents.task({
|
|
601
|
+
* agent: researcherAgent,
|
|
602
|
+
* prompt: "Tell me about 5 topics in advanced physics.",
|
|
603
|
+
* });
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
606
|
+
task(taskParameters: SingleAgentTaskParams): Task;
|
|
607
|
+
/**
|
|
608
|
+
* Defines a task to be executed by multiple collaborating agents
|
|
609
|
+
*
|
|
610
|
+
* ```ts
|
|
611
|
+
* const task = context.agents.task({
|
|
612
|
+
* model,
|
|
613
|
+
* maxSteps: 3,
|
|
614
|
+
* agents: [researcherAgent, mathAgent],
|
|
615
|
+
* prompt: "Tell me about 3 cities in Japan and calculate the sum of their populations",
|
|
616
|
+
* });
|
|
617
|
+
* ```
|
|
618
|
+
*/
|
|
619
|
+
task(taskParameters: MultiAgentTaskParams): Task;
|
|
620
|
+
/**
|
|
621
|
+
* creates an openai model for agents
|
|
622
|
+
*/
|
|
623
|
+
openai(...params: Parameters<ReturnType<typeof createWorkflowOpenAI>>): ai.LanguageModelV1;
|
|
624
|
+
}
|
|
625
|
+
|
|
390
626
|
/**
|
|
391
627
|
* Upstash Workflow context
|
|
392
628
|
*
|
|
@@ -682,6 +918,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
682
918
|
*/
|
|
683
919
|
protected addStep<TResult = unknown>(step: BaseLazyStep<TResult>): Promise<TResult>;
|
|
684
920
|
get api(): WorkflowApi;
|
|
921
|
+
get agents(): WorkflowAgents;
|
|
685
922
|
}
|
|
686
923
|
|
|
687
924
|
/**
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { PublishRequest, Client, Receiver, HTTPMethods as HTTPMethods$1 } from '@upstash/qstash';
|
|
2
|
+
import * as ai from 'ai';
|
|
3
|
+
import { CoreTool, generateText } from 'ai';
|
|
4
|
+
import * as _ai_sdk_openai from '@ai-sdk/openai';
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* Base class outlining steps. Basically, each step kind (run/sleep/sleepUntil)
|
|
@@ -387,6 +390,239 @@ declare class WorkflowApi extends BaseWorkflowApi {
|
|
|
387
390
|
get anthropic(): AnthropicAPI;
|
|
388
391
|
}
|
|
389
392
|
|
|
393
|
+
/**
|
|
394
|
+
* An Agent which utilizes the model and tools available to it
|
|
395
|
+
* to achieve a given task
|
|
396
|
+
*
|
|
397
|
+
* @param name Name of the agent
|
|
398
|
+
* @param background Background of the agent
|
|
399
|
+
* @param model LLM model to use
|
|
400
|
+
* @param tools tools available to the agent
|
|
401
|
+
* @param maxSteps number of times the agent can call the LLM at most. If
|
|
402
|
+
* the agent abruptly stops execution after calling tools, you may need
|
|
403
|
+
* to increase maxSteps
|
|
404
|
+
* @param temparature temparature used when calling the LLM
|
|
405
|
+
*/
|
|
406
|
+
declare class Agent {
|
|
407
|
+
readonly name: AgentParameters["name"];
|
|
408
|
+
readonly tools: AgentParameters["tools"];
|
|
409
|
+
readonly maxSteps: AgentParameters["maxSteps"];
|
|
410
|
+
readonly background: AgentParameters["background"];
|
|
411
|
+
readonly model: AgentParameters["model"];
|
|
412
|
+
readonly temparature: AgentParameters["temparature"];
|
|
413
|
+
constructor({ tools, maxSteps, background, name, model, temparature }: AgentParameters);
|
|
414
|
+
/**
|
|
415
|
+
* Trigger the agent by passing a prompt
|
|
416
|
+
*
|
|
417
|
+
* @param prompt task to assign to the agent
|
|
418
|
+
* @returns Response as `{ text: string }`
|
|
419
|
+
*/
|
|
420
|
+
call({ prompt }: {
|
|
421
|
+
prompt: string;
|
|
422
|
+
}): Promise<{
|
|
423
|
+
text: string;
|
|
424
|
+
}>;
|
|
425
|
+
/**
|
|
426
|
+
* Convert the agent to a tool which can be used by other agents.
|
|
427
|
+
*
|
|
428
|
+
* @returns the agent as a tool
|
|
429
|
+
*/
|
|
430
|
+
asTool(): AISDKTool;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
type AISDKTool = CoreTool;
|
|
434
|
+
type LangchainTool = {
|
|
435
|
+
description: string;
|
|
436
|
+
schema: AISDKTool["parameters"];
|
|
437
|
+
invoke: (...params: any[]) => any;
|
|
438
|
+
};
|
|
439
|
+
type GenerateTextParams = Parameters<typeof generateText>[0];
|
|
440
|
+
type Model = GenerateTextParams["model"];
|
|
441
|
+
type AgentParameters<TTool extends AISDKTool | LangchainTool = AISDKTool> = {
|
|
442
|
+
/**
|
|
443
|
+
* number of times the agent can call the LLM at most. If
|
|
444
|
+
* the agent abruptly stops execution after calling tools, you may need
|
|
445
|
+
* to increase maxSteps
|
|
446
|
+
*/
|
|
447
|
+
maxSteps: number;
|
|
448
|
+
/**
|
|
449
|
+
* Background of the agent
|
|
450
|
+
*/
|
|
451
|
+
background: string;
|
|
452
|
+
/**
|
|
453
|
+
* tools available to the agent
|
|
454
|
+
*/
|
|
455
|
+
tools: Record<string, TTool>;
|
|
456
|
+
/**
|
|
457
|
+
* Name of the agent
|
|
458
|
+
*/
|
|
459
|
+
name: string;
|
|
460
|
+
/**
|
|
461
|
+
* LLM model to use
|
|
462
|
+
*/
|
|
463
|
+
model: Model;
|
|
464
|
+
/**
|
|
465
|
+
* temparature used when calling the LLM
|
|
466
|
+
*
|
|
467
|
+
* @default 0.1
|
|
468
|
+
*/
|
|
469
|
+
temparature?: number;
|
|
470
|
+
};
|
|
471
|
+
type TaskParams = {
|
|
472
|
+
/**
|
|
473
|
+
* task assigned to the agent
|
|
474
|
+
*/
|
|
475
|
+
prompt: string;
|
|
476
|
+
};
|
|
477
|
+
type SingleAgentTaskParams = TaskParams & {
|
|
478
|
+
/**
|
|
479
|
+
* agent to perform the task
|
|
480
|
+
*/
|
|
481
|
+
agent: Agent;
|
|
482
|
+
};
|
|
483
|
+
type MultiAgentTaskParams = TaskParams & {
|
|
484
|
+
/**
|
|
485
|
+
* Agents which will collaborate to achieve the task
|
|
486
|
+
*/
|
|
487
|
+
agents: Agent[];
|
|
488
|
+
/**
|
|
489
|
+
* number of times the manager agent can call the LLM at most.
|
|
490
|
+
* If the agent abruptly stops execution after calling other agents, you may
|
|
491
|
+
* need to increase maxSteps
|
|
492
|
+
*/
|
|
493
|
+
maxSteps: number;
|
|
494
|
+
/**
|
|
495
|
+
* LLM model to use
|
|
496
|
+
*/
|
|
497
|
+
model: Model;
|
|
498
|
+
/**
|
|
499
|
+
* Background of the agent. If not passed, default will be used.
|
|
500
|
+
*/
|
|
501
|
+
background?: string;
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* creates an AI SDK openai client with a custom
|
|
506
|
+
* fetch implementation which uses context.call.
|
|
507
|
+
*
|
|
508
|
+
* @param context workflow context
|
|
509
|
+
* @returns ai sdk openai
|
|
510
|
+
*/
|
|
511
|
+
declare const createWorkflowOpenAI: (context: WorkflowContext) => _ai_sdk_openai.OpenAIProvider;
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* An Agent Task
|
|
515
|
+
*
|
|
516
|
+
* Can be run to make the agent(s) complete it using the tools available to them
|
|
517
|
+
*
|
|
518
|
+
* Can consist of a single agent or multiple agents.
|
|
519
|
+
*
|
|
520
|
+
* Single agent:
|
|
521
|
+
*
|
|
522
|
+
* ```ts
|
|
523
|
+
* const task = context.agents.task({
|
|
524
|
+
* agent: researcherAgent,
|
|
525
|
+
* prompt: "Tell me about 5 topics in advanced physics.",
|
|
526
|
+
* });
|
|
527
|
+
* const { text } = await task.run();
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* Multi Agent:
|
|
531
|
+
*
|
|
532
|
+
* ```ts
|
|
533
|
+
* const task = context.agents.task({
|
|
534
|
+
* model,
|
|
535
|
+
* maxSteps: 3,
|
|
536
|
+
* agents: [researcherAgent, mathAgent],
|
|
537
|
+
* prompt: "Tell me about 3 cities in Japan and calculate the sum of their populations",
|
|
538
|
+
* });
|
|
539
|
+
* const { text } = await task.run();
|
|
540
|
+
* ```
|
|
541
|
+
*/
|
|
542
|
+
declare class Task {
|
|
543
|
+
private readonly context;
|
|
544
|
+
private readonly taskParameters;
|
|
545
|
+
constructor({ context, taskParameters, }: {
|
|
546
|
+
context: WorkflowContext;
|
|
547
|
+
taskParameters: SingleAgentTaskParams | MultiAgentTaskParams;
|
|
548
|
+
});
|
|
549
|
+
/**
|
|
550
|
+
* Run the agents to complete the task
|
|
551
|
+
*
|
|
552
|
+
* @returns Result of the task as { text: string }
|
|
553
|
+
*/
|
|
554
|
+
run(): Promise<{
|
|
555
|
+
text: string;
|
|
556
|
+
}>;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Workflow Agents API
|
|
561
|
+
*
|
|
562
|
+
* https://upstash.com/docs/workflow/agents/overview
|
|
563
|
+
*
|
|
564
|
+
* Allows defining agents which can complete a given task
|
|
565
|
+
* using tools available to them.
|
|
566
|
+
*/
|
|
567
|
+
declare class WorkflowAgents {
|
|
568
|
+
private context;
|
|
569
|
+
constructor({ context }: {
|
|
570
|
+
context: WorkflowContext;
|
|
571
|
+
});
|
|
572
|
+
/**
|
|
573
|
+
* Defines an agent
|
|
574
|
+
*
|
|
575
|
+
* ```ts
|
|
576
|
+
* const researcherAgent = context.agents.agent({
|
|
577
|
+
* model,
|
|
578
|
+
* name: 'academic',
|
|
579
|
+
* maxSteps: 2,
|
|
580
|
+
* tools: {
|
|
581
|
+
* wikiTool: new WikipediaQueryRun({
|
|
582
|
+
* topKResults: 1,
|
|
583
|
+
* maxDocContentLength: 500,
|
|
584
|
+
* })
|
|
585
|
+
* },
|
|
586
|
+
* background:
|
|
587
|
+
* 'You are researcher agent with access to Wikipedia. ' +
|
|
588
|
+
* 'Utilize Wikipedia as much as possible for correct information',
|
|
589
|
+
* });
|
|
590
|
+
* ```
|
|
591
|
+
*
|
|
592
|
+
* @param params agent parameters
|
|
593
|
+
* @returns
|
|
594
|
+
*/
|
|
595
|
+
agent(params: AgentParameters<AISDKTool | LangchainTool>): Agent;
|
|
596
|
+
/**
|
|
597
|
+
* Defines a task to be executed by a single agent
|
|
598
|
+
*
|
|
599
|
+
* ```ts
|
|
600
|
+
* const task = context.agents.task({
|
|
601
|
+
* agent: researcherAgent,
|
|
602
|
+
* prompt: "Tell me about 5 topics in advanced physics.",
|
|
603
|
+
* });
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
606
|
+
task(taskParameters: SingleAgentTaskParams): Task;
|
|
607
|
+
/**
|
|
608
|
+
* Defines a task to be executed by multiple collaborating agents
|
|
609
|
+
*
|
|
610
|
+
* ```ts
|
|
611
|
+
* const task = context.agents.task({
|
|
612
|
+
* model,
|
|
613
|
+
* maxSteps: 3,
|
|
614
|
+
* agents: [researcherAgent, mathAgent],
|
|
615
|
+
* prompt: "Tell me about 3 cities in Japan and calculate the sum of their populations",
|
|
616
|
+
* });
|
|
617
|
+
* ```
|
|
618
|
+
*/
|
|
619
|
+
task(taskParameters: MultiAgentTaskParams): Task;
|
|
620
|
+
/**
|
|
621
|
+
* creates an openai model for agents
|
|
622
|
+
*/
|
|
623
|
+
openai(...params: Parameters<ReturnType<typeof createWorkflowOpenAI>>): ai.LanguageModelV1;
|
|
624
|
+
}
|
|
625
|
+
|
|
390
626
|
/**
|
|
391
627
|
* Upstash Workflow context
|
|
392
628
|
*
|
|
@@ -682,6 +918,7 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
682
918
|
*/
|
|
683
919
|
protected addStep<TResult = unknown>(step: BaseLazyStep<TResult>): Promise<TResult>;
|
|
684
920
|
get api(): WorkflowApi;
|
|
921
|
+
get agents(): WorkflowAgents;
|
|
685
922
|
}
|
|
686
923
|
|
|
687
924
|
/**
|