gleamstral/agent/agent
Types
Represents an agent with configuration options for communication with Mistral AI agents
pub type Agent {
Agent(client: client.Client, config: Config)
}
Constructors
-
Agent(client: client.Client, config: Config)
pub type Config {
Config(
max_tokens: Int,
stream: Bool,
stop: List(String),
random_seed: Int,
response_format: ResponseFormat,
tools: List(tool.Tool),
tool_choice: tool.ToolChoice,
presence_penalty: Float,
frequency_penalty: Float,
n: Int,
prediction: Prediction,
)
}
Constructors
-
Config( max_tokens: Int, stream: Bool, stop: List(String), random_seed: Int, response_format: ResponseFormat, tools: List(tool.Tool), tool_choice: tool.ToolChoice, presence_penalty: Float, frequency_penalty: Float, n: Int, prediction: Prediction, )
pub type Prediction {
Content(String)
}
Constructors
-
Content(String)
pub type ResponseFormat {
JsonObject
Text
}
Constructors
-
JsonObject
-
Text
Functions
pub fn complete(
agent: Agent,
agent_id: String,
messages: List(Message),
) -> Result(Response, Error)
Sends an agent completion request to the API and returns the response
Parameters
agent
: The configured Agent instanceagent_id
: The ID of the Mistral AI agent to interact withmessages
: The conversation history as a list of messages
Returns
Ok(response.Response)
: The successful response from the APIError(client.Error)
: An error that occurred during the request
Example
let result = agent
|> agent.set_max_tokens(1000)
|> agent.complete("agent-123", messages)
pub fn new(client: Client) -> Agent
Creates a new Agent with default configuration using the provided client
Example
let client = client.new("your-api-key")
let agent = agent.new(client)
pub fn set_frequency_penalty(
agent: Agent,
frequency_penalty: Float,
) -> Agent
pub fn set_max_tokens(agent: Agent, max_tokens: Int) -> Agent
pub fn set_prediction(
agent: Agent,
prediction: Prediction,
) -> Agent
pub fn set_presence_penalty(
agent: Agent,
presence_penalty: Float,
) -> Agent
pub fn set_random_seed(agent: Agent, random_seed: Int) -> Agent
pub fn set_response_format(
agent: Agent,
response_format: ResponseFormat,
) -> Agent
pub fn set_stream(agent: Agent, stream: Bool) -> Agent
pub fn set_tool_choice(
agent: Agent,
tool_choice: ToolChoice,
) -> Agent