talking to claude

This commit is contained in:
2026-02-12 09:07:14 -07:00
parent ec90e8fea3
commit ec1b4af657
4 changed files with 52 additions and 0 deletions
View File
+11
View File
@@ -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"
+23
View File
@@ -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
+18
View File
@@ -0,0 +1,18 @@
import asyncio
from agent.loop import run_turn
async def run_tui():
user_message = "what is the answer to life the universe and everythings?"
message = await run_turn(user_message)
print(message.content)
def main():
print("Hello from mycode!")
asyncio.run(run_tui())
if __name__ == "__main__":
main()