Skip to content

Commit

Permalink
Merge pull request #757 from dcSpark/nico/new_version
Browse files Browse the repository at this point in the history
Nico/new version
  • Loading branch information
nicarq authored Dec 29, 2024
2 parents 3cea4ec + 08dce73 commit 4b7a271
Show file tree
Hide file tree
Showing 24 changed files with 565 additions and 281 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,17 @@ impl GenericInferenceChain {
if can_use_tools && tools_allowed || is_agent {
// CASE 2.1: If using an Agent, get its specifically configured tools
if let ProviderOrAgent::Agent(agent) = &llm_provider {
for tool_name in &agent.tools {
for tool in &agent.tools {
if let Some(tool_router) = &tool_router {
match tool_router.get_tool_by_name(tool_name).await {
match tool_router
.get_tool_by_name_and_version(&tool.to_string_without_version(), tool.version())
.await
{
Ok(Some(tool)) => tools.push(tool),
Ok(None) => {
return Err(LLMProviderError::ToolNotFound(format!(
"Tool not found for name: {}",
tool_name
tool.to_string_with_version()
)));
}
Err(e) => {
Expand Down Expand Up @@ -401,7 +404,8 @@ impl GenericInferenceChain {
// Find the ShinkaiTool that has a tool with the function name
let shinkai_tool = tools.iter().find(|tool| {
tool.name() == function_call.name
|| tool.tool_router_key().to_string_without_version() == function_call.tool_router_key.clone().unwrap_or_default()
|| tool.tool_router_key().to_string_without_version()
== function_call.tool_router_key.clone().unwrap_or_default()
});
if shinkai_tool.is_none() {
eprintln!("Function not found: {}", function_call.name);
Expand All @@ -427,7 +431,8 @@ impl GenericInferenceChain {
};

let mut function_call_with_router_key = function_call.clone();
function_call_with_router_key.tool_router_key = Some(shinkai_tool.tool_router_key().to_string_without_version());
function_call_with_router_key.tool_router_key =
Some(shinkai_tool.tool_router_key().to_string_without_version());
function_call_with_router_key.response = Some(function_response.response.clone());
tool_calls_history.push(function_call_with_router_key);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use shinkai_job_queue_manager::job_queue_manager::{JobForProcessing, JobQueueMan
use shinkai_message_primitives::schemas::job::{Job, JobLike};
use shinkai_message_primitives::schemas::llm_providers::common_agent_llm_provider::ProviderOrAgent;
use shinkai_message_primitives::schemas::sheet::WorkflowSheetJobData;
use shinkai_message_primitives::schemas::tool_router_key::ToolRouterKey;
use shinkai_message_primitives::schemas::ws_types::WSUpdateHandler;
use shinkai_message_primitives::shinkai_message::shinkai_message_schemas::{CallbackAction, MessageMetadata};
use shinkai_message_primitives::shinkai_utils::job_scope::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use shinkai_message_primitives::schemas::shinkai_tools::DynamicToolType;
use shinkai_message_primitives::schemas::tool_router_key::ToolRouterKey;
use shinkai_message_primitives::shinkai_utils::shinkai_message_builder::ShinkaiMessageBuilder;
use std::sync::Arc;
use tokio::sync::Mutex;
Expand Down Expand Up @@ -88,7 +89,7 @@ impl JobCallbackManager {
db: Arc<SqliteManager>,
tool_type: DynamicToolType,
inference_response_content: String,
available_tools: Vec<String>,
available_tools: Vec<ToolRouterKey>,
identity_secret_key: &SigningKey,
user_profile: &ShinkaiName,
job_id: &str,
Expand Down
Loading

0 comments on commit 4b7a271

Please sign in to comment.