Spaces:
Paused
Paused
tamas.kiss
commited on
Commit
·
8b9bffd
1
Parent(s):
8d2f8de
Changed to OpenAI embeddings because of
Browse files- app.py +3 -2
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -14,6 +14,7 @@ from bs4 import BeautifulSoup
|
|
| 14 |
import requests
|
| 15 |
import logging
|
| 16 |
from pinecone import Pinecone, ServerlessSpec
|
|
|
|
| 17 |
|
| 18 |
logging.basicConfig(format='[%(asctime)s] %(message)s', datefmt='%d-%b-%y %H:%M:%S', level=logging.INFO)
|
| 19 |
|
|
@@ -30,7 +31,7 @@ CACHE_DIR = "./.cache"
|
|
| 30 |
|
| 31 |
cross_encoder = CrossEncoder("cross-encoder/ms-marco-MiniLM-L-12-v2")
|
| 32 |
pinecone_client = Pinecone(api_key=PINECONE_API_KEY)
|
| 33 |
-
|
| 34 |
|
| 35 |
if not os.path.exists(CACHE_DIR):
|
| 36 |
os.makedirs(CACHE_DIR)
|
|
@@ -85,7 +86,7 @@ def cached(func):
|
|
| 85 |
|
| 86 |
@cached
|
| 87 |
def create_embedding(text: str):
|
| 88 |
-
embed_text =
|
| 89 |
|
| 90 |
return embed_text.tolist()
|
| 91 |
|
|
|
|
| 14 |
import requests
|
| 15 |
import logging
|
| 16 |
from pinecone import Pinecone, ServerlessSpec
|
| 17 |
+
from openai import OpenAI
|
| 18 |
|
| 19 |
logging.basicConfig(format='[%(asctime)s] %(message)s', datefmt='%d-%b-%y %H:%M:%S', level=logging.INFO)
|
| 20 |
|
|
|
|
| 31 |
|
| 32 |
cross_encoder = CrossEncoder("cross-encoder/ms-marco-MiniLM-L-12-v2")
|
| 33 |
pinecone_client = Pinecone(api_key=PINECONE_API_KEY)
|
| 34 |
+
openai = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
| 35 |
|
| 36 |
if not os.path.exists(CACHE_DIR):
|
| 37 |
os.makedirs(CACHE_DIR)
|
|
|
|
| 86 |
|
| 87 |
@cached
|
| 88 |
def create_embedding(text: str):
|
| 89 |
+
embed_text = openai.embeddings.create(input=text, model="text-embedding-ada-002", )
|
| 90 |
|
| 91 |
return embed_text.tolist()
|
| 92 |
|
requirements.txt
CHANGED
|
@@ -7,3 +7,4 @@ pinecone-client
|
|
| 7 |
sentence_transformers
|
| 8 |
tqdm
|
| 9 |
beautifulsoup4
|
|
|
|
|
|
| 7 |
sentence_transformers
|
| 8 |
tqdm
|
| 9 |
beautifulsoup4
|
| 10 |
+
openai
|