Skip to content

Commit

Permalink
Merge pull request #2853 from redpanda-data/examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rockwotj authored Sep 10, 2024
2 parents 4147e54 + d0d911d commit d926fab
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 2 deletions.
30 changes: 30 additions & 0 deletions docs/modules/components/pages/processors/ollama_embeddings.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,36 @@ By default, the processor starts and runs a locally installed Ollama server. Alt
For more information, see the https://github.com/ollama/ollama/tree/main/docs[Ollama documentation^].
== Examples
[tabs]
======
Store embedding vectors in Qdrant::
+
--
Compute embeddings for some generated data and store it within xrefs:component:outputs/qdrant.adoc[Qdrant]
```yamlinput:
generate:
interval: 1s
mapping: |
root = {"text": fake("paragraph")}
pipeline:
processors:
- ollama_embeddings:
model: snowflake-artic-embed
text: "${!this.text}"
output:
qdrant:
grpc_host: localhost:6334
collection_name: "example_collection"
id: "root = uuid_v4()"
vector_mapping: "root = this"```
--
======
== Fields
=== `model`
Expand Down
31 changes: 31 additions & 0 deletions docs/modules/components/pages/processors/openai_embeddings.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,37 @@ This processor sends text strings to the OpenAI API, which generates vector embe
To learn more about vector embeddings, see the https://platform.openai.com/docs/guides/embeddings[OpenAI API documentation^].
== Examples
[tabs]
======
Store embedding vectors in Pinecone::
+
--
Compute embeddings for some generated data and store it within xrefs:component:outputs/pinecone.adoc[Pinecone]
```yamlinput:
generate:
interval: 1s
mapping: |
root = {"text": fake("paragraph")}
pipeline:
processors:
- openai_embeddings:
model: text-embedding-3-large
api_key: "${OPENAI_API_KEY}"
text_mapping: "root = this.text"
output:
pinecone:
host: "${PINECONE_HOST}"
api_key: "${PINECONE_API_KEY}"
id: "root = uuid_v4()"
vector_mapping: "root = this"```
--
======
== Fields
=== `server_address`
Expand Down
21 changes: 20 additions & 1 deletion internal/impl/ollama/embeddings_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,26 @@ For more information, see the https://github.com/ollama/ollama/tree/main/docs[Ol
service.NewInterpolatedStringField(oepFieldText).
Description("The text you want to create vector embeddings for. By default, the processor submits the entire payload as a string.").
Optional(),
).Fields(commonFields()...)
).Fields(commonFields()...).
Example(
"Store embedding vectors in Qdrant",
"Compute embeddings for some generated data and store it within xrefs:component:outputs/qdrant.adoc[Qdrant]",
`input:
generate:
interval: 1s
mapping: |
root = {"text": fake("paragraph")}
pipeline:
processors:
- ollama_embeddings:
model: snowflake-artic-embed
text: "${!this.text}"
output:
qdrant:
grpc_host: localhost:6334
collection_name: "example_collection"
id: "root = uuid_v4()"
vector_mapping: "root = this"`)
}

func makeOllamaEmbeddingProcessor(conf *service.ParsedConfig, mgr *service.Resources) (service.Processor, error) {
Expand Down
22 changes: 21 additions & 1 deletion internal/impl/openai/embeddings_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,27 @@ To learn more about vector embeddings, see the https://platform.openai.com/docs/
service.NewIntField(oepFieldDims).
Description("The number of dimensions the resulting output embeddings should have. Only supported in `text-embedding-3` and later models.").
Optional(),
)
).
Example(
"Store embedding vectors in Pinecone",
"Compute embeddings for some generated data and store it within xrefs:component:outputs/pinecone.adoc[Pinecone]",
`input:
generate:
interval: 1s
mapping: |
root = {"text": fake("paragraph")}
pipeline:
processors:
- openai_embeddings:
model: text-embedding-3-large
api_key: "${OPENAI_API_KEY}"
text_mapping: "root = this.text"
output:
pinecone:
host: "${PINECONE_HOST}"
api_key: "${PINECONE_API_KEY}"
id: "root = uuid_v4()"
vector_mapping: "root = this"`)
}

func makeEmbeddingsProcessor(conf *service.ParsedConfig, mgr *service.Resources) (service.Processor, error) {
Expand Down

0 comments on commit d926fab

Please sign in to comment.