|
|
|
|
|
import logging |
|
import json |
|
|
|
import basic_agent |
|
|
|
LOG = logging.getLogger(__name__) |
|
|
|
QUESTIONS_PATH = "../questions.json" |
|
|
|
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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() |
|
|
|
with open(QUESTIONS_PATH, "r") as fp: |
|
questions = json.load(fp) |
|
|
|
|
|
print(f"{len(questions)=}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
want = 9 |
|
question = questions[want] |
|
|
|
q_task_id = question["task_id"] |
|
q_text = question["question"] |
|
q_filename = question.get("file_name", "") |
|
|
|
if q_filename: |
|
file_url = f"{DEFAULT_API_URL}/files/{q_task_id}" |
|
print("Question {task_id=} has attachment: {file_url=}") |
|
quest_with_url = f"{q_text}\nFile url: {file_url}" |
|
else: |
|
quest_with_url = q_text |
|
|
|
answer = ba(quest_with_url) |
|
|
|
LOG.warning(f"{answer=}") |
|
|