-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
oauth for tool execution in chat/api
- Loading branch information
Showing
6 changed files
with
115 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
shinkai-bin/shinkai-node/src/tools/tool_execution/execution_header_generator.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use std::{collections::HashMap, sync::Arc}; | ||
|
||
use shinkai_sqlite::SqliteManager; | ||
use shinkai_tools_primitives::tools::{error::ToolError, tool_config::OAuth}; | ||
|
||
use super::execution_coordinator::handle_oauth; | ||
|
||
pub async fn generate_execution_environment( | ||
db: Arc<SqliteManager>, | ||
llm_provider: String, | ||
app_id: String, | ||
tool_id: String, | ||
tool_router_key: String, | ||
instance_id: String, | ||
oauth: &Option<Vec<OAuth>>, | ||
) -> Result<HashMap<String, String>, ToolError> { | ||
let mut envs = HashMap::new(); | ||
|
||
let bearer = db.read_api_v2_key().unwrap_or_default().unwrap_or_default(); | ||
envs.insert("BEARER".to_string(), bearer); | ||
envs.insert("X_SHINKAI_TOOL_ID".to_string(), tool_id.clone()); | ||
envs.insert("X_SHINKAI_APP_ID".to_string(), app_id.clone()); | ||
envs.insert("X_SHINKAI_INSTANCE_ID".to_string(), instance_id.clone()); | ||
envs.insert("X_SHINKAI_LLM_PROVIDER".to_string(), llm_provider); | ||
|
||
let oauth = handle_oauth(oauth, &db, app_id.clone(), tool_id.clone(), tool_router_key.clone()).await?; | ||
|
||
envs.insert("SHINKAI_OAUTH".to_string(), oauth.to_string()); | ||
|
||
Ok(envs) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod execution_coordinator; | ||
pub mod execution_custom; | ||
pub mod execution_deno_dynamic; | ||
pub mod execution_header_generator; | ||
pub mod execution_python_dynamic; |