Spaces:
Sleeping
Sleeping
ShivaPrakash
commited on
Commit
•
4824952
1
Parent(s):
06c95ad
Add application file
Browse files- .ipynb_checkpoints/Dockerfile-checkpoint +0 -0
- .ipynb_checkpoints/main-checkpoint.py +21 -0
- .ipynb_checkpoints/requirements-checkpoint.txt +3 -0
- Dockerfile +11 -0
- main.py +21 -0
- requirements.txt +3 -0
.ipynb_checkpoints/Dockerfile-checkpoint
ADDED
File without changes
|
.ipynb_checkpoints/main-checkpoint.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import anthropic
|
2 |
+
from typing import Union
|
3 |
+
from fastapi import FastAPI
|
4 |
+
|
5 |
+
app = FastAPI()
|
6 |
+
key = "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"
|
7 |
+
client = anthropic.Anthropic(api_key=key,)
|
8 |
+
MODEL_NAME = "claude-3-opus-20240229"
|
9 |
+
|
10 |
+
@app.get("/")
|
11 |
+
def read_root():
|
12 |
+
return {"Hello": "Welcome to the response generator by Claude"}
|
13 |
+
|
14 |
+
|
15 |
+
@app.get("/generate/{prompt}")
|
16 |
+
|
17 |
+
def read_item(prompt: str):
|
18 |
+
response = message = client.messages.create( model="claude-3-opus-20240229", max_tokens=1024,
|
19 |
+
messages=[{"role": "user", "content": prompt}]
|
20 |
+
).content[0].text
|
21 |
+
return {"response": response}
|
.ipynb_checkpoints/requirements-checkpoint.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
fastapi
|
2 |
+
uvicorn[standard]
|
3 |
+
anthropic
|
Dockerfile
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9
|
2 |
+
|
3 |
+
WORKDIR /code
|
4 |
+
|
5 |
+
COPY ./requirements.txt /code/requirements.txt
|
6 |
+
|
7 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
+
|
9 |
+
COPY . .
|
10 |
+
|
11 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
main.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import anthropic
|
2 |
+
from typing import Union
|
3 |
+
from fastapi import FastAPI
|
4 |
+
|
5 |
+
app = FastAPI()
|
6 |
+
key = "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"
|
7 |
+
client = anthropic.Anthropic(api_key=key,)
|
8 |
+
MODEL_NAME = "claude-3-opus-20240229"
|
9 |
+
|
10 |
+
@app.get("/")
|
11 |
+
def read_root():
|
12 |
+
return {"Hello": "Welcome to the response generator by Claude"}
|
13 |
+
|
14 |
+
|
15 |
+
@app.get("/generate/{prompt}")
|
16 |
+
|
17 |
+
def read_item(prompt: str):
|
18 |
+
response = message = client.messages.create( model="claude-3-opus-20240229", max_tokens=1024,
|
19 |
+
messages=[{"role": "user", "content": prompt}]
|
20 |
+
).content[0].text
|
21 |
+
return {"response": response}
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
fastapi
|
2 |
+
uvicorn[standard]
|
3 |
+
anthropic
|