Skip to content

Commit

Permalink
Bump openai async lib and model version
Browse files Browse the repository at this point in the history
  • Loading branch information
dmweis committed Feb 12, 2024
1 parent d6943d1 commit f0d7ac5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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}
Expand Down
9 changes: 4 additions & 5 deletions src/openai/conversation_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -20,7 +19,7 @@ use tracing::info;
#[derive(Serialize, Deserialize, Debug)]
pub struct OpenAiHistory {
history: Vec<ChatCompletionRequestMessage>,
functions: Vec<ChatCompletionFunctions>,
functions: Vec<FunctionObject>,
tools: Vec<ChatCompletionTool>,
timestamp: chrono::DateTime<chrono::Utc>,
}
Expand Down Expand Up @@ -83,7 +82,7 @@ impl ChatGptConversation {
}

pub fn add_function(&mut self, func: Arc<dyn ChatGptFunction>) -> anyhow::Result<()> {
let new_function = ChatCompletionFunctionsArgs::default()
let new_function = FunctionObjectArgs::default()
.name(func.name())
.description(func.description())
.parameters(func.parameters_schema())
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/openai/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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. \
Expand Down

0 comments on commit f0d7ac5

Please sign in to comment.