use std::sync::Arc;
use tokio::sync::Mutex;
use oris_runtime::{
agent::{
context_engineering::middleware::{InjectionPosition, MessageInjectionMiddleware},
create_agent, AgentState,
},
schemas::messages::Message,
tools::{InMemoryStore, SimpleContext},
};
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let file_context_injector =
MessageInjectionMiddleware::inject_file_context(InjectionPosition::End);
let compliance_injector =
MessageInjectionMiddleware::inject_compliance_rules(InjectionPosition::End);
let mut state = AgentState::new();
state.set_field(
"uploaded_files".to_string(),
json!([
{
"name": "project_proposal.pdf",
"type": "pdf",
"summary": "Q4 project proposal document"
},
{
"name": "budget.xlsx",
"type": "excel",
"summary": "Budget spreadsheet for Q4"
}
]),
);
let agent = create_agent(
"gpt-4o-mini",
&[],
Some("You are a helpful assistant"),
Some(vec![
Arc::new(file_context_injector),
Arc::new(compliance_injector),
]),
)?
.with_context(Arc::new(
SimpleContext::new()
.with_user_id("user_123".to_string())
.with_custom("user_jurisdiction".to_string(), "EU".to_string())
.with_custom("compliance_frameworks".to_string(), "GDPR".to_string())
.with_custom("industry".to_string(), "finance".to_string()),
))
.with_store(Arc::new(InMemoryStore::new()))
.with_state(Arc::new(Mutex::new(state)));
let result = agent
.invoke_messages(vec![Message::new_human_message(
"What files do I have access to?",
)])
.await?;
println!("Agent response: {}", result);
Ok(())
}