This repository was archived by the owner on Oct 10, 2025. It is now read-only.
-
Couldn't load subscription status.
- Fork 33
Add docs for LLM Extension #520
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
64dab00
Work on docs
tgahunia05 4ab7294
work on docs
tgahunia05 6a902ef
work on docs
tgahunia05 cfd34e5
Use similar language to other extension docs
tgahunia05 3458e05
Update fcn signature and region/model related notes
tgahunia05 d35ae0e
NIT
tgahunia05 aea7f46
Update to reflect region specification
tgahunia05 41648be
Provide example with vector ext
tgahunia05 38c78f2
Add result to synergy example
tgahunia05 5d396d4
Update docs with PR feedback
tgahunia05 cc530e4
Update src/content/docs/extensions/llm.mdx
tgahunia05 c916531
Update src/content/docs/extensions/llm.mdx
tgahunia05 6ad5d4c
Update src/content/docs/extensions/llm.mdx
tgahunia05 1453626
Update src/content/docs/extensions/llm.mdx
tgahunia05 781555d
Update src/content/docs/extensions/llm.mdx
tgahunia05 33e6ae3
Update src/content/docs/extensions/llm.mdx
tgahunia05 d6fe678
Update src/content/docs/extensions/llm.mdx
tgahunia05 331dd3e
Apply PR feedback
tgahunia05 cde2178
Retire arg: type form to document syntax
tgahunia05 dd007e0
NIT
tgahunia05 3c72603
Fix incorrect provider in example
tgahunia05 15901d3
Apply PR feedback
tgahunia05 771e9dc
Copyedit
sdht0 0fdf4a9
correct invalid optional param syntax, add env var example
tgahunia05 ba5d1cc
Need to init conn before using it
tgahunia05 e71a2aa
Add one more example where create embedding can be used, update filte…
tgahunia05 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| --- | ||
| title: "LLM Extension" | ||
| --- | ||
|
|
||
| import { Tabs, TabItem } from '@astrojs/starlight/components'; | ||
|
|
||
| The **LLM extension** provides a `CREATE_EMBEDDING` function for creating text embeddings using API calls to supported providers. | ||
|
|
||
| We currently support the following providers: | ||
|
|
||
| * [OpenAI](https://platform.openai.com/docs/guides/embeddings) | ||
| * [Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/titan-embedding-models.html) | ||
| * [Google Vertex](https://cloud.google.com/vertex-ai/generative-ai/docs/embeddings/get-text-embeddings) | ||
| * [Google Gemini](https://ai.google.dev/gemini-api/docs/embeddings) | ||
| * [Voyage AI](https://docs.voyageai.com/docs/embeddings) | ||
| * [Ollama](https://ollama.com/blog/embedding-models) | ||
| --- | ||
|
|
||
| ## Usage | ||
|
|
||
| Install and load the extension using the following commands: | ||
|
|
||
| ```sql | ||
| INSTALL llm; | ||
| LOAD llm; | ||
| ``` | ||
|
|
||
| ### Configuration | ||
|
|
||
| To allow API calls to the providers, you must set the appropriate environment variables: | ||
|
|
||
| | Provider | Required Environment Variables | | ||
| | --- | --- | | ||
| | `amazon-bedrock` | `AWS_ACCESS_KEY`, `AWS_SECRET_ACCESS_KEY` | | ||
| | `google-vertex` | `GOOGLE_CLOUD_PROJECT_ID`, `GOOGLE_VERTEX_ACCESS_KEY` | | ||
| | `google-gemini` | `GOOGLE_GEMINI_API_KEY` | | ||
| | `open-ai` | `OPENAI_API_KEY` | | ||
| | `voyage-ai` | `VOYAGE_API_KEY` | | ||
| | `ollama` | None, but expects access to `http://localhost:11434` | | ||
|
|
||
| See how to set environment variables below: | ||
|
|
||
| <Tabs> | ||
| <TabItem value="cypher" label="Cypher"> | ||
|
|
||
| ```bash | ||
| # Set the OpenAI API key | ||
| export OPENAI_API_KEY=sk-proj-key | ||
| ``` | ||
|
|
||
| </TabItem> | ||
|
|
||
| <TabItem value="python" label="Python"> | ||
| ```python | ||
| os.environ["OPENAI_API_KEY"] = "sk-proj-key" | ||
| #... | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| ## Creating embeddings | ||
|
|
||
| You can generate text embeddings using the `CREATE_EMBEDDING` function. The function returns a `LIST[FLOAT]` type. | ||
|
|
||
| ```sql | ||
| CALL CREATE_EMBEDDING( | ||
| 'prompt', // The input text to embed. | ||
| 'provider', // The embedding provider. E.g., `'open-ai'`. | ||
| 'model', // The identifier of the embedding model. E.g., `'text-embedding-3-small'`. | ||
| // Optional parameters, if supported by the provider. | ||
| ); | ||
| ``` | ||
|
|
||
| ### Optional parameters | ||
|
|
||
| | Option |Type| Description | | ||
| |--------|------|-------| | ||
| | dimensions |`INT64`| The size of the embedding vector, if supported by the provider. Currently only `'open-ai'`, `'google-vertex'`, and `'voyage-ai'` support this option. | | ||
| | region |`STRING`| A region or endpoint, if supported by the provider. E.g., `'us-east-1'` for `'amazon-bedrock'`. | | ||
|
|
||
| :::note[Note] | ||
| If an unsupported model, dimension, or region is specified, the API call to the provider will fail. Check the provider's API documentation for the currently supported options. | ||
| ::: | ||
|
|
||
| ### Examples | ||
|
|
||
| ```sql | ||
| CALL CREATE_EMBEDDING("Hello world", "open-ai", "text-embedding-3-small"); | ||
|
|
||
| CALL CREATE_EMBEDDING("Hello world", "ollama", "nomic-embed-text"); | ||
|
|
||
| CALL CREATE_EMBEDDING("Hello world", "google-gemini", "gemini-embedding-exp-03-07"); | ||
| ``` | ||
|
|
||
| With optional parameters: | ||
|
|
||
| ```sql | ||
| CALL CREATE_EMBEDDING("Hello world", "voyage-ai", "voyage-3-large", 512); | ||
|
|
||
| CALL CREATE_EMBEDDING("Hello world", "amazon-bedrock", "amazon.titan-embed-text-v1", "us-east-1"); | ||
|
|
||
| CALL CREATE_EMBEDDING("Hello world", "google-vertex", "gemini-embedding-001", 256, "us-east1"); | ||
| ``` | ||
| --- | ||
|
|
||
| ## Storing embeddings in a vector index | ||
|
|
||
| The embedding function can be used with the `vector` extension. The example in the [vector docs](/extensions/vector) shows how the `CREATE_EMBEDDING` function can be used to create the embeddings needed for the vector index directly in Kuzu. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.