feat(service): register project_tools in chat service, add AppStorage::read method
This commit is contained in:
parent
b23c6a03c3
commit
33a4a5c6c9
@ -231,6 +231,7 @@ impl AppService {
|
|||||||
let mut registry = ToolRegistry::new();
|
let mut registry = ToolRegistry::new();
|
||||||
git_tools::register_all(&mut registry);
|
git_tools::register_all(&mut registry);
|
||||||
file_tools::register_all(&mut registry);
|
file_tools::register_all(&mut registry);
|
||||||
|
project_tools::register_all(&mut registry);
|
||||||
Some(Arc::new(
|
Some(Arc::new(
|
||||||
ChatService::new(client).with_tool_registry(registry),
|
ChatService::new(client).with_tool_registry(registry),
|
||||||
))
|
))
|
||||||
@ -289,6 +290,7 @@ impl AppService {
|
|||||||
let room = RoomService::new(
|
let room = RoomService::new(
|
||||||
db.clone(),
|
db.clone(),
|
||||||
cache.clone(),
|
cache.clone(),
|
||||||
|
config.clone(),
|
||||||
message_producer.clone(),
|
message_producer.clone(),
|
||||||
room_manager,
|
room_manager,
|
||||||
redis_url,
|
redis_url,
|
||||||
@ -362,6 +364,7 @@ pub mod git;
|
|||||||
pub mod git_tools;
|
pub mod git_tools;
|
||||||
pub mod issue;
|
pub mod issue;
|
||||||
pub mod project;
|
pub mod project;
|
||||||
|
pub mod project_tools;
|
||||||
pub mod pull_request;
|
pub mod pull_request;
|
||||||
pub mod search;
|
pub mod search;
|
||||||
pub mod skill;
|
pub mod skill;
|
||||||
|
|||||||
@ -57,4 +57,14 @@ impl AppStorage {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Read a file by key and return (bytes, content_type).
|
||||||
|
pub async fn read(&self, key: &str) -> anyhow::Result<(Vec<u8>, String)> {
|
||||||
|
let path = self.base_path.join(key);
|
||||||
|
let data = tokio::fs::read(&path).await?;
|
||||||
|
let content_type = mime_guess2::from_path(&path)
|
||||||
|
.first_or_octet_stream()
|
||||||
|
.to_string();
|
||||||
|
Ok((data, content_type))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user