pub fn generate_openai_tools_config(
config: &ToolConfig,
) -> Result<String, Error>
Examples found in repository?
examples/main.rs (line 34)
3fn main() {
4 let config = ToolConfig {
5 functions: vec![
6 FunctionDefinition {
7 name: "get_current_weather".to_string(),
8 description: "获取当前天气".to_string(),
9 parameters: vec![
10 FunctionParameter {
11 name: "location".to_string(),
12 description: "城市名".to_string(),
13 r#type: "string".to_string(),
14 enum_values: None,
15 required: true,
16 },
17 FunctionParameter {
18 name: "unit".to_string(),
19 description: "温度单位".to_string(),
20 r#type: "string".to_string(),
21 enum_values: Some(vec!["celsius".to_string(), "fahrenheit".to_string()]),
22 required: false,
23 },
24 ],
25 },
26 ],
27 };
28
29 match generate_gemini_tools_config(&config) {
30 Ok(gemini_json) => println!("Gemini 配置: {}", gemini_json),
31 Err(e) => eprintln!("Gemini 配置生成错误: {}", e),
32 }
33
34 match generate_openai_tools_config(&config) {
35 Ok(openai_json) => println!("OpenAI 配置: {}", openai_json),
36 Err(e) => eprintln!("OpenAI 配置生成错误: {}", e),
37 }
38}