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} |