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:
parent
bfdb934443
commit
026f5cf32d
@ -270,6 +270,9 @@ impl ChatService {
|
|||||||
Some(request.sender.uid),
|
Some(request.sender.uid),
|
||||||
)
|
)
|
||||||
.with_project(request.project.id);
|
.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 {
|
if let Some(ref registry) = self.tool_registry {
|
||||||
ctx.registry_mut().merge(registry.clone());
|
ctx.registry_mut().merge(registry.clone());
|
||||||
}
|
}
|
||||||
@ -596,6 +599,9 @@ impl ChatService {
|
|||||||
Some(request.sender.uid),
|
Some(request.sender.uid),
|
||||||
)
|
)
|
||||||
.with_project(request.project.id);
|
.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 {
|
if let Some(ref registry) = self.tool_registry {
|
||||||
ctx.registry_mut().merge(registry.clone());
|
ctx.registry_mut().merge(registry.clone());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,7 @@ struct Inner {
|
|||||||
pub sender_id: Option<Uuid>,
|
pub sender_id: Option<Uuid>,
|
||||||
pub project_id: Uuid,
|
pub project_id: Uuid,
|
||||||
pub registry: ToolRegistry,
|
pub registry: ToolRegistry,
|
||||||
|
pub embed_service: Option<crate::embed::EmbedService>,
|
||||||
depth: u32,
|
depth: u32,
|
||||||
max_depth: u32,
|
max_depth: u32,
|
||||||
tool_call_count: usize,
|
tool_call_count: usize,
|
||||||
@ -50,6 +51,7 @@ impl ToolContext {
|
|||||||
sender_id,
|
sender_id,
|
||||||
project_id: Uuid::nil(),
|
project_id: Uuid::nil(),
|
||||||
registry: ToolRegistry::new(),
|
registry: ToolRegistry::new(),
|
||||||
|
embed_service: None,
|
||||||
depth: 0,
|
depth: 0,
|
||||||
max_depth: 5,
|
max_depth: 5,
|
||||||
tool_call_count: 0,
|
tool_call_count: 0,
|
||||||
@ -78,6 +80,15 @@ impl ToolContext {
|
|||||||
self
|
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 {
|
pub fn recursion_exceeded(&self) -> bool {
|
||||||
self.inner.depth >= self.inner.max_depth
|
self.inner.depth >= self.inner.max_depth
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user