mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-13 14:16:54 +00:00
Allow OpenAIEmbeddings.ndims() to use an explicitly configured dim for model names outside the three built-in OpenAI names, so schemas can be built for compatible models. Preserve existing model defaults and request behavior. Add regression coverage for the resulting Arrow schema dimensions and for all known OpenAI model dimensions.
26 lines
1.1 KiB
Plaintext
26 lines
1.1 KiB
Plaintext
---
|
|
title: OpenAI
|
|
sidebarTitle: OpenAI
|
|
---
|
|
|
|
import { PyEmbeddingOpenaiBasic } from '/snippets/integrations.mdx';
|
|
|
|
LanceDB registers the OpenAI embeddings function in the registry by default, as `openai`. Below are the parameters that you can customize when creating the instances:
|
|
|
|
| Parameter | Type | Default Value | Description |
|
|
|---|---|---|---|
|
|
| `name` | `str` | `"text-embedding-ada-002"` | The name of the model. |
|
|
| `dim` | `int` | Model default | Requested output dimensions for models that support shortening embeddings. Required for model names other than the OpenAI ones listed by `model_names()` (for example a model served behind an OpenAI-compatible `base_url`), where it is the model's embedding dimension. Use `func.ndims()` when defining the vector field. |
|
|
| `use_azure` | bool | `False` | Set true to use Azure OpenAI SDK |
|
|
|
|
Set your OpenAI API key before running the example:
|
|
|
|
```shell
|
|
export OPENAI_API_KEY="your-api-key"
|
|
```
|
|
|
|
<CodeGroup>
|
|
<CodeBlock filename="Python" language="Python" icon="python">
|
|
{PyEmbeddingOpenaiBasic}
|
|
</CodeBlock>
|
|
</CodeGroup> |