AI Agent
AIAgent Documentation
The AIAgent component is used to define a general purpose artificial intelligence system. The engine will take the information from this component and use it to generate outputs and actions.
Namespace
MetaverseCloudEngine.Unity.AI.Components
Public Methods
void FlushMemory(): Starts the AI agent's thought process. This will clear any previous memory and start the agent fresh.
void SubmitUserInput(string input): Issues user input to the AI agent. The agent will process the input and generate a response.
void Cancel(): Cancels the current thought process.
Public Properties
string Id (read only): The unique identifier of the AI agent.
AiCharacterIntelligencePreset IntelligencePreset: The intelligence preset to use for the AI agent.
string Prompt: The prompt that the AI agent will use to generate responses.
Inspector Fields
string id: The unique identifier of the AI agent.
AiCharacterIntelligencePreset intelligencePreset: The intelligence preset to use for the AI agent.
AIPrompt prompt: The prompt that the AI agent will use to generate responses.
UnityEvent onThinkingStarted: Invoked when the AI agent starts thinking.
UnityEvent onThinkingFinished: Invoked when the AI agent finishes thinking.
UnityEvent<string> onResponse: Invoked when the AI agent generates a response.
UnityEvent onResponseFailed: Invoked when the AI agent fails to generate a response.
List<AIAgentAction> actions: A list of actions that the AI agent can perform.
AudioSource voiceSource: The AudioSource to play the AI agent's voice from.
TextToSpeechVoicePreset voicePreset: The voice preset to use for the AI agent's voice.
Behavior
Execution Order: This class inherits from TriInspectorMonoBehaviour, which uses the default Unity execution order.
Usage
To use AIAgent, start by adding the component to a GameObject in your scene.
In the inspector, configure the intelligencePreset and prompt properties to specify the behavior of your AI agent.
You can then use the SubmitUserInput() method to send user input to the AI agent.
You can also listen to the events to trigger other behaviors when the AI agent starts thinking, finishes thinking, or generates a response.
Example:
You can use the AIAgent component to create a chatbot that can respond to user input. To do this:
Add the AIAgent component to a GameObject in your scene.
In the inspector, configure the intelligencePreset and prompt properties to specify the behavior of your chatbot.
Create a UI InputField for the user to enter their text.
Add a Unity Event to the InputField's onEndEdit event.
In the Unity Event, select the GameObject that has the AIAgent component and then select the SubmitUserInput method.
In the SubmitUserInput method call, pass in the text from the InputField.
Add a Unity Event to the AIAgent component's onResponse event.
In the Unity Event, display the chatbot's response in a UI Text component.
This will create a chatbot that can respond to user input.
Additional Notes
The AIAgent component uses a third-party AI service to generate responses.
The AiCharacterIntelligencePreset class allows you to select different intelligence presets for the AI agent.
The AIAgentAction class allows you to define actions that the AI agent can perform.
Last updated
Was this helpful?