fun main() = runBlocking {
val apiKey = "api-key"
val entity = System.getenv()["WEAVE_ENTITY"] ?: throw IllegalArgumentException("WEAVE_ENTITY is not set")
val projectName = System.getenv()["WEAVE_PROJECT_NAME"] ?: "koog-tracing"
val agent = AIAgent(
executor = simpleOpenAIExecutor(apiKey),
llmModel = OpenAIModels.CostOptimized.GPT4oMini,
systemPrompt = "You are a code assistant. Provide concise code examples."
) {
install(OpenTelemetry) {
addWeaveExporter()
}
}
println("Running agent with Weave tracing")
val result = agent.run("""
Create a Python function to calculate fibonacci numbers efficiently,
include error handling, type hints, and unit tests.
Verify the implementation works for n=50.
""")
println("Result: $result\nSee traces on https://wandb.ai/$entity/$projectName/weave/traces")
}