@baserun.trace
def ask_question(question="What is the capital of the US?") -> str:
completion = client.chat.completions.create(
model="gpt-4-1106-preview",
messages=[{"role": "user", "content": question}],
)
content = completion.choices[0].message.content
# Create the annotation
annotation = baserun.annotate()
# Capture the user feedback as an annotation
annotation.feedback(
name="annotate_feedback", score=0.8, metadata={"comment": "This is correct but not concise enough"}
)
annotation.check_includes("openai_chat.content", "Washington", content)
annotation.log("OpenAI Chat Results", metadata={"result": content, "input": question})
# Make sure to submit the annotation
annotation.submit()