Merge branch 'online-st'
Browse files
__pycache__/optimized_quiz.cpython-312.pyc
CHANGED
|
Binary files a/__pycache__/optimized_quiz.cpython-312.pyc and b/__pycache__/optimized_quiz.cpython-312.pyc differ
|
|
|
clients/__pycache__/groq_client.cpython-312.pyc
CHANGED
|
Binary files a/clients/__pycache__/groq_client.cpython-312.pyc and b/clients/__pycache__/groq_client.cpython-312.pyc differ
|
|
|
clients/groq_client.py
CHANGED
|
@@ -4,8 +4,8 @@ from uuid import uuid4
|
|
| 4 |
from groq import Groq
|
| 5 |
from langchain_core.documents import Document
|
| 6 |
|
| 7 |
-
# CHANGED:
|
| 8 |
-
from langchain_huggingface import
|
| 9 |
from langchain_chroma import Chroma
|
| 10 |
from dotenv import load_dotenv
|
| 11 |
import random
|
|
@@ -22,6 +22,7 @@ load_dotenv(dotenv_path=".secrets.env", override=True)
|
|
| 22 |
|
| 23 |
# Config
|
| 24 |
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
|
|
|
|
| 25 |
DATA_PATH = "data.json"
|
| 26 |
CHROMA_PATH = "chroma_db"
|
| 27 |
|
|
@@ -105,14 +106,14 @@ class GroqClient:
|
|
| 105 |
return []
|
| 106 |
|
| 107 |
def init_vector_store(self, documents):
|
| 108 |
-
# CHANGED:
|
| 109 |
-
# This
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
)
|
| 117 |
|
| 118 |
# Clear old data to avoid duplicates
|
|
@@ -127,7 +128,7 @@ class GroqClient:
|
|
| 127 |
persist_directory=CHROMA_PATH,
|
| 128 |
)
|
| 129 |
|
| 130 |
-
# CHANGED: This now
|
| 131 |
vector_store.add_documents(documents=documents, ids=uuids)
|
| 132 |
return vector_store
|
| 133 |
|
|
|
|
| 4 |
from groq import Groq
|
| 5 |
from langchain_core.documents import Document
|
| 6 |
|
| 7 |
+
# CHANGED: Using HuggingFaceEndpointEmbeddings for online API inference
|
| 8 |
+
from langchain_huggingface import HuggingFaceEndpointEmbeddings
|
| 9 |
from langchain_chroma import Chroma
|
| 10 |
from dotenv import load_dotenv
|
| 11 |
import random
|
|
|
|
| 22 |
|
| 23 |
# Config
|
| 24 |
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
|
| 25 |
+
HF_API_KEY = os.getenv("HF_API_KEY")
|
| 26 |
DATA_PATH = "data.json"
|
| 27 |
CHROMA_PATH = "chroma_db"
|
| 28 |
|
|
|
|
| 106 |
return []
|
| 107 |
|
| 108 |
def init_vector_store(self, documents):
|
| 109 |
+
# CHANGED: Using online HuggingFaceEndpointEmbeddings with API key
|
| 110 |
+
# This uses HuggingFace's hosted inference API instead of local model
|
| 111 |
+
if not HF_API_KEY:
|
| 112 |
+
raise RuntimeError("HF_API_KEY not found in environment")
|
| 113 |
+
|
| 114 |
+
embeddings_model = HuggingFaceEndpointEmbeddings(
|
| 115 |
+
model="sentence-transformers/all-MiniLM-L6-v2",
|
| 116 |
+
huggingfacehub_api_token=HF_API_KEY,
|
| 117 |
)
|
| 118 |
|
| 119 |
# Clear old data to avoid duplicates
|
|
|
|
| 128 |
persist_directory=CHROMA_PATH,
|
| 129 |
)
|
| 130 |
|
| 131 |
+
# CHANGED: This now makes API calls to HuggingFace for embeddings
|
| 132 |
vector_store.add_documents(documents=documents, ids=uuids)
|
| 133 |
return vector_store
|
| 134 |
|