Skip to content

Commit

Permalink
Merge pull request #56 from cosmonaut-nz/prompt_tune
Browse files Browse the repository at this point in the history
Version bump for openai-api-rs
  • Loading branch information
avastmick committed Jan 30, 2024
2 parents d35b07e + e2877b0 commit 1213bd9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cosmonaut_code"
version = "0.2.1"
version = "0.2.2"
edition = "2021"
license = "CC BY-NC-ND 4.0"
readme = "README.md"
Expand All @@ -18,8 +18,8 @@ name = "cosmonaut_code"
path = "src/main.rs"

[dependencies]
openai-api-rs = "2.1.7"
google-generative-ai-rs = "0.1.4"
openai-api-rs = "4.0.5"
google-generative-ai-rs = "0.1.6"
# google-generative-ai-rs = { git = "https://github.com/avastmick/google-generative-ai-rs.git", version = "0.1.3" }
thiserror = "1.0.55"
log = "0.4.20"
Expand Down Expand Up @@ -50,4 +50,4 @@ futures = "0.3.30"
tempfile = "3.9.0"

[build-dependencies]
linguist-rs-build = { git = "https://github.com/cosmonaut-nz/linguist-rs.git", version = "1.1.1" }
linguist-rs-build = { git = "https://github.com/cosmonaut-nz/linguist-rs.git", version = "1.1.1" }
13 changes: 8 additions & 5 deletions src/provider/openai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use openai_api_rs::v1::{
api::Client,
chat_completion::{
ChatCompletionChoice, ChatCompletionMessage, ChatCompletionMessageForResponse,
ChatCompletionRequest, ChatCompletionResponse, MessageRole,
ChatCompletionRequest, ChatCompletionResponse, Content, MessageRole,
},
};
use serde_json::json;
Expand Down Expand Up @@ -128,9 +128,8 @@ impl ProviderMessageConverter for OpenAIMessageConverter {

ChatCompletionMessage {
role,
content: message.content.clone(),
content: Content::Text(message.content.clone()),
name: None,
function_call: None,
}
}

Expand Down Expand Up @@ -205,7 +204,11 @@ mod tests {
};

let converted_message = converter.convert_message(&message);
assert_eq!(converted_message.content, message.content);
let converted_msg_content = match converted_message.content {
Content::Text(content) => content,
_ => panic!("Expected Content::Text"),
};
assert_eq!(converted_msg_content, message.content);
}
#[test]
fn test_openai_response_converter() {
Expand All @@ -229,7 +232,7 @@ mod tests {
name: None,
content: Some("Test content".to_string()),
role: MessageRole::user,
function_call: None,
tool_calls: None,
},
}],
system_fingerprint: None,
Expand Down

0 comments on commit 1213bd9

Please sign in to comment.