Function: createAssistant()
createAssistant(
props
):Promise
<VercelAi
|OpenAIAssistant
|DeepSeekAssistant
|GoogleAIAssistant
|XaiAssistant
|OllamaAssistant
|AnthropicAssistant
>
Defined in: packages/core/src/utils/create-assistant.ts:42
Creates an AI assistant instance with the specified configuration
Parameters
props
Configuration properties for the assistant. See UseAssistantProps for more details.
Returns
Promise
<VercelAi
| OpenAIAssistant
| DeepSeekAssistant
| GoogleAIAssistant
| XaiAssistant
| OllamaAssistant
| AnthropicAssistant
>
Promise that resolves to the configured assistant instance
Example
const assistant = await createAssistant({
modelProvider: 'openai',
model: 'gpt-4',
apiKey: 'your-api-key',
instructions: 'You are a helpful assistant',
tools: [
tool({
description: 'Get the weather in a location',
parameters: z.object({ location: z.string() }),
execute: async ({ location }, option) => {
const getStation = options.context?.getStation;
const station = getStation ? await getStation(location) : null;
return { llmResult: `Weather in ${location} from station ${station}.` };
},
context: {
getStation: async (location) => {
return { station: '123' };
},
},
component: WeatherComponent,
})
]
});