Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nicarq committed Oct 22, 2024
1 parent 4291e64 commit 16ae49e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
9 changes: 9 additions & 0 deletions shinkai-bin/shinkai-node/src/llm_provider/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ pub enum LLMProviderError {
ToolRouterNotFound,
UnexpectedResponseFormat(String),
InvalidVRPath(String),
ToolNotFound(String),
ToolRetrievalError(String),
ToolSearchError(String),
}

impl fmt::Display for LLMProviderError {
Expand Down Expand Up @@ -170,6 +173,9 @@ impl fmt::Display for LLMProviderError {
LLMProviderError::ToolRouterNotFound => write!(f, "Tool Router not found"),
LLMProviderError::UnexpectedResponseFormat(s) => write!(f, "Unexpected response format: {}", s),
LLMProviderError::InvalidVRPath(s) => write!(f, "Invalid VRPath: {}", s),
LLMProviderError::ToolNotFound(s) => write!(f, "Tool not found: {}", s),
LLMProviderError::ToolRetrievalError(s) => write!(f, "Tool retrieval error: {}", s),
LLMProviderError::ToolSearchError(s) => write!(f, "Tool search error: {}", s),
}
}
}
Expand Down Expand Up @@ -246,6 +252,9 @@ impl LLMProviderError {
LLMProviderError::ToolRouterNotFound => "ToolRouterNotFound",
LLMProviderError::UnexpectedResponseFormat(_) => "UnexpectedResponseFormat",
LLMProviderError::InvalidVRPath(_) => "InvalidVRPath",
LLMProviderError::ToolNotFound(_) => "ToolNotFound",
LLMProviderError::ToolRetrievalError(_) => "ToolRetrievalError",
LLMProviderError::ToolSearchError(_) => "ToolSearchError",
};

let error_message = format!("{}", self);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ impl GenericInferenceChain {

// 2) Vector search for tooling / workflows if the workflow / tooling scope isn't empty
let job_config = full_job.config();
shinkai_log(
ShinkaiLogOption::JobExecution,
ShinkaiLogLevel::Info,
&format!("job_config: {:?}", job_config),
);
let mut tools = vec![];
let use_tools = match &llm_provider.model {
LLMProviderInterface::OpenAI(_) => true,
Expand Down Expand Up @@ -223,11 +228,30 @@ impl GenericInferenceChain {
// Search in JS Tools
let results = tool_router
.vector_search_enabled_tools_with_network(&user_message.clone(), 5)
.await
.unwrap();
for result in results {
if let Some(tool) = tool_router.get_tool_by_name(&result.tool_router_key).await.unwrap() {
tools.push(tool);
.await;

match results {
Ok(results) => {
for result in results {
match tool_router.get_tool_by_name(&result.tool_router_key).await {
Ok(Some(tool)) => tools.push(tool),
Ok(None) => {
return Err(LLMProviderError::ToolNotFound(
format!("Tool not found for key: {}", result.tool_router_key),
));
}
Err(e) => {
return Err(LLMProviderError::ToolRetrievalError(
format!("Error retrieving tool: {:?}", e),
));
}
}
}
}
Err(e) => {
return Err(LLMProviderError::ToolSearchError(
format!("Error during tool search: {:?}", e),
));
}
}
}
Expand Down Expand Up @@ -429,4 +453,4 @@ impl GenericInferenceChain {
}
}
}
}
}

0 comments on commit 16ae49e

Please sign in to comment.