mirror of
https://github.com/mii443/openai-api-rs.git
synced 2025-08-22 23:25:39 +00:00
Remove Option
This commit is contained in:
@ -9,7 +9,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
model: chat_completion::GPT4.to_string(),
|
||||
messages: vec![chat_completion::ChatCompletionMessage {
|
||||
role: chat_completion::MessageRole::user,
|
||||
content: Some(String::from("What is Bitcoin?")),
|
||||
content: String::from("What is Bitcoin?"),
|
||||
name: None,
|
||||
function_call: None,
|
||||
}],
|
||||
|
@ -7,7 +7,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().to_string());
|
||||
let req = CompletionRequest {
|
||||
model: completion::GPT3_TEXT_DAVINCI_003.to_string(),
|
||||
prompt: Some(String::from("What is Bitcoin?")),
|
||||
prompt: String::from("What is Bitcoin?"),
|
||||
suffix: None,
|
||||
max_tokens: Some(3000),
|
||||
temperature: Some(0.9),
|
||||
|
@ -34,18 +34,18 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
model: chat_completion::GPT3_5_TURBO_0613.to_string(),
|
||||
messages: vec![chat_completion::ChatCompletionMessage {
|
||||
role: chat_completion::MessageRole::user,
|
||||
content: Some(String::from("What is the price of Ethereum?")),
|
||||
content: String::from("What is the price of Ethereum?"),
|
||||
name: None,
|
||||
function_call: None,
|
||||
}],
|
||||
functions: Some(vec![chat_completion::Function {
|
||||
name: String::from("get_coin_price"),
|
||||
description: Some(String::from("Get the price of a cryptocurrency")),
|
||||
parameters: Some(chat_completion::FunctionParameters {
|
||||
parameters: chat_completion::FunctionParameters {
|
||||
schema_type: chat_completion::JSONSchemaType::Object,
|
||||
properties: Some(properties),
|
||||
required: Some(vec![String::from("coin")]),
|
||||
}),
|
||||
},
|
||||
}]),
|
||||
function_call: Some("auto".to_string()),
|
||||
temperature: None,
|
||||
|
@ -34,18 +34,18 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
model: chat_completion::GPT3_5_TURBO_0613.to_string(),
|
||||
messages: vec![chat_completion::ChatCompletionMessage {
|
||||
role: chat_completion::MessageRole::user,
|
||||
content: Some(String::from("What is the price of Ethereum?")),
|
||||
content: String::from("What is the price of Ethereum?"),
|
||||
name: None,
|
||||
function_call: None,
|
||||
}],
|
||||
functions: Some(vec![chat_completion::Function {
|
||||
name: String::from("get_coin_price"),
|
||||
description: Some(String::from("Get the price of a cryptocurrency")),
|
||||
parameters: Some(chat_completion::FunctionParameters {
|
||||
parameters: chat_completion::FunctionParameters {
|
||||
schema_type: chat_completion::JSONSchemaType::Object,
|
||||
properties: Some(properties),
|
||||
required: Some(vec![String::from("coin")]),
|
||||
}),
|
||||
},
|
||||
}]),
|
||||
function_call: None,
|
||||
temperature: None,
|
||||
@ -86,13 +86,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
messages: vec![
|
||||
chat_completion::ChatCompletionMessage {
|
||||
role: chat_completion::MessageRole::user,
|
||||
content: Some(String::from("What is the price of Ethereum?")),
|
||||
content: String::from("What is the price of Ethereum?"),
|
||||
name: None,
|
||||
function_call: None,
|
||||
},
|
||||
chat_completion::ChatCompletionMessage {
|
||||
role: chat_completion::MessageRole::function,
|
||||
content: Some({
|
||||
content: ({
|
||||
let price = get_coin_price(&coin).await;
|
||||
format!("{{\"price\": {}}}", price)
|
||||
}),
|
||||
|
Reference in New Issue
Block a user