Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitab83832

Browse files
authored
Clean Rust and C docs (#1507)
1 parentb6d6cb3 commitab83832

File tree

5 files changed

+71
-31
lines changed

5 files changed

+71
-31
lines changed

‎pgml-cms/docs/api/client-sdk/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ async fn main() -> Result<(), Error> {
9999
{% endtab %}
100100

101101
{% tab title="C" %}
102-
```c
102+
```cpp
103103
#include<stdio.h>
104104
#include"pgml.h"
105105

@@ -176,7 +176,7 @@ collection.add_pipeline(&mut pipeline).await?;
176176
{% endtab %}
177177

178178
{% tab title="C" %}
179-
```c
179+
```cpp
180180
// Add this code to the end of the main function from the above example.
181181
PipelineC * pipeline = pgml_pipelinec_new("sample_pipeline","{\"text\": {\"splitter\": {\"model\":\"recursive_character\"},\"semantic_search\": {\"model\":\"Alibaba-NLP/gte-base-en-v1.5\"}}}");
182182

@@ -251,7 +251,7 @@ collection.upsert_documents(documents, None).await?;
251251
{% endtab %}
252252

253253
{% tab title="C" %}
254-
```c
254+
```cpp
255255
// Add this code to the end of the main function in the above example.
256256
char * documents_to_upsert[2] = {"{\"id\":\"Document One\",\"text\":\"document one contents...\"}", "{\"id\":\"Document Two\",\"text\":\"document two contents...\"}"};
257257

@@ -334,7 +334,7 @@ Ok(())
334334
{% endtab %}
335335

336336
{% tab title="C" %}
337-
```c
337+
```cpp
338338
// Add this code to the end of the main function in the above example.
339339
r_size =0;
340340
char** results = pgml_collectionc_vector_search(collection,"{\"query\": {\"fields\": {\"text\": {\"query\":\"Something about a document...\"}}},\"limit\": 2}", pipeline, &r_size);

‎pgml-cms/docs/api/client-sdk/collections.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ let mut collection = Collection::new("test_collection", None)?;
3434
{% endtab %}
3535

3636
{% tab title="C" %}
37-
```c
37+
```cpp
3838
CollectionC * collection = pgml_collectionc_new("test_collection",NULL);
3939
```
4040
{% endtab %}
@@ -64,7 +64,7 @@ let mut collection = Collection::new("test_collection", Some(CUSTOM_DATABASE_URL
6464
{% endtab %}
6565

6666
{% tab title="C" %}
67-
```c
67+
```cpp
6868
CollectionC * collection = pgml_collectionc_new("test_collection", CUSTOM_DATABASE_URL);
6969
```
7070
{% endtab %}
@@ -138,7 +138,7 @@ collection.upsert_documents(documents, None).await?;
138138
{% endtab %}
139139

140140
{% tab title="C" %}
141-
```c
141+
```cpp
142142
char * documents[2] = {
143143
"{\"id\":\"document_one\",\"title\":\"Document One\",\"text\":\"Here are the contents of Document 1\",\"random_key\":\"here is some random data\"}",
144144
"{\"id\":\"document_two\",\"title\":\"Document Two\",\"text\":\"Here are the contents of Document 2\",\"random_key\":\"here is some random data\"}"
@@ -214,7 +214,7 @@ collection.upsert_documents(documents, None).await?;
214214
{% endtab %}
215215

216216
{% tab title="C" %}
217-
```c
217+
```cpp
218218
char * documents[2] = {
219219
"{\"id\":\"document_one\",\"title\":\"Document One\",\"text\":\"Here is some new text for document one\",\"random_key\":\"here is some random data\"}",
220220
"{\"id\":\"document_two\",\"title\":\"Document Two\",\"text\":\"Here is some new text for document two\",\"random_key\":\"here is some random data\"}"
@@ -288,7 +288,7 @@ collection
288288
{% endtab %}
289289

290290
{% tab title="C" %}
291-
```c
291+
```cpp
292292
char * documents[2] = {
293293
"{\"id\":\"document_one\",\"new_key\":\"this will be a new key in document one\",\"random_key\":\"this will replace old random_key\"}",
294294
"{\"id\":\"document_two\",\"new_key\":\"this will be a new key in document two\",\"random_key\":\"this will replace old random_key\"}"
@@ -324,7 +324,7 @@ let documents = collection
324324
{% endtab %}
325325

326326
{% tab title="C" %}
327-
```c
327+
```cpp
328328
unsignedlong r_size =0;
329329
char** documents = pgml_collectionc_get_documents(collection,"{\"limit\": 100}", &r_size);
330330
```
@@ -359,7 +359,7 @@ let documents = collection
359359
{% endtab %}
360360

361361
{% tab title="C" %}
362-
```c
362+
```cpp
363363
unsignedlong r_size =0;
364364
char** documents = pgml_collectionc_get_documents(collection,"{\"limit\": 100,\"offset\": 10}", &r_size);
365365
```
@@ -390,7 +390,7 @@ let documents = collection
390390
{% endtab %}
391391

392392
{% tab title="C" %}
393-
```c
393+
```cpp
394394
unsignedlong r_size =0;
395395
char** documents = pgml_collectionc_get_documents(collection,"{\"limit\": 100,\"last_row_id\": 10}", &r_size);
396396
```
@@ -447,7 +447,7 @@ let documents = collection
447447
{% endtab %}
448448

449449
{% tab title="C" %}
450-
```c
450+
```cpp
451451
unsignedlong r_size =0;
452452
char** documents = pgml_collectionc_get_documents(collection,"{\"limit\": 100,\"filter\": {\"id\": {\"$eq\":\"document_one\"}}}", &r_size);
453453
```
@@ -501,7 +501,7 @@ let documents = collection
501501
{% endtab %}
502502

503503
{% tab title="C" %}
504-
```c
504+
```cpp
505505
unsignedlong r_size =0;
506506
char** documents = pgml_collectionc_get_documents(collection,"{\"limit\": 100,\"offset\": 10,\"order_by\": {\"id\":\"desc\"}}", &r_size);
507507
```
@@ -549,7 +549,7 @@ let documents = collection
549549
{% endtab %}
550550

551551
{% tab title="C" %}
552-
```c
552+
```cpp
553553
pgml_collectionc_delete_documents(collection, "{\"id\": {\"$eq\": 1}}");
554554
```
555555
{% endtab %}

‎pgml-cms/docs/api/client-sdk/document-search.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ collection.add_pipeline(&mut pipeline).await?;
7979
{% endtab %}
8080

8181
{% tab title="C" %}
82-
```c
82+
```cpp
8383
PipelineC *pipeline = pgml_pipelinec_new("test_pipeline","{\
8484
\"abstract\": {\
8585
\"semantic_search\": {\
@@ -192,7 +192,7 @@ let results = collection
192192
{% endtab %}
193193

194194
{% tab title="C" %}
195-
```c
195+
```cpp
196196
char * results = pgml_collectionc_search(collection,"\
197197
\"query\": {\
198198
\"full_text_search\": {\

‎pgml-cms/docs/api/client-sdk/pipelines.md

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ let mut pipeline = Pipeline::new(
8282
{% endtab %}
8383

8484
{% tab title="C" %}
85-
```c
85+
```cpp
8686
PipelineC * pipeline = pgml_pipelinec_new(
8787
"test_pipeline",
8888
"{\
@@ -156,7 +156,7 @@ let mut pipeline = Pipeline::new(
156156
{% endtab %}
157157

158158
{% tab title="C" %}
159-
```c
159+
```cpp
160160
PipelineC * pipeline = pgml_pipelinec_new(
161161
"test_pipeline",
162162
"{\
@@ -174,6 +174,8 @@ PipelineC * pipeline = pgml_pipelinec_new(
174174

175175
This`Pipeline` splits and embeds the`body` text enabling semantic search using vectors. This is a very popular`Pipeline` for RAG.
176176

177+
###Switching from OpenAI
178+
177179
We support most every open source model on[Hugging Face](https://huggingface.co/), and OpenAI's embedding models. To use a model from OpenAI specify the`source` as`openai`, and make sure and set the environment variable`OPENAI_API_KEY`.
178180

179181
{% tabs %}
@@ -204,6 +206,44 @@ pipeline = Pipeline(
204206
)
205207
```
206208
{% endtab %}
209+
210+
{% tab title="Rust" %}
211+
```rust
212+
letmutpipeline=Pipeline::new(
213+
"test_pipeline",
214+
Some(
215+
serde_json::json!({
216+
"body": {
217+
"splitter": {"model":"recursive_character"},
218+
"semantic_search": {
219+
"model":"text-embedding-ada-002",
220+
"source":"openai"
221+
},
222+
},
223+
})
224+
.into(),
225+
),
226+
)?;
227+
228+
```
229+
{% endtab %}
230+
231+
{% tab title="C" %}
232+
```cpp
233+
PipelineC * pipeline = pgml_pipelinec_new(
234+
"test_pipeline",
235+
"{\
236+
\"body\": {\
237+
\"splitter\": {\"model\":\"recursive_character\"},\
238+
\"semantic_search\": {\
239+
\"model\":\"text-embedding-ada-002\",\
240+
\"source\":\"openai\"\
241+
}\
242+
}\
243+
}"
244+
);
245+
```
246+
{% endtab %}
207247
{% endtabs %}
208248

209249
##Customizing the Indexes
@@ -267,7 +307,7 @@ let mut pipeline = Pipeline::new(
267307
{% endtab %}
268308

269309
{% tab title="C" %}
270-
```c
310+
```cpp
271311
PipelineC * pipeline = pgml_pipelinec_new(
272312
"test_pipeline",
273313
"{\
@@ -308,7 +348,7 @@ collection.add_pipeline(&mut pipeline).await?;
308348
{% endtab %}
309349

310350
{% tab title="C" %}
311-
```c
351+
```cpp
312352
pgml_collectionc_add_pipeline(collection, pipeline);
313353
```
314354
{% endtab %}
@@ -336,7 +376,7 @@ let mut pipeline = Pipeline::new("test_pipeline", None)?;
336376
{% endtab %}
337377

338378
{% tab title="C" %}
339-
```c
379+
```cpp
340380
PipelineC * pipeline = pgml_pipelinec_new("test_pipeline",NULL);
341381
```
342382
{% endtab %}
@@ -381,7 +421,7 @@ collection.disable_pipeline(&mut pipeline).await?;
381421
{% endtab %}
382422

383423
{% tab title="C" %}
384-
```c
424+
```cpp
385425
CollectionC * collection = pgml_collectionc_new("test_collection",NULL);
386426
PipelineC * pipeline = pgml_pipelinec_new("test_pipeline",NULL);
387427
pgml_collectionc_disable_pipeline(collection, pipeline);
@@ -421,7 +461,7 @@ collection.enable_pipeline(&mut pipeline).await?;
421461
{% endtab %}
422462

423463
{% tab title="C" %}
424-
```c
464+
```cpp
425465
CollectionC * collection = pgml_collectionc_new("test_collection",NULL);
426466
PipelineC * pipeline = pgml_pipelinec_new("test_pipeline",NULL);
427467
pgml_collectionc_enable_pipeline(collection, pipeline);
@@ -459,7 +499,7 @@ collection.remove_pipeline(&mut pipeline).await?;
459499
{% endtab %}
460500

461501
{% tab title="C" %}
462-
```c
502+
```cpp
463503
CollectionC * collection = pgml_collectionc_new("test_collection",NULL);
464504
PipelineC * pipeline = pgml_pipelinec_new("test_pipeline",NULL);
465505
pgml_collectionc_remove_pipeline(collection, pipeline);

‎pgml-cms/docs/api/client-sdk/search.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ collection.add_pipeline(&mut pipeline).await?;
8080
{% endtab %}
8181

8282
{% tab title="C" %}
83-
```c
83+
```cpp
8484
PipelineC *pipeline = pgml_pipelinec_new("test_pipeline","{\
8585
\"abstract\": {\
8686
\"semantic_search\": {\
@@ -173,7 +173,7 @@ let results = collection
173173
{% endtab %}
174174

175175
{% tab title="C" %}
176-
```c
176+
```cpp
177177
r_size =0;
178178
char **results = pgml_collectionc_vector_search(collection,"{\
179179
\"query\": {\
@@ -283,7 +283,7 @@ let results = collection
283283
{% endtab %}
284284

285285
{% tab title="C" %}
286-
```c
286+
```cpp
287287
r_size =0;
288288
char **results = pgml_collectionc_vector_search(collection,"{\
289289
\"query\": {\
@@ -389,7 +389,7 @@ let results = collection
389389
{% endtab %}
390390

391391
{% tab title="C" %}
392-
```c
392+
```cpp
393393
r_size =0;
394394
char **results = pgml_collectionc_vector_search(collection,"{\
395395
\"query\": {\
@@ -488,7 +488,7 @@ let results = collection
488488
{% endtab %}
489489

490490
{% tab title="C" %}
491-
```c
491+
```cpp
492492
r_size =0;
493493
char **results = pgml_collectionc_vector_search(collection,"{\
494494
\"query\": {\
@@ -615,7 +615,7 @@ let results = collection
615615
{% endtab %}
616616

617617
{% tab title="C" %}
618-
```c
618+
```cpp
619619
r_size =0;
620620
char **results = pgml_collectionc_vector_search(collection,"{\
621621
\"query\": {\

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp