update gemini embedding
Browse files- rag_core/embedder.py +3 -2
rag_core/embedder.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import requests
|
| 2 |
import time
|
| 3 |
import logging
|
|
|
|
| 4 |
from rag_core.utils import log_timed
|
| 5 |
|
| 6 |
@log_timed("gửi API tạo embedding")
|
|
@@ -9,8 +10,8 @@ def get_embedding(text: str, retries: int = 3, base_timeout: int = 30):
|
|
| 9 |
try:
|
| 10 |
current_timeout = base_timeout * (i + 1)
|
| 11 |
response = requests.post(
|
| 12 |
-
"https://
|
| 13 |
-
json={"text": text},
|
| 14 |
timeout=current_timeout
|
| 15 |
)
|
| 16 |
response.raise_for_status()
|
|
|
|
| 1 |
import requests
|
| 2 |
import time
|
| 3 |
import logging
|
| 4 |
+
import os
|
| 5 |
from rag_core.utils import log_timed
|
| 6 |
|
| 7 |
@log_timed("gửi API tạo embedding")
|
|
|
|
| 10 |
try:
|
| 11 |
current_timeout = base_timeout * (i + 1)
|
| 12 |
response = requests.post(
|
| 13 |
+
"https://generativelanguage.googleapis.com/v1/models/text-embedding-004:embedContent?key="+os.getenv("GEMINI_API_KEY"),
|
| 14 |
+
json={"content": { "parts": [ { "text": text } ] }},
|
| 15 |
timeout=current_timeout
|
| 16 |
)
|
| 17 |
response.raise_for_status()
|