mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-27 09:26:22 +02:00
Feature/structured query tool integration (#493)
* Agent integration to structured query * Update tests
This commit is contained in:
parent
a6d9f5e849
commit
ed0e02791d
5 changed files with 553 additions and 2 deletions
|
|
@ -31,4 +31,5 @@ from . graph_rag_client import GraphRagClientSpec
|
|||
from . tool_service import ToolService
|
||||
from . tool_client import ToolClientSpec
|
||||
from . agent_client import AgentClientSpec
|
||||
from . structured_query_client import StructuredQueryClientSpec
|
||||
|
||||
|
|
|
|||
33
trustgraph-base/trustgraph/base/structured_query_client.py
Normal file
33
trustgraph-base/trustgraph/base/structured_query_client.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
from . request_response_spec import RequestResponse, RequestResponseSpec
|
||||
from .. schema import StructuredQueryRequest, StructuredQueryResponse
|
||||
|
||||
class StructuredQueryClient(RequestResponse):
|
||||
async def structured_query(self, question, timeout=600):
|
||||
resp = await self.request(
|
||||
StructuredQueryRequest(
|
||||
question = question
|
||||
),
|
||||
timeout=timeout
|
||||
)
|
||||
|
||||
if resp.error:
|
||||
raise RuntimeError(resp.error.message)
|
||||
|
||||
# Return the full response structure for the tool to handle
|
||||
return {
|
||||
"data": resp.data,
|
||||
"errors": resp.errors if resp.errors else [],
|
||||
"error": resp.error
|
||||
}
|
||||
|
||||
class StructuredQueryClientSpec(RequestResponseSpec):
|
||||
def __init__(
|
||||
self, request_name, response_name,
|
||||
):
|
||||
super(StructuredQueryClientSpec, self).__init__(
|
||||
request_name = request_name,
|
||||
request_schema = StructuredQueryRequest,
|
||||
response_name = response_name,
|
||||
response_schema = StructuredQueryResponse,
|
||||
impl = StructuredQueryClient,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue