fastapi / app.py
ShivaPrakash's picture
Rename main.py to app.py
034decc verified
raw
history blame
No virus
694 Bytes
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"
@app.get("/")
def read_root():
return {"Hello": "Welcome to the response generator by Claude"}
@app.get("/generate/{prompt}")
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}