Wrapper application around upstream Vanna with: - Tenant-aware ChromaDB memory (per program/store) - ClickHouse RLS runner with introspection guards - PT-BR system prompt and chat translations - Custom Plotly chart generator (ranked bar, datetime coercion) - Embed bootstrap (theme pierce + i18n + markdown) shared by demo and React app - Event sink for chat turn observability
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
"""Ask the Vanna agent a question from the command line.
|
|
|
|
Usage:
|
|
python ask.py "Quantas vendas tivemos no último mês?"
|
|
python ask.py --program-id <id> --store-id <id> "..."
|
|
"""
|
|
|
|
import argparse
|
|
import asyncio
|
|
from typing import Optional
|
|
|
|
from agent import build_agent, local_request_context
|
|
|
|
|
|
async def main(question: str, program_id: Optional[str], store_id: Optional[str]) -> None:
|
|
agent = build_agent(program_id=program_id, store_id=store_id)
|
|
rc = local_request_context()
|
|
|
|
print(f"\n> {question}\n")
|
|
async for component in agent.send_message(
|
|
request_context=rc,
|
|
message=question,
|
|
conversation_id="cli-session",
|
|
):
|
|
rich = getattr(component, "rich_component", None)
|
|
simple = getattr(component, "simple_component", None)
|
|
|
|
content = getattr(rich, "content", None) if rich else None
|
|
if not content and simple is not None:
|
|
content = getattr(simple, "text", None)
|
|
if content:
|
|
print(content)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="Ask the Vanna agent a question.")
|
|
parser.add_argument("--program-id", dest="program_id", default=None)
|
|
parser.add_argument("--store-id", dest="store_id", default=None)
|
|
parser.add_argument("question", nargs="+")
|
|
args = parser.parse_args()
|
|
|
|
asyncio.run(
|
|
main(
|
|
question=" ".join(args.question),
|
|
program_id=args.program_id,
|
|
store_id=args.store_id,
|
|
)
|
|
)
|