Skip to main content

AIAgentElement

AIAgentElement represents a configurable AI agent element in the scene or application. It provides abstraction for connecting to different AI providers with prompt, model, and memory customization.

Example:

const agent = new AIAgentElement();
scene.add(agent);

aiName: string

The display name or alias for this AI agent. Used for identification in UIs, logs, or conversational prompts.

Example:

agent.aiName = "HelperBot";

provider: AIProvider

Specifies the backend AI service provider to use for processing prompts. Must be one of the supported AIProvider values:

  • "openai-assistant"
  • "openai-completion"
  • "azure-ai"
  • "ollama"

Example:

agent.provider = "openai-assistant";

apiKey: string

The API key used to authenticate with the selected provider. Should be kept secure and not exposed on the client side in production.

Example:

agent.apiKey = "sk-xxxxxxxxxxxxxx";

systemPrompt: string

The system prompt that sets the default behavior, tone, and context of the AI agent. Injected into every conversation or completion request.

Example:

agent.systemPrompt = "You are a helpful assistant for 3D scene management.";

model: string

The model identifier used by the selected provider (e.g., "gpt-4", "claude-3-opus", "gemini-1.5"). Must match a valid model name supported by the chosen provider.

Example:

agent.model = "gpt-4";

memory: Persistable | string

Optional persistent memory object or memory identifier. Enables long-term context retention across multiple interactions with the AI agent.

Example:

agent.memory = "ai-helper-memory";