"""Publish the sample catalog and select tools for a few turns. pip install toolcue export TOOLCUE_URL=... TOOLCUE_TOKEN=... TOOLCUE_ADMIN_TOKEN=... python3 quickstart.py """ import json import os from toolcue import ToolcueClient AGENT = "acme-billing" catalog = json.load(open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "catalog.json"))) toolcue = ToolcueClient() summary = toolcue.publish_catalog(AGENT, catalog["tools"]) print(f"published {summary['tools']} tools, {summary['edges']} dependency links") turns = [ ("Refund the last invoice for Globex", [], {"roles": ["agent"]}), ("thanks!", [], {"roles": ["agent"]}), ("ok, move them to the scale plan", [ {"role": "user", "content": "what plan is Globex on?"}, {"role": "assistant", "content": "Globex (cus_8812) is on growth.", "toolCalls": [ {"name": "find_customer", "arguments": {"query": "Globex"}, "result": "{\"customer_id\": \"cus_8812\", \"plan\": \"growth\"}"}]}], {"roles": ["agent"]}), ] for message, history, user in turns: answer = toolcue.select(AGENT, message, history, user) print(f"\n> {message}\n turn type: {answer['turnType']}, {answer['timings']['totalMs']:.0f} ms") for t in answer["tools"]: print(f" - {t['name']:<24} {t['reason']:<10} {t['detail']}") if answer["resolvedParams"]: print(f" values found in the conversation: {answer['resolvedParams']}") found = toolcue.find_tools(AGENT, "set the VAT rate to 20%", user={"roles": ["admin"]}) print("\nfind_tools('set the VAT rate to 20%') as an admin:", [t["name"] for t in found["tools"]])