Spaces:
Sleeping
Sleeping
File size: 2,095 Bytes
521d69a d947abd 521d69a d947abd 521d69a d947abd 521d69a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
---
title: ChromaDB
emoji: ποΈ
colorFrom: blue
colorTo: purple
sdk: docker
app_port: 7860
pinned: false
short_description: ChromaDB Auth Proxy
---
# ποΈ ChromaDB Auth Proxy
A ChromaDB server with auth proxy.
## π Quick Start
### Connection Information
- **Host**: `https://hyperdemocracy.chromadb-usc-vecs.hf.space`
- **Authentication**: Secret bearer token
## π» Usage
### Python HttpClient Example
```python
import os
import time
import uuid
import chromadb
from chromadb.config import Settings, APIVersion
# Get host and token from environment variable
host = os.getenv("CHROMA_PROXY_BASE")
token = os.getenv("CHROMA_AUTH_TOKEN")
if not host or not token:
raise ValueError("Set CHROMA_PROXY_BASE and CHROMA_AUTH_TOKEN")
headers = {"Authorization": f"Bearer {token}"}
settings = Settings(chroma_server_api_default_path=APIVersion.V2, anonymized_telemetry=False)
client = chromadb.HttpClient(host=host, headers=headers, settings=settings)
# Test the connection
print("HB:", client.heartbeat())
# Collection: create β add β query β delete
name=f"demo_{int(time.time())}_{uuid.uuid4().hex[:6]}"
coll=client.get_or_create_collection(name=name, metadata={"purpose":"smoke"})
coll.add(
ids=["doc-1", "doc-2", "doc-3"],
documents=[
"The Eiffel Tower is located in Paris and was completed in 1889.",
"Mount Fuji is the highest mountain in Japan and an active stratovolcano.",
"The Great Wall of China is a series of fortifications built across ancient China.",
],
metadatas=[
{"country": "France", "city": "Paris"},
{"country": "Japan"},
{"country": "China"},
],
)
print(coll.query(query_texts=["Which landmark is in France?"], n_results=2))
client.delete_collection(name=name)
print("OK")
```
### curl example
```bash
# Test proxy health without authentication
curl https://hyperdemocracy-chromadb-usc-vecs.hf.space/health
# Test chromadb API with authentication
curl -H "authorization: Bearer $CHROMA_AUTH_TOKEN" https://hyperdemocracy-chromadb-usc-vecs.hf.space/api/v2/heartbeat
```
---
|