import os from dotenv import load_dotenv import base64 LANGFUSE_PUBLIC_KEY = os.getenv("LANGFUSE_PUBLIC_KEY") LANGFUSE_SECRET_KEY = os.getenv("LANGFUSE_SECRET_KEY") LANGFUSE_AUTH = base64.b64encode(f"{LANGFUSE_PUBLIC_KEY}:{LANGFUSE_SECRET_KEY}".encode()).decode() os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://cloud.langfuse.com/api/public/otel" # Ensure this matches your region os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = f"Authorization=Basic {LANGFUSE_AUTH}" from opentelemetry.sdk.trace import TracerProvider from openinference.instrumentation.smolagents import SmolagentsInstrumentor from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter from opentelemetry.sdk.trace.export import SimpleSpanProcessor trace_provider = TracerProvider() trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter())) SmolagentsInstrumentor().instrument(tracer_provider=trace_provider) import yaml import os from smolagents import GradioUI, CodeAgent, HfApiModel CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) from tools.fitness_routine import FitnessRoutineTool as FT fitness_routine = FT() # Create the fitness agent with our custom tool fitness_agent = CodeAgent( name="Fitness_Routine_Agent", tools=[fitness_routine], model=HfApiModel(model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud/') ) # Example usage response = fitness_agent.run( "Create a 45-minute weight loss routine for a 39-year-old begginer " "with dumbells " ) if __name__ == "__main__": GradioUI(fitness_agent).launch()