Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nicarq committed Oct 18, 2023
1 parent a83bb36 commit dc29223
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion scripts/run_node1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export FIRST_DEVICE_NEEDS_REGISTRATION_CODE="false"

export INITIAL_AGENT_NAME="my_gpt"
export INITIAL_AGENT_URL="https://api.openai.com"
export INITIAL_AGENT_MODEL="openai:chatgpt3-turbo"
export INITIAL_AGENT_MODEL="openai:gpt-3.5-turbo"

# Add these lines to enable all log options
export LOG_ALL=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mod tests {
"false".to_string(),
"http://example.com".to_string(),
"123456".to_string(),
"openai:chatgpt3-turbo".to_string(),
"openai:gpt-3.5-turbo".to_string(),
"permission1,permission2".to_string(),
"bucket1,bucket2".to_string(),
"sender1,sender2".to_string(),
Expand Down
16 changes: 12 additions & 4 deletions src/agent/providers/openai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use serde_json;
use serde_json::json;
use serde_json::Value as JsonValue;
use shinkai_message_primitives::schemas::agents::serialized_agent::OpenAI;
use shinkai_message_primitives::shinkai_utils::shinkai_logging::{shinkai_log, ShinkaiLogOption, ShinkaiLogLevel};
use tiktoken_rs::get_chat_completion_max_tokens;
use tiktoken_rs::num_tokens_from_messages;

Expand Down Expand Up @@ -103,14 +104,21 @@ impl LLMProvider for OpenAI {
.send()
.await?;

eprintln!("Status: {}", res.status());
shinkai_log(
ShinkaiLogOption::JobExecution,
ShinkaiLogLevel::Debug,
format!("Call API Status: {:?}", res.status()).as_str(),
);

let response_text = res.text().await?;
//eprintln!("Response: {:?}", response_text);
shinkai_log(
ShinkaiLogOption::JobExecution,
ShinkaiLogLevel::Debug,
format!("Call API Response Text: {:?}", response_text).as_str(),
);

let data_resp: Result<JsonValue, _> = serde_json::from_str(&response_text);
//eprintln!("data_resp: {:?}", data_resp);

// let data_resp = res.json::<serde_json::Value>().await;
match data_resp {
Ok(value) => {
let data: Response = serde_json::from_value(value).map_err(AgentError::SerdeError)?;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn fetch_agent_env(global_identity: String) -> Option<SerializedAgent> {
let initial_agent_model: String = env::var("INITIAL_AGENT_MODEL")
.unwrap_or_else(|_| "".to_string())
.parse()
.expect("Failed to parse agent model e.g. openai:chatgpt3-turbo");
.expect("Failed to parse agent model e.g. openai:gpt-3.5-turbo");

if initial_agent_name.is_empty()
|| initial_agent_api_key.is_empty()
Expand Down

0 comments on commit dc29223

Please sign in to comment.