mirror of https://github.com/kortix-ai/suna.git
llm keys helper function in example agent && llm non-required api keys
This commit is contained in:
parent
cd53a3f6b4
commit
b3c189a9fa
|
@ -8,6 +8,7 @@ This agent can:
|
||||||
- Use either XML or Standard tool calling patterns
|
- Use either XML or Standard tool calling patterns
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
from agentpress.thread_manager import ThreadManager
|
from agentpress.thread_manager import ThreadManager
|
||||||
|
@ -88,6 +89,17 @@ file contents here
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def get_anthropic_api_key():
|
||||||
|
"""Get Anthropic API key from environment or prompt user."""
|
||||||
|
api_key = os.getenv("ANTHROPIC_API_KEY")
|
||||||
|
if not api_key:
|
||||||
|
api_key = input("\n🔑 Please enter your Anthropic API key: ").strip()
|
||||||
|
if not api_key:
|
||||||
|
print("❌ No API key provided. Please set ANTHROPIC_API_KEY environment variable or enter a key.")
|
||||||
|
sys.exit(1)
|
||||||
|
os.environ["ANTHROPIC_API_KEY"] = api_key
|
||||||
|
return api_key
|
||||||
|
|
||||||
async def run_agent(thread_id: str, use_xml: bool = True, max_iterations: int = 5):
|
async def run_agent(thread_id: str, use_xml: bool = True, max_iterations: int = 5):
|
||||||
"""Run the development agent with specified configuration."""
|
"""Run the development agent with specified configuration."""
|
||||||
thread_manager = ThreadManager()
|
thread_manager = ThreadManager()
|
||||||
|
@ -181,6 +193,8 @@ def main():
|
||||||
"""Main entry point with synchronous setup."""
|
"""Main entry point with synchronous setup."""
|
||||||
print("\n🚀 Welcome to AgentPress Web Developer Example!")
|
print("\n🚀 Welcome to AgentPress Web Developer Example!")
|
||||||
|
|
||||||
|
get_anthropic_api_key()
|
||||||
|
|
||||||
project_description = input("What would you like to build? (default: Create a modern, responsive landing page)\n> ")
|
project_description = input("What would you like to build? (default: Create a modern, responsive landing page)\n> ")
|
||||||
if not project_description.strip():
|
if not project_description.strip():
|
||||||
project_description = "Create a modern, responsive landing page"
|
project_description = "Create a modern, responsive landing page"
|
||||||
|
|
|
@ -7,13 +7,16 @@ from openai import OpenAIError
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY')
|
OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY', None)
|
||||||
ANTHROPIC_API_KEY = os.environ.get('ANTHROPIC_API_KEY')
|
ANTHROPIC_API_KEY = os.environ.get('ANTHROPIC_API_KEY', None)
|
||||||
GROQ_API_KEY = os.environ.get('GROQ_API_KEY')
|
GROQ_API_KEY = os.environ.get('GROQ_API_KEY', None)
|
||||||
AGENTOPS_API_KEY = os.environ.get('AGENTOPS_API_KEY')
|
AGENTOPS_API_KEY = os.environ.get('AGENTOPS_API_KEY', None)
|
||||||
|
|
||||||
|
if OPENAI_API_KEY:
|
||||||
os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY
|
os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY
|
||||||
|
if ANTHROPIC_API_KEY:
|
||||||
os.environ['ANTHROPIC_API_KEY'] = ANTHROPIC_API_KEY
|
os.environ['ANTHROPIC_API_KEY'] = ANTHROPIC_API_KEY
|
||||||
|
if GROQ_API_KEY:
|
||||||
os.environ['GROQ_API_KEY'] = GROQ_API_KEY
|
os.environ['GROQ_API_KEY'] = GROQ_API_KEY
|
||||||
|
|
||||||
async def make_llm_api_call(
|
async def make_llm_api_call(
|
||||||
|
|
Loading…
Reference in New Issue