importos# Set API keys for different LLM providersos.environ["DEEPSEEK_API_KEY"]="your-deepseek-key"os.environ["OPENAI_API_KEY"]="your-openai-key"# Optionalos.environ["MISTRAL_API_KEY"]="your-mistral-key"# Optional
API Key Configuration
Always set API keys as environment variables
Never hardcode sensitive credentials in your script
Supports multiple LLM providers for flexibility
Creating an Agent
Initialize an agent with your preferred language model:
deffibonacci(n:int)->list[int]:"""Generate Fibonacci sequence up to n numbers. Args: n: Number of Fibonacci numbers to generate Returns: List of Fibonacci numbers """ifn<=0:return[]elifn==1:return[0]sequence=[0,1]whilelen(sequence)<n:sequence.append(sequence[-1]+sequence[-2])returnsequence# Example usageprint(fibonacci(10))# [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
Best Practices
Choose models based on your specific requirements
Validate API keys before initializing the agent
Handle potential errors gracefully
Experiment with different models to find the best fit
Supported LLM Providers
DeepSeek
OpenAI
Mistral AI
AWS Bedrock (enterprise)
Flexibility
The QuantaLogic Agent supports multiple language models, giving you the freedom to choose the best AI for your task.
importosfromquantalogicimportAgent# Set API keys for different LLM providersifnotos.environ.get("DEEPSEEK_API_KEY"):raiseValueError("DEEPSEEK_API_KEY environment variable is not set")# Initialize agentagent=Agent(model_name="deepseek/deepseek-chat")# Solve a taskresult=agent.solve_task("Create a Python function that calculates the Fibonacci sequence")print(result)
Best Practice
Always verify API keys are set before creating the agent to avoid runtime errors.