Class: OpenAIAgentWorker
OpenAI agent worker. This class is responsible for running the agent.
Implements
Constructors
constructor
• new OpenAIAgentWorker(«destructured»
): OpenAIAgentWorker
Initialize.
Parameters
Name | Type |
---|---|
«destructured» | OpenAIAgentWorkerParams |
Returns
Defined in
packages/core/src/agent/openai/worker.ts:103
Properties
_getTools
• Private
_getTools: (input
: string
) => Promise
<BaseTool
[]>
Type declaration
▸ (input
): Promise
<BaseTool
[]>
Parameters
Name | Type |
---|---|
input | string |
Returns
Promise
<BaseTool
[]>
Defined in
packages/core/src/agent/openai/worker.ts:98
callbackManager
• callbackManager: undefined
| CallbackManager
Defined in
packages/core/src/agent/openai/worker.ts:96
llm
• Private
llm: OpenAI
Defined in
packages/core/src/agent/openai/worker.ts:91
maxFunctionCalls
• Private
maxFunctionCalls: number
Defined in
packages/core/src/agent/openai/worker.ts:93
prefixMessages
• prefixMessages: ChatMessage
[]
Defined in
packages/core/src/agent/openai/worker.ts:95
verbose
• Private
verbose: boolean
Defined in
packages/core/src/agent/openai/worker.ts:92
Methods
_getAgentResponse
▸ _getAgentResponse(task
, mode
, llmChatKwargs
): Promise
<AgentChatResponse
>
Get agent response.
Parameters
Name | Type |
---|---|
task | Task |
mode | ChatResponseMode |
llmChatKwargs | any |
Returns
Promise
<AgentChatResponse
>
Defined in
packages/core/src/agent/openai/worker.ts:205
_getLlmChatKwargs
▸ _getLlmChatKwargs(task
, openaiTools
, toolChoice?
): Object
Parameters
Name | Type | Default value |
---|---|---|
task | Task | undefined |
openaiTools | { [key: string] : any ; }[] | undefined |
toolChoice | string | { [key: string] : any ; } | "auto" |
Returns
Object
Defined in
packages/core/src/agent/openai/worker.ts:165
_processMessage
▸ _processMessage(task
, chatResponse
): AsyncIterable
<ChatResponseChunk
> | AgentChatResponse
Process message.
Parameters
Name | Type |
---|---|
task | Task |
chatResponse | ChatResponse |
Returns
AsyncIterable
<ChatResponseChunk
> | AgentChatResponse
Defined in
packages/core/src/agent/openai/worker.ts:188
_runStep
▸ _runStep(step
, task
, mode?
, toolChoice?
): Promise
<TaskStepOutput
>
Parameters
Name | Type | Default value |
---|---|---|
step | TaskStep | undefined |
task | Task | undefined |
mode | ChatResponseMode | ChatResponseMode.WAIT |
toolChoice | string | { [key: string] : any ; } | "auto" |
Returns
Promise
<TaskStepOutput
>
Defined in
packages/core/src/agent/openai/worker.ts:306
_shouldContinue
▸ _shouldContinue(toolCalls
, nFunctionCalls
): boolean
Should continue.
Parameters
Name | Type |
---|---|
toolCalls | null | ChatCompletionMessageToolCall [] |
nFunctionCalls | number |
Returns
boolean
Defined in
packages/core/src/agent/openai/worker.ts:282
callFunction
▸ callFunction(tools
, toolCall
): Promise
<CallFunctionOutput
>
Call function.
Parameters
Name | Type |
---|---|
tools | BaseTool [] |
toolCall | ChatCompletionMessageToolCall |
Returns
Promise
<CallFunctionOutput
>
Defined in
packages/core/src/agent/openai/worker.ts:230
finalizeTask
▸ finalizeTask(task
, kwargs?
): void
Finalize task.
Parameters
Name | Type |
---|---|
task | Task |
kwargs? | any |
Returns
void
Implementation of
Defined in
packages/core/src/agent/openai/worker.ts:402
getAllMessages
▸ getAllMessages(task
): ChatMessage
[]
Get all messages.
Parameters
Name | Type |
---|---|
task | Task |
Returns
Defined in
packages/core/src/agent/openai/worker.ts:135
getLatestToolCalls
▸ getLatestToolCalls(task
): null
| ChatCompletionMessageToolCall
[]
Get latest tool calls.
Parameters
Name | Type |
---|---|
task | Task |
Returns
null
| ChatCompletionMessageToolCall
[]
Defined in
packages/core/src/agent/openai/worker.ts:148
getTools
▸ getTools(input
): Promise
<BaseTool
[]>
Get tools.
Parameters
Name | Type |
---|---|
input | string |
Returns
Promise
<BaseTool
[]>
Defined in
packages/core/src/agent/openai/worker.ts:302
initializeStep
▸ initializeStep(task
, kwargs?
): TaskStep
Initialize step.
Parameters
Name | Type |
---|---|
task | Task |
kwargs? | any |
Returns
Implementation of
Defined in
packages/core/src/agent/openai/worker.ts:257
runStep
▸ runStep(step
, task
, kwargs?
): Promise
<TaskStepOutput
>
Run step.
Parameters
Name | Type |
---|---|
step | TaskStep |
task | Task |
kwargs? | any |
Returns
Promise
<TaskStepOutput
>
Implementation of
Defined in
packages/core/src/agent/openai/worker.ts:371
streamStep
▸ streamStep(step
, task
, kwargs?
): Promise
<TaskStepOutput
>
Stream step.
Parameters
Name | Type |
---|---|
step | TaskStep |
task | Task |
kwargs? | any |
Returns
Promise
<TaskStepOutput
>