Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
nicarq committed Oct 18, 2023
1 parent 7249f35 commit 883e84f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 23 deletions.
63 changes: 41 additions & 22 deletions src/agent/execution/job_execution_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,42 +145,61 @@ impl JobManager {
format!("Processing files_map: ... files: {}", job_message.files_inbox.len()).as_str(),
);
// TODO: later we should able to grab errors and return them to the user
let new_scope_entries = JobManager::process_files_inbox(
let new_scope_entries_result = JobManager::process_files_inbox(
db.clone(),
agent_found,
job_message.files_inbox.clone(),
profile,
save_to_db_directly,
)
.await?;
.await;

for (_, value) in new_scope_entries {
match value {
ScopeEntry::Local(local_entry) => {
if !full_job.scope.local.contains(&local_entry) {
full_job.scope.local.push(local_entry);
} else {
println!("Duplicate LocalScopeEntry detected");
}
}
ScopeEntry::Database(db_entry) => {
if !full_job.scope.database.contains(&db_entry) {
full_job.scope.database.push(db_entry);
} else {
println!("Duplicate DBScopeEntry detected");
match new_scope_entries_result {
Ok(new_scope_entries) => {
for (_, value) in new_scope_entries {
match value {
ScopeEntry::Local(local_entry) => {
if !full_job.scope.local.contains(&local_entry) {
full_job.scope.local.push(local_entry);
} else {
println!("Duplicate LocalScopeEntry detected");
}
}
ScopeEntry::Database(db_entry) => {
if !full_job.scope.database.contains(&db_entry) {
full_job.scope.database.push(db_entry);
} else {
println!("Duplicate DBScopeEntry detected");
}
}
}
}
let mut shinkai_db = db.lock().await;
shinkai_db.update_job_scope(full_job.job_id().to_string(), full_job.scope.clone())?;
}
Err(e) => {
shinkai_log(
ShinkaiLogOption::JobExecution,
ShinkaiLogLevel::Error,
format!("Error processing files: {}", e).as_str(),
);
return Err(e);
}
}
{
let mut shinkai_db = db.lock().await;
shinkai_db.update_job_scope(full_job.job_id().to_string(), full_job.scope.clone())?;
}
} else {
// TODO: move this somewhere else
let mut shinkai_db = db.lock().await;
shinkai_db.init_profile_resource_router(&profile)?;
std::mem::drop(shinkai_db); // required to avoid deadlock
match shinkai_db.init_profile_resource_router(&profile) {
Ok(_) => std::mem::drop(shinkai_db), // required to avoid deadlock
Err(e) => {
shinkai_log(
ShinkaiLogOption::JobExecution,
ShinkaiLogLevel::Error,
format!("Error initializing profile resource router: {}", e).as_str(),
);
return Err(AgentError::ShinkaiDB(e));
}
}
}

Ok(())
Expand Down
7 changes: 6 additions & 1 deletion src/agent/providers/openai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ impl LLMProvider for OpenAI {
});

let body = serde_json::to_string(&payload)?;
eprintln!("body api chagpt: {}", body);

shinkai_log(
ShinkaiLogOption::JobExecution,
ShinkaiLogLevel::Debug,
format!("Call API Body: {:?}", body).as_str(),
);

let res = client
.post(url)
Expand Down

0 comments on commit 883e84f

Please sign in to comment.