Overview
The Config struct controls request parameters for the t3.chat API, including search functionality and reasoning effort levels.
Struct Definition
#[derive(Clone)]
pub struct Config {
pub include_search: bool,
pub reasoning_effort: ReasoningEffort,
}
Fields
Whether to include search functionality in the API request. When enabled, the assistant can search for information online.Default: false
The level of reasoning effort to use for the request. Higher levels provide more thorough responses but may take longer.Default: ReasoningEffort::Low
ReasoningEffort Enum
Controls the reasoning effort level for API requests.
#[derive(Clone, Copy)]
pub enum ReasoningEffort {
Low,
Medium,
High,
}
Variants
Minimal reasoning effort for faster responsesString value: "low"
Balanced reasoning effort for moderate complexityString value: "medium"
Maximum reasoning effort for complex queriesString value: "high"
as_str
Returns the string value for the reasoning effort.
pub fn as_str(&self) -> &'static str
The corresponding string value (“low”, “medium”, or “high”)
Example:
use t3router::t3::config::{Config, ReasoningEffort};
let effort = ReasoningEffort::High;
assert_eq!(effort.as_str(), "high");
Constructor
new
Creates a new Config instance with default values.
A new configuration object with default values:
include_search: false
reasoning_effort: ReasoningEffort::Low
Example:
use t3router::t3::config::Config;
let config = Config::new();
assert_eq!(config.include_search, false);
Usage Examples
Default configuration
use t3router::{Client, Message, Type, Config};
let mut client = Client::new(
"cookies".to_string(),
"session_id".to_string()
);
let msg = Message::new(Type::User, "Hello!".to_string());
// Use default config
let response = client.send("gpt-4", Some(msg), Some(Config::new())).await?;
Custom configuration with search enabled
use t3router::t3::{client::Client, message::{Message, Type}, config::{Config, ReasoningEffort}};
let mut config = Config::new();
config.include_search = true;
config.reasoning_effort = ReasoningEffort::Medium;
let msg = Message::new(
Type::User,
"What are the latest developments in quantum computing?".to_string()
);
let response = client.send("gpt-4", Some(msg), Some(config)).await?;
High reasoning effort for complex queries
use t3router::t3::config::{Config, ReasoningEffort};
let mut config = Config::new();
config.reasoning_effort = ReasoningEffort::High;
config.include_search = false;
let msg = Message::new(
Type::User,
"Explain the proof of Fermat's Last Theorem".to_string()
);
let response = client.send("gpt-4", Some(msg), Some(config)).await?;
Comparing reasoning levels
use t3router::t3::config::{Config, ReasoningEffort};
// Quick response
let low_config = Config {
include_search: false,
reasoning_effort: ReasoningEffort::Low,
};
// Balanced approach
let medium_config = Config {
include_search: true,
reasoning_effort: ReasoningEffort::Medium,
};
// Deep analysis
let high_config = Config {
include_search: true,
reasoning_effort: ReasoningEffort::High,
};
Best Practices
When to use different reasoning efforts
- Low: Simple queries, greetings, basic Q&A
- Medium: Moderate complexity, analysis tasks, code explanation
- High: Complex reasoning, mathematical proofs, detailed research
Search functionality
Enable include_search when:
- Asking about current events
- Requesting recent information
- Needing factual verification
- Researching specific topics
use t3router::t3::config::Config;
// For current events
let mut config = Config::new();
config.include_search = true;
let msg = Message::new(
Type::User,
"What happened in the news today?".to_string()
);
Omitting configuration
You can omit the config parameter entirely, and the default configuration will be used automatically:
// These are equivalent:
let response1 = client.send("gpt-4", Some(msg), None).await?;
let response2 = client.send("gpt-4", Some(msg), Some(Config::new())).await?;