talking to claude
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
anthropic_api_key: str
|
||||
model: str = "claude-sonnet-4-5-20250929"
|
||||
safedir: str = "./workspace"
|
||||
max_tokens: int = 500
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
@@ -0,0 +1,23 @@
|
||||
import asyncio
|
||||
|
||||
from anthropic import AsyncAnthropic
|
||||
|
||||
from agent.config import Settings
|
||||
|
||||
settings = Settings()
|
||||
|
||||
client = AsyncAnthropic(api_key=settings.anthropic_api_key)
|
||||
|
||||
|
||||
async def run_turn(user_message: str) -> str:
|
||||
message = await client.messages.create(
|
||||
model=settings.model,
|
||||
max_tokens=settings.max_tokens,
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": user_message,
|
||||
}
|
||||
],
|
||||
)
|
||||
return message
|
||||
Reference in New Issue
Block a user