AssistantsPlanner class
A Planner that uses the OpenAI Assistants API.
Constructors
Assistants |
Creates a new |
Methods
begin |
Starts a new task. |
continue |
Continues the current task. |
create |
Static helper method for programmatically creating an assistant. |
Constructor Details
AssistantsPlanner<TState>(AssistantsPlannerOptions)
Creates a new AssistantsPlanner
instance.
new AssistantsPlanner(options: AssistantsPlannerOptions)
Parameters
- options
- AssistantsPlannerOptions
Options for configuring the AssistantsPlanner.
Method Details
beginTask(TurnContext, TState, AI<TState>)
Starts a new task.
function beginTask(context: TurnContext, state: TState, ai: AI<TState>): Promise<Plan>
Parameters
- context
-
TurnContext
Context for the current turn of conversation.
- state
-
TState
Application state for the current turn of conversation.
- ai
-
AI<TState>
The AI system that is generating the plan.
Returns
Promise<Plan>
The plan that was generated.
Remarks
This method is called when the AI system is ready to start a new task. The planner should generate a plan that the AI system will execute. Returning an empty plan signals that there is no work to be performed.
The planner should take the users input from state.temp.input
.
continueTask(TurnContext, TState, AI<TState>)
Continues the current task.
function continueTask(context: TurnContext, state: TState, ai: AI<TState>): Promise<Plan>
Parameters
- context
-
TurnContext
Context for the current turn of conversation.
- state
-
TState
Application state for the current turn of conversation.
- ai
-
AI<TState>
The AI system that is generating the plan.
Returns
Promise<Plan>
The plan that was generated.
Remarks
This method is called when the AI system has finished executing the previous plan and is ready to continue the current task. The planner should generate a plan that the AI system will execute. Returning an empty plan signals that the task is completed and there is no work to be performed.
The output from the last plan step that was executed is passed to the planner via state.temp.input
.
createAssistant(string, AssistantCreationOptions, string)
Static helper method for programmatically creating an assistant.
static function createAssistant(apiKey: string, request: AssistantCreationOptions, endpoint?: string): Promise<Assistant>
Parameters
- apiKey
-
string
OpenAI API key.
- request
- AssistantCreationOptions
Definition of the assistant to create.
- endpoint
-
string
The Azure OpenAI resource endpoint.
Returns
Promise<Assistant>
The created assistant.