mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 16:36:21 +02:00
Extend use of user + collection fields (#503)
* Collection+user fields in structured query * User/collection in structured query & agent
This commit is contained in:
parent
a92050c411
commit
f22bf13aa6
15 changed files with 122 additions and 45 deletions
|
|
@ -61,6 +61,10 @@ async def question(
|
|||
"flow": flow_id,
|
||||
"request": {
|
||||
"question": question,
|
||||
"user": user,
|
||||
"state": state or "",
|
||||
"group": [],
|
||||
"history": []
|
||||
}
|
||||
|
||||
})
|
||||
|
|
|
|||
|
|
@ -79,11 +79,11 @@ def format_table_data(rows, table_name, output_format):
|
|||
else:
|
||||
return json.dumps({table_name: rows}, indent=2)
|
||||
|
||||
def structured_query(url, flow_id, question, output_format='table'):
|
||||
def structured_query(url, flow_id, question, user='trustgraph', collection='default', output_format='table'):
|
||||
|
||||
api = Api(url).flow().id(flow_id)
|
||||
|
||||
resp = api.structured_query(question=question)
|
||||
resp = api.structured_query(question=question, user=user, collection=collection)
|
||||
|
||||
# Check for errors
|
||||
if "error" in resp and resp["error"]:
|
||||
|
|
@ -132,6 +132,18 @@ def main():
|
|||
help='Natural language question to execute',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--user',
|
||||
default='trustgraph',
|
||||
help='Cassandra keyspace identifier (default: trustgraph)'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--collection',
|
||||
default='default',
|
||||
help='Data collection identifier (default: default)'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--format',
|
||||
choices=['table', 'json', 'csv'],
|
||||
|
|
@ -147,6 +159,8 @@ def main():
|
|||
url=args.url,
|
||||
flow_id=args.flow_id,
|
||||
question=args.question,
|
||||
user=args.user,
|
||||
collection=args.collection,
|
||||
output_format=args.format,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue