Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ subx-cli config set ai.provider openai
# Azure OpenAI setup
export AZURE_OPENAI_API_KEY="your-azure-api-key"
export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com"
export AZURE_OPENAI_DEPLOYMENT_ID="your-deployment-id"
export AZURE_OPENAI_API_VERSION="2025-04-01-preview"
# Note: Azure OpenAI deployment ID is now configured via `ai.model` instead of a separate field
subx-cli config set ai.provider azure-openai
subx-cli config set ai.deployment_id "your-deployment-id"
subx-cli config set ai.model "your-deployment-id"
subx-cli config set ai.api_version "2025-04-01-preview"

# Configure VAD settings
Expand Down
4 changes: 2 additions & 2 deletions README.zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ subx-cli config set ai.provider openai
# Azure OpenAI 設定
export AZURE_OPENAI_API_KEY="your-azure-api-key"
export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com"
export AZURE_OPENAI_DEPLOYMENT_ID="your-deployment-id"
export AZURE_OPENAI_API_VERSION="2025-04-01-preview"
# 注意:Azure OpenAI 部署識別符現已通過 `ai.model` 設定,而非獨立欄位
subx-cli config set ai.provider azure-openai
subx-cli config set ai.deployment_id "your-deployment-id"
subx-cli config set ai.model "your-deployment-id"
subx-cli config set ai.api_version "2025-04-01-preview"

# 配置 VAD 設定
Expand Down
3 changes: 1 addition & 2 deletions docs/configuration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ base_url = "https://openrouter.ai/api/v1"
[ai]
provider = "azure-openai"
api_key = "your-azure-api-key"
model = "your-deployment-id" # Use the Azure OpenAI deployment name here
base_url = "https://your-resource.openai.azure.com"
deployment_id = "your-deployment-id"
api_version = "2025-04-01-preview"
model = "gpt-4o"
```

## Format Configuration (`[formats]`)
Expand Down
4 changes: 0 additions & 4 deletions src/config/field_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ pub fn validate_field(key: &str, value: &str) -> Result<()> {
}

// Azure OpenAI specific fields
"ai.deployment_id" => {
validate_non_empty_string(value, "Azure OpenAI deployment ID")?;
}
"ai.api_version" => {
validate_non_empty_string(value, "Azure OpenAI API version")?;
}
Expand Down Expand Up @@ -207,7 +204,6 @@ pub fn get_field_description(key: &str) -> &'static str {
"ai.retry_attempts" => "Number of retry attempts for AI requests",
"ai.retry_delay_ms" => "Delay between retry attempts in milliseconds",
"ai.request_timeout_seconds" => "Request timeout in seconds",
"ai.deployment_id" => "Azure OpenAI deployment ID (required for azure-openai)",
"ai.api_version" => "Azure OpenAI API version (optional, defaults to latest)",

"sync.default_method" => "Synchronization method ('auto', 'vad', or 'manual')",
Expand Down
5 changes: 0 additions & 5 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,6 @@ pub struct AIConfig {
/// For slow networks or complex requests, you may need to increase this value.
pub request_timeout_seconds: u64,

/// Azure OpenAI deployment ID (required for azure-openai provider)
#[serde(default)]
pub deployment_id: Option<String>,

/// Azure OpenAI API version (optional, defaults to latest)
#[serde(default)]
pub api_version: Option<String>,
Expand All @@ -187,7 +183,6 @@ impl Default for AIConfig {
// Set to 120 seconds to handle slow networks and complex AI requests
// This is especially important for users with high-latency connections
request_timeout_seconds: 120,
deployment_id: None,
api_version: None,
}
}
Expand Down
18 changes: 6 additions & 12 deletions src/config/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,16 @@ impl ProductionConfigService {
debug!("ProductionConfigService: Found AZURE_OPENAI_ENDPOINT environment variable");
app_config.ai.base_url = endpoint;
}
if let Some(version) = self.env_provider.get_var("AZURE_OPENAI_API_VERSION") {
debug!("ProductionConfigService: Found AZURE_OPENAI_API_VERSION environment variable");
app_config.ai.api_version = Some(version);
}
// Special handling for Azure OpenAI deployment ID environment variable
if let Some(deployment) = self.env_provider.get_var("AZURE_OPENAI_DEPLOYMENT_ID") {
debug!(
"ProductionConfigService: Found AZURE_OPENAI_DEPLOYMENT_ID environment variable"
);
app_config.ai.deployment_id = Some(deployment);
}
if let Some(version) = self.env_provider.get_var("AZURE_OPENAI_API_VERSION") {
debug!("ProductionConfigService: Found AZURE_OPENAI_API_VERSION environment variable");
app_config.ai.api_version = Some(version);
app_config.ai.model = deployment;
}

// Validate the configuration
Expand Down Expand Up @@ -371,13 +372,6 @@ impl ProductionConfigService {
let v = value.parse().unwrap(); // Validation already done
config.ai.request_timeout_seconds = v;
}
["ai", "deployment_id"] => {
if !value.is_empty() {
config.ai.deployment_id = Some(value.to_string());
} else {
config.ai.deployment_id = None;
}
}
["ai", "api_version"] => {
if !value.is_empty() {
config.ai.api_version = Some(value.to_string());
Expand Down
13 changes: 1 addition & 12 deletions src/config/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,6 @@ pub fn validate_ai_config(ai_config: &AIConfig) -> Result<()> {
validate_ai_model(&ai_config.model)?;
validate_temperature(ai_config.temperature)?;
validate_positive_number(ai_config.max_tokens as f64)?;
if let Some(dep) = &ai_config.deployment_id {
if dep.trim().is_empty() {
return Err(SubXError::config(
"Azure OpenAI deployment_id must not be empty",
));
}
} else {
return Err(SubXError::config(
"Azure OpenAI deployment_id is required".to_string(),
));
}
if let Some(ver) = &ai_config.api_version {
if ver.trim().is_empty() {
return Err(SubXError::config(
Expand Down Expand Up @@ -352,7 +341,7 @@ mod tests {
let mut ai_config = AIConfig::default();
ai_config.provider = "azure-openai".to_string();
ai_config.api_key = Some("azure-key-123".to_string());
ai_config.deployment_id = Some("dep123".to_string());
ai_config.model = "dep123".to_string();
ai_config.api_version = Some("2025-04-01-preview".to_string());
assert!(validate_ai_config(&ai_config).is_ok());
}
Expand Down
3 changes: 1 addition & 2 deletions src/core/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,8 @@ mod tests {
let mut config = crate::config::Config::default();
config.ai.provider = "azure-openai".to_string();
config.ai.api_key = Some("azure-key-123".to_string());
config.ai.deployment_id = Some("dep123".to_string());
config.ai.model = "dep123".to_string();
config.ai.api_version = Some("2025-04-01-preview".to_string());
config.ai.model = "gpt-test".to_string();
config.ai.base_url = "https://example.openai.azure.com".to_string();
let result = create_ai_provider(&config.ai);
assert!(result.is_ok());
Expand Down
Loading