Spaces:
Sleeping
Sleeping
| import anthropic | |
| from typing import Union | |
| from fastapi import FastAPI | |
| app = FastAPI() | |
| key = "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" | |
| client = anthropic.Anthropic(api_key=key,) | |
| MODEL_NAME = "claude-3-opus-20240229" | |
| def read_root(): | |
| return {"Hello": "Welcome to the response generator by Claude"} | |
| def read_item(prompt: str): | |
| response = message = client.messages.create( model="claude-3-opus-20240229", max_tokens=1024, | |
| messages=[{"role": "user", "content": prompt}] | |
| ).content[0].text | |
| return {"response": response} |