Spaces:
Sleeping
Sleeping
robinroy03
commited on
Commit
·
b09edd3
1
Parent(s):
52bcaeb
First commit :)
Browse files- .gitignore +4 -0
- Dockerfile +16 -0
- app.py +30 -0
- requirements.txt +14 -0
.gitignore
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.env
|
2 |
+
venv
|
3 |
+
__pycache__
|
4 |
+
learn.py
|
Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3
|
2 |
+
|
3 |
+
RUN useradd -m -u 1000 user
|
4 |
+
USER user
|
5 |
+
ENV HOME=/home/user \
|
6 |
+
PATH=/home/user/.local/bin:$PATH
|
7 |
+
|
8 |
+
COPY --chown=user . $HOME/dbAPI
|
9 |
+
|
10 |
+
WORKDIR $HOME/dbAPI
|
11 |
+
|
12 |
+
RUN mkdir $HOME/.cache
|
13 |
+
|
14 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
15 |
+
|
16 |
+
CMD ["gunicorn", "-w", "5", "-b", "0.0.0.0:7860","app:app"]
|
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask
|
2 |
+
from flask import request
|
3 |
+
from pinecone import Pinecone, ServerlessSpec
|
4 |
+
|
5 |
+
import os
|
6 |
+
|
7 |
+
|
8 |
+
PINECONE_DB_API = os.environ.get('PINECONE_DB_API')
|
9 |
+
pc = Pinecone(api_key=PINECONE_DB_API)
|
10 |
+
index = pc.Index('fury-actor-py') # NOTE: FOR NOW
|
11 |
+
|
12 |
+
app = Flask(__name__)
|
13 |
+
|
14 |
+
@app.route("/query", methods=['POST'])
|
15 |
+
def query():
|
16 |
+
"""
|
17 |
+
{
|
18 |
+
embeddings: <embeddings_list>
|
19 |
+
}
|
20 |
+
"""
|
21 |
+
|
22 |
+
embeddings = request.get_json()['embeddings']
|
23 |
+
|
24 |
+
matches = index.query(
|
25 |
+
vector = embeddings,
|
26 |
+
top_k = 3,
|
27 |
+
include_metadata = True
|
28 |
+
)
|
29 |
+
|
30 |
+
return matches.to_dict()
|
requirements.txt
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
blinker==1.8.2
|
2 |
+
certifi==2024.6.2
|
3 |
+
click==8.1.7
|
4 |
+
Flask==3.0.3
|
5 |
+
gunicorn==22.0.0
|
6 |
+
itsdangerous==2.2.0
|
7 |
+
Jinja2==3.1.4
|
8 |
+
MarkupSafe==2.1.5
|
9 |
+
packaging==24.0
|
10 |
+
pinecone-client==4.1.0
|
11 |
+
tqdm==4.66.4
|
12 |
+
typing_extensions==4.12.1
|
13 |
+
urllib3==2.2.1
|
14 |
+
Werkzeug==3.0.3
|