Implement secure configuration management with encryption and validation (Phase 1 improvements)
This commit is contained in:
commit
d4d6aafea9
12 files changed
+1656
No files matched your search
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Example usage of OpenClaw Agent with different LLM providers
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, '.')
|
||||
|
||||
from main import create_maxclaw_agent
|
||||
|
||||
def example_with_openai():
|
||||
"""Example using OpenAI"""
|
||||
print("=== Example: OpenAI ===")
|
||||
os.environ["MODEL_PROVIDER"] = "openai"
|
||||
os.environ["MODEL_NAME"] = "gpt-4o-mini"
|
||||
# You would need to set OPENAI_API_KEY in your environment
|
||||
# os.environ["OPENAI_API_KEY"] = "your-api-key"
|
||||
|
||||
try:
|
||||
agent = create_maxclaw_agent()
|
||||
print("✅ OpenAI agent created")
|
||||
# Uncomment to test (requires API key)
|
||||
# result = agent.invoke({"messages": [{"role": "user", "content": "Say hello in Italian"}]})
|
||||
# print(f"Response: {result['messages'][-1].content}")
|
||||
except Exception as e:
|
||||
print(f"❌ OpenAI agent failed: {e}")
|
||||
print("💡 Set OPENAI_API_KEY environment variable to test")
|
||||
|
||||
def example_with_ollama():
|
||||
"""Example using Ollama"""
|
||||
print("\n=== Example: Ollama ===")
|
||||
os.environ["MODEL_PROVIDER"] = "ollama"
|
||||
os.environ["MODEL_NAME"] = "gemma2:9b"
|
||||
os.environ["OLLAMA_BASE_URL"] = "https://ollama.solarpi.net" # From user's profile
|
||||
|
||||
try:
|
||||
agent = create_maxclaw_agent()
|
||||
print("✅ Ollama agent created")
|
||||
# Uncomment to test (requires Ollama server)
|
||||
# result = agent.invoke({"messages": [{"role": "user", "content": "Say hello in Italian"}]})
|
||||
# print(f"Response: {result['messages'][-1].content}")
|
||||
except Exception as e:
|
||||
print(f"❌ Ollama agent failed: {e}")
|
||||
print("💡 Make sure Ollama is running at https://ollama.solarpi.net")
|
||||
|
||||
def example_with_openrouter():
|
||||
"""Example using OpenRouter"""
|
||||
print("\n=== Example: OpenRouter ===")
|
||||
os.environ["MODEL_PROVIDER"] = "openrouter"
|
||||
os.environ["MODEL_NAME"] = "anthropic/claude-3.5-sonnet"
|
||||
# You would need to set OPENROUTER_API_KEY in your environment
|
||||
# os.environ["OPENROUTER_API_KEY"] = "your-api-key"
|
||||
|
||||
try:
|
||||
agent = create_maxclaw_agent()
|
||||
print("✅ OpenRouter agent created")
|
||||
# Uncomment to test (requires API key)
|
||||
# result = agent.invoke({"messages": [{"role": "user", "content": "Say hello in Italian"}]})
|
||||
# print(f"Response: {result['messages'][-1].content}")
|
||||
except Exception as e:
|
||||
print(f"❌ OpenRouter agent failed: {e}")
|
||||
print("💡 Set OPENROUTER_API_KEY environment variable to test")
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("OpenClaw Agent - Provider Configuration Examples\n")
|
||||
example_with_openai()
|
||||
example_with_ollama()
|
||||
example_with_openrouter()
|
||||
print("\n💡 To run the agent interactively, use: python main.py")
|
||||
print(" Remember to set the appropriate environment variables for your chosen provider.")
|
||||
Reference in new issue
Block a user