feat(vector): Automatic indexing of documents in s3 storage
This commit is contained in:
19
vector/client.py
Normal file
19
vector/client.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import requests
|
||||
|
||||
class EmbeddedClient:
|
||||
def __init__(self, authorization: str, url: str = "https://openrouter.ai/api/v1/embeddings", model: str = "qwen/qwen3-embedding-8b") -> None:
|
||||
self.url = url
|
||||
self.authorization = authorization
|
||||
self.model = model
|
||||
|
||||
def embed(self, text: str) -> list[float]:
|
||||
print(f"Embedding text {text}...")
|
||||
response = requests.post(
|
||||
f"{self.url}",
|
||||
headers={"Authorization": self.authorization, "Content-Type": "application/json"},
|
||||
json={"input": text, "model": self.model},
|
||||
timeout=60
|
||||
)
|
||||
response.raise_for_status()
|
||||
embedding = response.json()["data"][0]["embedding"]
|
||||
return embedding
|
||||
Reference in New Issue
Block a user