Final_Assignment_Agent / basic_agent_test.py
SrcLurker's picture
change the models, add tracing.
766d2d7
raw
history blame
1.47 kB
#!/usr/bin/env python3
import logging
import basic_agent
LOG = logging.getLogger(__name__)
# Local:
# https://huggingface.co/docs/smolagents/tutorials/inspect_runs
# https://cobusgreyling.medium.com/introduce-inspectability-to-huggingface-smolagents-571bd3f8da4c
#
# pip install arize-phoenix opentelemetry-sdk opentelemetry-exporter-otlp openinference-instrumentation-smolagents
#
# pip install 'smolagents[telemetry]'
#
# python -m phoenix.server.main serve
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from openinference.instrumentation.smolagents import SmolagentsInstrumentor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor
endpoint = "http://0.0.0.0:6006/v1/traces"
trace_provider = TracerProvider()
trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))
SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
ba = basic_agent.BasicAgent()
"""
answer = ba(
"Who is the 47th president of the united states? If necessary, use a web search to get the most up to date information."
)
"""
answer = ba("What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists?"
)
LOG.warning(f"{answer=}")