Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nico/extend dates #881

Merged
merged 4 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.9.10"
version = "0.9.11"
edition = "2021"
authors = ["Nico Arqueros <[email protected]>"]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde_json::json;
use shinkai_fs::shinkai_file_manager::ShinkaiFileManager;
use shinkai_sqlite::SqliteManager;
use std::{collections::HashMap, fs};
use std::collections::{HashMap, HashSet};

use crate::llm_provider::execution::prompts::general_prompts::JobPromptGenerator;
use crate::managers::tool_router::ToolCallFunctionResponse;
Expand Down Expand Up @@ -92,8 +92,10 @@ impl JobPromptGenerator {
if let Ok(job_scope) = job_scope {
all_files.extend(job_scope);
}
// Add fs files and Agent files
all_files.extend(additional_files);
// Add fs files and Agent files, ensuring no duplicates
let mut unique_files: HashSet<String> = all_files.into_iter().collect();
unique_files.extend(additional_files.into_iter());
all_files = unique_files.into_iter().collect();

if !all_files.is_empty() {
prompt.add_content(
Expand Down Expand Up @@ -139,7 +141,8 @@ impl JobPromptGenerator {
prompt.add_omni(content, image_files, SubPromptType::UserLastMessage, 100);
}

// If function_call exists, it means that the LLM requested a function call and we need to send the response back
// If function_call exists, it means that the LLM requested a function call and we need to send the response
// back
if let Some(function_call) = function_call {
// Convert FunctionCall to Value
let function_call_value = json!({
Expand Down
10 changes: 5 additions & 5 deletions shinkai-bin/shinkai-node/src/managers/galxe_quests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ pub async fn compute_return_for_days_quest(db: Arc<SqliteManager>, required_days
let start_date = chrono::DateTime::parse_from_rfc3339("2025-02-08T00:00:00Z")
.map_err(|e| format!("Failed to parse start date: {}", e))?
.with_timezone(&chrono::Utc);
let end_date = chrono::DateTime::parse_from_rfc3339("2025-02-20T23:59:59Z")
let end_date = chrono::DateTime::parse_from_rfc3339("2025-03-06T23:59:59Z")
.map_err(|e| format!("Failed to parse end date: {}", e))?
.with_timezone(&chrono::Utc);

Expand Down Expand Up @@ -545,10 +545,10 @@ pub async fn compute_use_rag_quest(db: Arc<SqliteManager>) -> Result<bool, Strin
// Define the valid date range (Feb 9th to Feb 20th)
let start_date = chrono::DateTime::parse_from_rfc3339("2025-02-08T00:00:00Z")
.map_err(|e| format!("Failed to parse start date: {}", e))?
.with_timezone(&chrono::Utc);
let end_date = chrono::DateTime::parse_from_rfc3339("2025-02-20T23:59:59Z")
.with_timezone(&chrono::Local);
let end_date = chrono::DateTime::parse_from_rfc3339("2025-03-06T23:59:59Z")
.map_err(|e| format!("Failed to parse end date: {}", e))?
.with_timezone(&chrono::Utc);
.with_timezone(&chrono::Local);

// Collect unique dates when jobs with file resources were created
let mut unique_dates = std::collections::HashSet::new();
Expand All @@ -557,7 +557,7 @@ pub async fn compute_use_rag_quest(db: Arc<SqliteManager>) -> Result<bool, Strin
// Parse the job's creation date
let job_date = chrono::DateTime::parse_from_rfc3339(&job.datetime_created())
.map_err(|e| format!("Failed to parse job date: {}", e))?
.with_timezone(&chrono::Utc);
.with_timezone(&chrono::Local); // Convert to local timezone

// Check if the job was created within the valid date range
if job_date >= start_date && job_date <= end_date {
Expand Down
5 changes: 4 additions & 1 deletion shinkai-bin/shinkai-node/src/managers/tool_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,10 @@ impl ToolRouter {
println!("call_function additional_files: {:?}", additional_files);
println!("call_function job_scope files: {:?}", all_files);

all_files.extend(additional_files);
// Use a HashSet to ensure unique paths
let mut unique_files: std::collections::HashSet<_> = all_files.into_iter().collect();
unique_files.extend(additional_files.into_iter());
let all_files: Vec<_> = unique_files.into_iter().collect();

match shinkai_tool {
ShinkaiTool::Python(python_tool, _is_enabled) => {
Expand Down
3 changes: 3 additions & 0 deletions shinkai-bin/shinkai-node/src/tools/tool_prompts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ pub async fn generate_code_prompt(
* To implement the task you can update the CONFIG, INPUTS and OUTPUT types to match the run function type:
```{language}
# /// script
# requires-python = ">=3.10,<3.12"
# dependencies = [
# "requests",
# ]
Expand Down Expand Up @@ -214,6 +215,7 @@ class OUTPUT:
* This is an example of the commented script block that MUST be present before any python code or imports.

# /// script
# requires-python = ">=3.10,<3.12"
# dependencies = [
# "requests",
# "ruff >=0.3.0",
Expand Down Expand Up @@ -764,6 +766,7 @@ pub async fn tool_metadata_implementation_prompt(
* If the code uses shinkaiSqliteQueryExecutor then fill the sqlTables and sqlQueries sections, otherwise these sections are empty.
* sqlTables contains the complete table structures, they should be same as in the code.
* sqlQueries contains from 1 to 3 examples that show how the data should be retrieved for usage.
* If properties from CONFIG have default values, then those properties shouldn't be in the required array.
{oauth_explain}
</agent_metadata_rules>

Expand Down