@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
44use std:: collections:: HashMap ;
55use std:: { env, vec} ;
66
7- async fn get_coin_price ( coin : & str ) -> f64 {
7+ fn get_coin_price ( coin : & str ) -> f64 {
88 let coin = coin. to_lowercase ( ) ;
99 match coin. as_str ( ) {
1010 "btc" | "bitcoin" => 10000.0 ,
@@ -13,8 +13,7 @@ async fn get_coin_price(coin: &str) -> f64 {
1313 }
1414}
1515
16- #[ tokio:: main]
17- async fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
16+ fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
1817 let client = Client :: new ( env:: var ( "OPENAI_API_KEY" ) . unwrap ( ) . to_string ( ) ) ;
1918
2019 let mut properties = HashMap :: new ( ) ;
@@ -60,7 +59,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
6059 user : None ,
6160 } ;
6261
63- let result = client. chat_completion ( req) . await ?;
62+ let result = client. chat_completion ( req) ?;
6463
6564 match result. choices [ 0 ] . finish_reason {
6665 chat_completion:: FinishReason :: stop => {
@@ -93,7 +92,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
9392 chat_completion:: ChatCompletionMessage {
9493 role: chat_completion:: MessageRole :: function,
9594 content: {
96- let price = get_coin_price( & coin) . await ;
95+ let price = get_coin_price( & coin) ;
9796 format!( "{{\" price\" : {}}}" , price)
9897 } ,
9998 name: Some ( String :: from( "get_coin_price" ) ) ,
@@ -113,7 +112,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
113112 logit_bias : None ,
114113 user : None ,
115114 } ;
116- let result = client. chat_completion ( req) . await ?;
115+ let result = client. chat_completion ( req) ?;
117116 println ! ( "{:?}" , result. choices[ 0 ] . message. content) ;
118117 }
119118 chat_completion:: FinishReason :: content_filter => {
0 commit comments