Skip to content

Instantly share code, notes, and snippets.

@vincentkoc
Last active April 25, 2025 15:07
Show Gist options
  • Save vincentkoc/a664a43a7edff5905e500fe38fd0dd77 to your computer and use it in GitHub Desktop.
Save vincentkoc/a664a43a7edff5905e500fe38fd0dd77 to your computer and use it in GitHub Desktop.
Comet Opik & Open AI Warsaw Hackathon

Recipe Agent Demo Architecture

Recipe Agent Demo with OpenAI Agents SDK + Comet Opik

A simple demo showcasing the integration of OpenAI Agents SDK with Comet Opik for observability. This demo features two agents:

  1. RecipeSuggesterAgent: Suggests recipes based on provided ingredients
  2. RecipeResearchAgent: Researches additional information about the suggested recipe

Setup

  1. Install dependencies:
pip install openai-agents opik python-dotenv
  1. Set up your OpenAI API key:
# Option A: Create a .env file
OPENAI_API_KEY=your_openai_key_here

# Option B: Export as environment variable
export OPENAI_API_KEY=your_openai_key_here
  1. Configure Opik:
opik configure
# Follow prompts for local server address
  1. Run the demo:
python recipe_agent.py

Features

  • Multi-agent orchestration using OpenAI Agents SDK
  • Asynchronous execution with proper error handling
  • Integration with Comet Opik for tracing and observability
  • Simple command-line interface for ingredient input

Example Usage

Welcome to the Recipe Agent Demo!

Enter a list of ingredients (comma-separated): chicken, rice, soy sauce

Suggested Recipe:
[Recipe suggestion will appear here]

Recipe Research:
[Additional information will appear here]

Project Structure

  • recipe_agent.py: Main application file containing agent definitions and logic
  • .env: (Optional) Environment variables file for API keys
"""
Sample Recipe Agent Demo for OpenAI Hackathon + Comet Opik
Setup Instructions:
-------------------
1. Install dependencies:
pip install openai-agents opik python-dotenv
2. Set up OpenAI API key:
Option A) Create a .env file in the project root:
OPENAI_API_KEY=your_openai_key_here
Option B) Export as environment variable:
export OPENAI_API_KEY=your_openai_key_here
3. Configure Opik (for tracing and online evals):
opik configure
# Follow prompts for local server address
4. Run the script:
python recipe_agent.py
References:
- Opik integration: https://www.comet.com/docs/opik/tracing/integrations/openai_agents
- OpenAI Agents SDK: https://platform.openai.com/docs/guides/agents
"""
import os
import asyncio
from dotenv import load_dotenv
from agents import Agent, Runner, set_trace_processors
from opik.integrations.openai.agents import OpikTracingProcessor
# Load environment variables from .env file
load_dotenv()
# Verify OpenAI API key is set
if not os.getenv("OPENAI_API_KEY"):
raise ValueError("OPENAI_API_KEY environment variable is not set")
# --- Agent 1: Recipe Suggester ---
RecipeSuggesterAgent = Agent(
name="RecipeSuggester",
instructions=(
"You are a helpful chef. Given a list of ingredients, suggest a creative recipe. "
"Be concise and clear. Output the recipe name and steps."
),
)
# --- Agent 2: Recipe Researcher ---
RecipeResearchAgent = Agent(
name="RecipeResearcher",
instructions=(
"You are a research assistant. Given a recipe name, research and provide "
"relevant information, tips, or variations for the recipe. Summarize your findings."
),
)
# --- Enable Opik Tracing ---
set_trace_processors(processors=[OpikTracingProcessor()])
# --- Demo Flow ---
async def main():
print("Welcome to the Recipe Agent Demo!\n")
ingredients = input("Enter a list of ingredients (comma-separated): ")
# Step 1: Suggest a recipe
recipe_result = await Runner.run(
RecipeSuggesterAgent,
f"Ingredients: {ingredients}"
)
recipe_name = recipe_result.final_output.split('\n')[0] # Assume first line is recipe name
print("\nSuggested Recipe:\n", recipe_result.final_output)
# Step 2: Research the recipe
research_result = await Runner.run(
RecipeResearchAgent,
f"Research the recipe: {recipe_name}"
)
print("\nRecipe Research:\n", research_result.final_output)
if __name__ == "__main__":
asyncio.run(main())

Recipe Agent Online Evaluation Prompts

These prompts are designed for Opik's online evaluation system to assess recipe quality and usability.

1. Recipe Taste Appeal Evaluation

You are a professional chef and food critic. Evaluate the suggested recipe's potential taste appeal and flavor combinations. Consider:
- Ingredient harmony and balance
- Seasoning and flavor depth
- Cultural authenticity (if applicable)
- Overall gastronomic appeal

Rate on a scale of 1-10 and explain your rating with specific culinary insights.

INPUT:
{{input}}

OUTPUT:
{{output}}

EVALUATION FORMAT:
Taste Score: [1-10]
Reasoning: [One clear sentence focusing on flavor profile and culinary merit]

2. Recipe Complexity and Accessibility

You are an experienced cooking instructor who specializes in home cooking. Evaluate the recipe's practicality and ease of execution. Consider:
- Ingredient accessibility
- Required cooking skills
- Time commitment
- Equipment needs
- Clear instructions

Rate on a scale of 1-10 (where 10 is extremely beginner-friendly) and provide specific implementation insights.

INPUT:
{{input}}

OUTPUT:
{{output}}

EVALUATION FORMAT:
Complexity Level: [Beginner/Intermediate/Advanced]
Time Estimate: [Quick (<30min)/Medium (30-60min)/Extended (>60min)]

Response example should be complexity + time, i.e: Intermediate 40mins

3. Overall Recipe Quality

You are an expert recipe developer and cookbook editor. Evaluate the overall quality and completeness of the recipe response. Consider:
- Ingredient specifications
- Step-by-step clarity
- Technical accuracy
- Safety considerations
- Serving size/yield information
- Additional tips/variations provided

Rate on a scale of 1-10 and explain your comprehensive assessment.

INPUT:
{{input}}

OUTPUT:
{{output}}

EVALUATION FORMAT:
Quality Score: [1-10]
Only give the quality score back

Using These Prompts

  1. Add these evaluations to your Opik configuration
  2. Monitor real-time recipe quality metrics
  3. Use insights to improve agent instructions and outputs
  4. Track quality trends over time

These prompts help ensure recipes are:

  • Tasty and appealing
  • Practical for home cooks
  • Well-documented and complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment