Spaces:
Running
Running
File size: 5,310 Bytes
14b666f b52102b 14b666f b52102b 14b666f b52102b 14b666f b52102b 14b666f b52102b 14b666f b52102b 14b666f b52102b 14b666f b52102b 14b666f b52102b 14b666f b52102b 14b666f b52102b 14b666f b52102b 14b666f b52102b 14b666f b52102b 14b666f b52102b 14b666f b52102b 14b666f b52102b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
"""
Example usage of the Fitness Agent with different AI providers and models.
Run this script to see different ways to use the FitnessAgent with both
Anthropic Claude and OpenAI GPT models.
"""
from fitness_agent import FitnessAgent
from agents import Runner
import os
def basic_example():
"""Example using the default model."""
print("=== Basic Usage (Default Model) ===")
agent = FitnessAgent()
print(f"Using model: {agent.model_name}")
print(f"Provider: {agent.provider}")
print(f"Final model path: {agent.final_model}")
# In a real scenario, you would run this:
# result = Runner.run_sync(agent, "Create a beginner fitness plan.")
# print(f"Result: {result.final_output}")
print("β
Agent created successfully!")
print()
def anthropic_example():
"""Example using Anthropic Claude models."""
print("=== Anthropic Claude Example ===")
agent = FitnessAgent("claude-3.5-sonnet")
print(f"Using model: {agent.model_name}")
print(f"Provider: {agent.provider}")
print(f"Final model path: {agent.final_model}")
print("β
Anthropic agent created successfully!")
print()
def openai_example():
"""Example using OpenAI GPT models."""
print("=== OpenAI GPT Example ===")
try:
agent = FitnessAgent("gpt-4o-mini")
print(f"Using model: {agent.model_name}")
print(f"Provider: {agent.provider}")
print(f"Final model path: {agent.final_model}")
print("β
OpenAI agent created successfully!")
except Exception as e:
print(f"β οΈ Could not create OpenAI agent: {e}")
print(" (Make sure you have OPENAI_API_KEY set in your .env file)")
print()
def reasoning_model_example():
"""Example using OpenAI reasoning models (o1/o3 series)."""
print("=== OpenAI Reasoning Model Example ===")
try:
agent = FitnessAgent("o1-mini")
print(f"Using model: {agent.model_name}")
print(f"Provider: {agent.provider}")
print(f"Final model path: {agent.final_model}")
print("β
Reasoning model agent created successfully!")
print("π‘ o1-mini is great for complex fitness planning and analysis")
except Exception as e:
print(f"β οΈ Could not create reasoning model agent: {e}")
print(" (o1 models may require special access)")
print()
def environment_variable_example():
"""Example using environment variable."""
print("=== Using Environment Variable ===")
# Set environment variable (in practice, this would be in your .env file)
os.environ["AI_MODEL"] = "gpt-4o"
agent = FitnessAgent() # Will use the model from environment variable
print(f"Using model: {agent.model_name}")
print(f"Provider: {agent.provider}")
print("β
Agent created with environment variable!")
print()
def list_available_models():
"""Display all available models organized by provider."""
print("=== Available Models by Provider ===")
providers = FitnessAgent.get_models_by_provider()
print("π΅ ANTHROPIC MODELS:")
for model in providers["anthropic"]:
full_name = providers["anthropic"][model]
info = FitnessAgent.get_model_info(model)
print(f" β’ {model}")
print(f" Path: {full_name}")
print(f" Info: {info}")
print()
print("π’ OPENAI MODELS:")
for model in providers["openai"]:
full_name = providers["openai"][model]
info = FitnessAgent.get_model_info(model)
print(f" β’ {model}")
print(f" Path: {full_name}")
print(f" Info: {info}")
print()
print("π― RECOMMENDED MODELS:")
for model in FitnessAgent.get_recommended_models():
provider_icon = "π΅" if "claude" in model else "π’" if any(x in model for x in ["gpt", "o1", "o3"]) else "βͺ"
print(f" {provider_icon} {model}")
print()
def compare_providers():
"""Show comparison between providers."""
print("=== Provider Comparison ===")
print("π΅ ANTHROPIC CLAUDE:")
print(" β
Excellent for detailed analysis and safety")
print(" β
Great context understanding")
print(" β
Strong reasoning capabilities")
print(" β Requires ANTHROPIC_API_KEY")
print()
print("π’ OPENAI GPT:")
print(" β
Familiar and widely used")
print(" β
Good general performance")
print(" β
Vision capabilities (GPT-4o)")
print(" β
Reasoning models (o1/o3 series)")
print(" β Requires OPENAI_API_KEY")
print()
if __name__ == "__main__":
print("π€ Fitness Agent Examples - Multi-Provider Support")
print("=" * 60)
list_available_models()
compare_providers()
basic_example()
anthropic_example()
openai_example()
reasoning_model_example()
environment_variable_example()
print("=" * 60)
print("β
All examples completed!")
print()
print("π‘ To actually run the agents:")
print(" 1. Copy .env.example to .env")
print(" 2. Add your OPENAI_API_KEY and/or ANTHROPIC_API_KEY")
print(" 3. Uncomment the Runner.run_sync lines in the examples")
print(" 4. Run: python fitness_agent/examples.py")
print()
print("π Or launch the web interface: python fitness_agent/app.py")
|