Skip to content

Commit

Permalink
Merge pull request #658 from dcSpark/fix/agent_paul_feedback
Browse files Browse the repository at this point in the history
FIX agent info in all_inboxes
  • Loading branch information
nicarq authored Nov 14, 2024
2 parents dc115e9 + f762b93 commit 5393948
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
22 changes: 18 additions & 4 deletions shinkai-libs/shinkai-db/src/db/db_inbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,11 +543,25 @@ impl ShinkaiDB {
let job = self.get_job_with_options(&unique_id, false, false)?;
let agent_id = job.parent_agent_or_llm_provider_id;

// TODO: add caching so we don't call this every time for the same agent_id
match self.get_llm_provider(&agent_id, &p) {
// Check if the agent_id is an LLM provider
let agent_subset = match self.get_llm_provider(&agent_id, &p) {
Ok(agent) => agent.map(LLMProviderSubset::from_serialized_llm_provider),
Err(_) => None,
}
Err(_) => {
// If not found as an LLM provider, check if it exists as an agent
match self.get_agent(&agent_id) {
Ok(Some(agent)) => {
// Fetch the serialized LLM provider
if let Ok(Some(serialized_llm_provider)) = self.get_llm_provider(&agent.llm_provider_id, &p) {
Some(LLMProviderSubset::from_agent(agent, serialized_llm_provider))
} else {
None
}
}
_ => None,
}
}
};
agent_subset
}
_ => None,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ use utoipa::ToSchema;

use crate::shinkai_message::{shinkai_message::ShinkaiMessage, shinkai_message_schemas::V2ChatMessage};

use super::{job_config::JobConfig, llm_providers::serialized_llm_provider::{LLMProviderInterface, SerializedLLMProvider}, shinkai_name::ShinkaiName};
use super::{
job_config::JobConfig,
llm_providers::{
agent::Agent,
serialized_llm_provider::{LLMProviderInterface, SerializedLLMProvider},
},
shinkai_name::ShinkaiName,
};

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, ToSchema)]
pub struct LLMProviderSubset {
Expand All @@ -21,6 +28,14 @@ impl LLMProviderSubset {
model: serialized_llm_provider.model,
}
}

pub fn from_agent(agent: Agent, serialized_llm_provider: SerializedLLMProvider) -> Self {
Self {
id: agent.agent_id,
full_identity_name: agent.full_identity_name,
model: serialized_llm_provider.model,
}
}
}

#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)]
Expand Down

0 comments on commit 5393948

Please sign in to comment.