feat(context): thread embed_service through ToolContext for FC tool access

Add with_embed_service() builder and embed_service() accessor to ToolContext,
wired through ChatService so function-calling tools can access Qdrant vector search.
This commit is contained in:
ZhenYi 2026-04-28 13:03:55 +08:00
parent bfdb934443
commit 026f5cf32d
2 changed files with 17 additions and 0 deletions

View File

@ -270,6 +270,9 @@ impl ChatService {
Some(request.sender.uid),
)
.with_project(request.project.id);
if let Some(ref es) = self.embed_service {
ctx = ctx.with_embed_service(es.clone());
}
if let Some(ref registry) = self.tool_registry {
ctx.registry_mut().merge(registry.clone());
}
@ -596,6 +599,9 @@ impl ChatService {
Some(request.sender.uid),
)
.with_project(request.project.id);
if let Some(ref es) = self.embed_service {
ctx = ctx.with_embed_service(es.clone());
}
if let Some(ref registry) = self.tool_registry {
ctx.registry_mut().merge(registry.clone());
}

View File

@ -27,6 +27,7 @@ struct Inner {
pub sender_id: Option<Uuid>,
pub project_id: Uuid,
pub registry: ToolRegistry,
pub embed_service: Option<crate::embed::EmbedService>,
depth: u32,
max_depth: u32,
tool_call_count: usize,
@ -50,6 +51,7 @@ impl ToolContext {
sender_id,
project_id: Uuid::nil(),
registry: ToolRegistry::new(),
embed_service: None,
depth: 0,
max_depth: 5,
tool_call_count: 0,
@ -78,6 +80,15 @@ impl ToolContext {
self
}
pub fn with_embed_service(mut self, embed_service: crate::embed::EmbedService) -> Self {
Arc::make_mut(&mut self.inner).embed_service = Some(embed_service);
self
}
pub fn embed_service(&self) -> Option<&crate::embed::EmbedService> {
self.inner.embed_service.as_ref()
}
pub fn recursion_exceeded(&self) -> bool {
self.inner.depth >= self.inner.max_depth
}