Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
nicarq committed Feb 3, 2025
1 parent cba218a commit 0188367
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ impl InferenceChainContext {
my_agent_payments_manager: Option<Arc<Mutex<MyAgentOfferingsManager>>>,
ext_agent_payments_manager: Option<Arc<Mutex<ExtAgentOfferingsManager>>>,
job_callback_manager: Option<Arc<Mutex<JobCallbackManager>>>,
// sqlite_logger: Option<Arc<SqliteLogger>>,
llm_stopper: Arc<LLMStopper>,
) -> Self {
Self {
Expand Down
22 changes: 15 additions & 7 deletions shinkai-bin/shinkai-node/src/network/v2_api/api_v2_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,16 +433,23 @@ impl Node {
.await
{
Ok(_) => {
// If everything went well, send the success message
let _ = res.send(Ok("Agent added successfully".to_string())).await;
Ok(())
}
Err(err) => {
// If there was an error, send the error message
let api_error = APIError {
code: StatusCode::INTERNAL_SERVER_ERROR.as_u16(),
error: "Internal Server Error".to_string(),
message: format!("{}", err),
// Check if the error message indicates a unique constraint violation
let api_error = if err.to_string().contains("UNIQUE constraint failed") {
APIError {
code: StatusCode::CONFLICT.as_u16(),
error: "Conflict".to_string(),
message: "An LLM provider with this ID already exists".to_string(),
}
} else {
APIError {
code: StatusCode::INTERNAL_SERVER_ERROR.as_u16(),
error: "Internal Server Error".to_string(),
message: format!("{}", err),
}
};
let _ = res.send(Err(api_error)).await;
Ok(())
Expand Down Expand Up @@ -1595,7 +1602,8 @@ impl Node {
return Ok(());
}

let zip_contents = match download_zip_file(url, "__agent.json".to_string(), node_name, signing_secret_key).await {
let zip_contents = match download_zip_file(url, "__agent.json".to_string(), node_name, signing_secret_key).await
{
Ok(contents) => contents,
Err(err) => {
let api_error = APIError {
Expand Down

0 comments on commit 0188367

Please sign in to comment.