-
Notifications
You must be signed in to change notification settings - Fork 0
/
chroma-client.html
262 lines (248 loc) · 7.85 KB
/
chroma-client.html
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<script type="text/javascript">
RED.nodes.registerType("remote-server-client", {
category: "config",
defaults: {
host: { value: "localhost", required: true },
},
label: function () {
return this.host;
},
});
</script>
<script type="text/html" data-template-name="remote-server-client">
<div class="form-row">
<label for="node-config-input-host"
><i class="fa fa-bookmark"></i> Host</label
>
<input type="text" id="node-config-input-host" />
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType("chromadb-client", {
category: "UBOS",
color: "#08B5FB",
defaults: {
name: { value: "" },
remoteServer: { value: "", type: "remote-server-client" },
collection: { value: "" },
operation: {
value: "listCollections",
required: true,
validate: function (v) {
const operation = String(v);
switch (operation) {
case "listCollections":
$("#forms-collection").css("display", "none");
break;
case "reset":
$("#forms-collection").css("display", "none");
break;
case "version":
$("#forms-collection").css("display", "none");
break;
default:
$("#forms-collection").css("display", "block");
break;
}
return true;
},
},
},
inputs: 1,
outputs: 1,
paletteLabel: "chroma client",
icon: "icon.png",
label: function () {
return this.name || "ChromaDB client";
},
});
</script>
<script type="text/html" data-template-name="chromadb-client">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name" />
</div>
<div class="form-row">
<label for="node-input-remoteServer">
<i class="fa fa-server"></i> Connection
</label>
<input type="text" id="node-input-remoteServer" />
</div>
<div class="form-row">
<label for="node-input-operation"
><i class="fa fa-wrench"></i> Operation</label
>
<select type="text" id="node-input-operation" style="width:70%!important;">
<option value="listCollections">listCollections</option>
<option value="createCollection">createCollection</option>
<option value="deleteCollection">deleteCollection</option>
<option value="getCollection">getCollection</option>
<option value="getOrCreateCollection">getOrCreateCollection</option>
<option value="heartbeat">heartbeat</option>
<option value="reset">reset</option>
<option value="version">version</option>
</select>
</div>
<div id="forms-collection">
<div class="form-row">
<label for="node-input-collection"
><i class="fa fa-database"></i> Collection</label
>
<input
type="text"
id="node-input-collection"
placeholder="Database Name"
autocomplete="off"
/>
</div>
</div>
</script>
<script type="text/html" data-help-name="chromadb-client">
<h3 id="createcollection">createCollection</h3>
<p>
▸ <strong>createCollection</strong>(<code>params</code>):
<code>Promise</code><<code>Collection</code>>
</p>
<p>
Creates a new collection with the specified properties.
<a href="https://docs.trychroma.com/js_reference/Client#createcollection"
>More details</a
>
</p>
<p>
<strong><code>Throws</code></strong>
</p>
<p>If there is an issue creating the collection.</p>
<p>
<strong><code>Example</code></strong>
</p>
<pre><code class="lang-js">msg.collection = <span class="hljs-string">"my_collection"</span><span class="hljs-comment">;</span>
msg.payload = {
<span class="hljs-symbol"> metadata:</span> {
<span class="hljs-symbol"> description:</span> <span class="hljs-string">"My first collection"</span>
}
}<span class="hljs-comment">;</span>
return msg<span class="hljs-comment">;</span>
</code></pre>
<h3 id="deletecollection">deleteCollection</h3>
<p>
▸ <strong>deleteCollection</strong>(<code>params</code>):
<code>Promise</code><<code>void</code>>
</p>
<p>
Deletes a collection with the specified name.
<a href="https://docs.trychroma.com/js_reference/Client#deletecollection"
>More details</a
>
</p>
<p>
<strong><code>Throws</code></strong>
</p>
<p>If there is an issue deleting the collection.</p>
<p>
<strong><code>Example</code></strong>
</p>
<pre><code class="lang-js">msg.collection = <span class="hljs-string">"my_collection"</span><span class="hljs-comment">;</span>
msg.payload = {}<span class="hljs-comment">;</span>
return msg<span class="hljs-comment">;</span>
</code></pre>
<h3 id="getcollection">getCollection</h3>
<p>
▸ <strong>getCollection</strong>(<code>params</code>):
<code>Promise</code><<code>Collection</code>>
</p>
<p>
Gets a collection with the specified name.
<a href="https://docs.trychroma.com/js_reference/Client#getcollection"
>More details</a
>
</p>
<p>
<strong><code>Throws</code></strong>
</p>
<p>If there is an issue getting the collection.</p>
<p>
<strong><code>Example</code></strong>
</p>
<pre><code class="lang-js">msg.collection = <span class="hljs-string">"my_collection"</span><span class="hljs-comment">;</span>
msg.payload = {}<span class="hljs-comment">;</span>
return msg<span class="hljs-comment">;</span>
</code></pre>
<h3 id="getorcreatecollection">getOrCreateCollection</h3>
<p>
▸ <strong>getOrCreateCollection</strong>(<code>params</code>):
<code>Promise</code><<code>Collection</code>>
</p>
<p>
Gets or creates a collection with the specified properties.
<a
href="https://docs.trychroma.com/js_reference/Client#getorcreatecollection"
>More details</a
>
</p>
<p>
<strong><code>Throws</code></strong>
</p>
<p>If there is an issue getting or creating the collection.</p>
<p>
<strong><code>Example</code></strong>
</p>
<pre><code class="lang-js">msg.collection = <span class="hljs-string">"my_collection"</span><span class="hljs-comment">;</span>
msg.payload = {
<span class="hljs-symbol"> metadata:</span> {
<span class="hljs-symbol"> description:</span> <span class="hljs-string">"My first collection"</span>
}
}<span class="hljs-comment">;</span>
return msg<span class="hljs-comment">;</span>
</code></pre>
<h3 id="heartbeat">heartbeat</h3>
<p>
▸ <strong>heartbeat</strong>(): <code>Promise</code><<code>number</code>>
</p>
<p>
Returns a heartbeat from the Chroma API.
<a href="https://docs.trychroma.com/js_reference/Client#heartbeat"
>More details</a
>
</p>
<h3 id="listcollections">listCollections</h3>
<p>
▸ <strong>listCollections</strong>():
<code>Promise</code><<code>CollectionType</code>[]>
</p>
<p>
Lists all collections.
<a href="https://docs.trychroma.com/js_reference/Client#listCollections"
>More details</a
>
</p>
<p>
<strong><code>Throws</code></strong>
</p>
<p>If there is an issue listing the collections.</p>
<h3 id="reset">reset</h3>
<p>
▸ <strong>reset</strong>():
<code>Promise</code><<code>Reset200Response</code>>
</p>
<p>
Resets the state of the object by making an API call to the reset endpoint.
<a href="https://docs.trychroma.com/js_reference/Client#reset"
>More details</a
>
</p>
<p>
<strong><code>Throws</code></strong>
</p>
<p>If there is an issue resetting the state.</p>
<h3 id="version">version</h3>
<p>
▸ <strong>version</strong>(): <code>Promise</code><<code>string</code>>
</p>
<p>
Returns the version of the Chroma API.
<a href="https://docs.trychroma.com/js_reference/Client#version"
>More details</a
>
</p>
</script>