From f0d7ac50177af9f85eb26260f54103f0d6260ce5 Mon Sep 17 00:00:00 2001 From: David Weis Date: Mon, 12 Feb 2024 19:14:21 +0000 Subject: [PATCH] Bump openai async lib and model version --- Cargo.lock | 6 +++--- Cargo.toml | 4 ++-- src/openai/conversation_handler.rs | 9 ++++----- src/openai/mod.rs | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a896b63..1bb6c1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -367,9 +367,9 @@ dependencies = [ [[package]] name = "async-openai" -version = "0.17.1" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c6ce3eb96d0957f9d5af15b5b0d651e27da8b567d126ef7fefb889d21dda06" +checksum = "dea5c9223f84965c603fd58c4c9ddcd1907efb2e54acf6fb47039358cd374df4" dependencies = [ "async-convert", "backoff", @@ -2033,7 +2033,7 @@ dependencies = [ [[package]] name = "hopper_rust" -version = "0.4.15" +version = "0.4.16" dependencies = [ "anyhow", "approx 0.5.1", diff --git a/Cargo.toml b/Cargo.toml index 20f5040..d2beca1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ name = "hopper_rust" publish = false readme = "README.md" repository = "https://github.com/dmweis/hopper_rust" -version = "0.4.15" +version = "0.4.16" [package.metadata.deb] assets = [ @@ -98,7 +98,7 @@ dynamixel-driver = {branch = "main", git = "https://github.com/dmweis/dynamixel- rplidar_driver = {git = "https://github.com/dmweis/rplidar_driver", branch = "main"} # openai -async-openai = {version = "0.17.1"} +async-openai = {version = "0.18.3"} # async-openai = {git = "https://github.com/dmweis/async-openai", branch = "main"} serialport = {version = "4.0.1", default-features = false} diff --git a/src/openai/conversation_handler.rs b/src/openai/conversation_handler.rs index ffc6017..cc42a91 100644 --- a/src/openai/conversation_handler.rs +++ b/src/openai/conversation_handler.rs @@ -2,12 +2,11 @@ use anyhow::Context; use async_openai::{ config::OpenAIConfig, types::{ - ChatCompletionFunctions, ChatCompletionFunctionsArgs, ChatCompletionRequestAssistantMessageArgs, ChatCompletionRequestMessage, ChatCompletionRequestSystemMessageArgs, ChatCompletionRequestToolMessageArgs, ChatCompletionRequestUserMessageArgs, ChatCompletionTool, ChatCompletionToolArgs, ChatCompletionToolChoiceOption, ChatCompletionToolType, CreateChatCompletionRequest, - CreateChatCompletionRequestArgs, + CreateChatCompletionRequestArgs, FunctionObject, FunctionObjectArgs, }, Client, }; @@ -20,7 +19,7 @@ use tracing::info; #[derive(Serialize, Deserialize, Debug)] pub struct OpenAiHistory { history: Vec, - functions: Vec, + functions: Vec, tools: Vec, timestamp: chrono::DateTime, } @@ -83,7 +82,7 @@ impl ChatGptConversation { } pub fn add_function(&mut self, func: Arc) -> anyhow::Result<()> { - let new_function = ChatCompletionFunctionsArgs::default() + let new_function = FunctionObjectArgs::default() .name(func.name()) .description(func.description()) .parameters(func.parameters_schema()) @@ -152,7 +151,7 @@ impl ChatGptConversation { .create(request) .await? .choices - .get(0) + .first() .context("Failed to get first choice on OpenAI api response")? .message .clone(); diff --git a/src/openai/mod.rs b/src/openai/mod.rs index 199114f..55ef321 100644 --- a/src/openai/mod.rs +++ b/src/openai/mod.rs @@ -24,7 +24,7 @@ use self::{conversation_handler::ChatGptConversation, events::*, functions::*}; // expensive but no rate limit // const MODEL_NAME: &str = "gpt-4-0613"; // best and cheapest but there is a rate limit -const MODEL_NAME: &str = "gpt-4-1106-preview"; +const MODEL_NAME: &str = "gpt-4-0125-preview"; const SYSTEM_PROMPT: &str = "You are a hexapod pet robot. Your name is Hopper. \ You can perform physical actions such as dance, sit, stand up by calling functions. \