|
9 | 9 | * File Created: 2025-03-01 21:55:58 |
10 | 10 | * |
11 | 11 | * Modified By: mingcheng ([email protected]) |
12 | | - * Last Modified: 2025-09-26 14:43:10 |
| 12 | + * Last Modified: 2025-09-26 15:51:48 |
13 | 13 | */ |
14 | 14 |
|
15 | | -use crate::cli; |
| 15 | +use crate::cli::{CMD, CMD_ABOUT, CMD_ABOUT_URL}; |
16 | 16 | use askama::Template; |
17 | 17 | use async_openai::config::OPENAI_API_BASE; |
18 | 18 | use async_openai::error::OpenAIError; |
@@ -55,15 +55,19 @@ impl OpenAI { |
55 | 55 | .with_api_base( |
56 | 56 | env::var("OPENAI_API_BASE").unwrap_or_else(|_| String::from(OPENAI_API_BASE)), |
57 | 57 | ) |
58 | | - .with_org_id(cli::CMD); |
| 58 | + .with_org_id(CMD); |
59 | 59 |
|
60 | 60 | // Set up HTTP client builder with default headers |
61 | | - let mut http_client_builder = ClientBuilder::new().user_agent(cli::CMD).default_headers({ |
62 | | - let mut headers = HeaderMap::new(); |
63 | | - headers.insert("HTTP-Referer", HeaderValue::from_static(cli::CMD_ABOUT_URL)); |
64 | | - headers.insert("X-Title", HeaderValue::from_static(cli::CMD)); |
65 | | - headers |
66 | | - }); |
| 61 | + let mut http_client_builder = ClientBuilder::new() |
| 62 | + .user_agent(format!("{}({})", CMD, CMD_ABOUT)) |
| 63 | + .default_headers({ |
| 64 | + let mut headers = HeaderMap::new(); |
| 65 | + headers.insert("HTTP-Referer", HeaderValue::from_static(CMD_ABOUT_URL)); |
| 66 | + headers.insert("X-Title", HeaderValue::from_static(CMD)); |
| 67 | + headers.insert("X-Client", HeaderValue::from_static(CMD)); |
| 68 | + headers.insert("X-Client-Type", HeaderValue::from_static("CLI")); |
| 69 | + headers |
| 70 | + }); |
67 | 71 |
|
68 | 72 | // Set up proxy if specified |
69 | 73 | let proxy_addr: String = env::var("OPENAI_API_PROXY").unwrap_or_else(|_| String::from("")); |
|
0 commit comments