You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
logs can include a trace and span ID. If the span ID is present and a specific span is selected.. should we only show those logs instead of all of them?
importosimporthttpximportlogfirefrompydantic_aiimportAgentfrompydantic_ai.models.instrumentedimportInstrumentedModelfrompydantic_ai.models.openaiimportOpenAIModellogfire.configure()
defget_latest_elasticsearch_version() ->str:
""" Returns the latest GA version of Elasticsearch in "X.Y.Z" format. """response=httpx.get("https://artifacts.elastic.co/releases/stack.json")
releases=response.json()["releases"]
# Filter out non-release versions (e.g. -rc1), and any " GA" suffixversions= [r["version"].replace(" GA", "") forrinreleasesif"-"notinr["version"]]
# Avoid lexicographic sort by comparing as a numeric tuple (X, Y, Z)returnmax(versions, key=lambdav: tuple(map(int, v.split("."))))
defmain():
model=InstrumentedModel(OpenAIModel(os.getenv("CHAT_MODEL", "gpt-4o-mini")))
agent=Agent(model, tools=[get_latest_elasticsearch_version])
result=agent.run_sync("What's the latest version of Elasticsearch?")
print(result.data)
if__name__=="__main__":
main()
.env
# Override default ENV variables for Ollama
OPENAI_BASE_URL=http://localhost:11434/v1
OPENAI_API_KEY=unused
# Need a larger model as 0.5b hallucinates on tool calls
CHAT_MODEL=qwen2.5:3b
# Disable sending to LogFire as we are sending to OTLP
LOGFIRE_SEND_TO_LOGFIRE=0
# OpenTelemetry configuration
OTEL_SERVICE_NAME=python-logfire-pydantic-ai
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true
The text was updated successfully, but these errors were encountered:
logs can include a trace and span ID. If the span ID is present and a specific span is selected.. should we only show those logs instead of all of them?
requirements.txt
main.py
.env
The text was updated successfully, but these errors were encountered: