Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import psycopg2
|
| 3 |
-
import
|
| 4 |
import json
|
| 5 |
import os
|
| 6 |
from typing import List, Dict
|
|
@@ -15,16 +15,17 @@ def get_db_conn():
|
|
| 15 |
password=os.environ["VECTOR_SECRET"]
|
| 16 |
)
|
| 17 |
|
| 18 |
-
#
|
|
|
|
| 19 |
def get_embedding(text: str) -> List[float]:
|
| 20 |
"""
|
| 21 |
ํ
์คํธ๋ฅผ ์๋ฒ ๋ฉ ๋ฒกํฐ๋ก ๋ณํํฉ๋๋ค.
|
| 22 |
"""
|
| 23 |
-
response =
|
| 24 |
input=text,
|
| 25 |
model="text-embedding-3-large"
|
| 26 |
)
|
| 27 |
-
return response
|
| 28 |
|
| 29 |
def search_similar_chats(query: str, maxResults: int = 10) -> List[Dict]:
|
| 30 |
"""
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import psycopg2
|
| 3 |
+
from openai import OpenAI
|
| 4 |
import json
|
| 5 |
import os
|
| 6 |
from typing import List, Dict
|
|
|
|
| 15 |
password=os.environ["VECTOR_SECRET"]
|
| 16 |
)
|
| 17 |
|
| 18 |
+
client = OpenAI() # ํ๊ฒฝ๋ณ์์ OPENAI_API_KEY๊ฐ ์์ผ๋ฉด ์๋ ์ธ์
|
| 19 |
+
|
| 20 |
def get_embedding(text: str) -> List[float]:
|
| 21 |
"""
|
| 22 |
ํ
์คํธ๋ฅผ ์๋ฒ ๋ฉ ๋ฒกํฐ๋ก ๋ณํํฉ๋๋ค.
|
| 23 |
"""
|
| 24 |
+
response = client.embeddings.create(
|
| 25 |
input=text,
|
| 26 |
model="text-embedding-3-large"
|
| 27 |
)
|
| 28 |
+
return response.data[0].embedding
|
| 29 |
|
| 30 |
def search_similar_chats(query: str, maxResults: int = 10) -> List[Dict]:
|
| 31 |
"""
|