gabrielaltay commited on
Commit
d947abd
Β·
verified Β·
1 Parent(s): 521d69a

Upload README.md with huggingface_hub

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