Update OpenAI Compatibility Docs with /v1/embeddings (#5470)

* docs without usage

* no usage

* rm metric note
This commit is contained in:
royjhan 2024-08-01 19:00:29 -04:00 committed by GitHub
parent ed52833bb1
commit 558a54b098
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,6 +31,11 @@ chat_completion = client.chat.completions.create(
list_completion = client.models.list() list_completion = client.models.list()
model = client.models.retrieve("llama3") model = client.models.retrieve("llama3")
embeddings = client.embeddings.create(
model="all-minilm",
input=["why is the sky blue?", "why is the grass green?"]
)
``` ```
### OpenAI JavaScript library ### OpenAI JavaScript library
@ -53,6 +58,11 @@ const chatCompletion = await openai.chat.completions.create({
const listCompletion = await openai.models.list() const listCompletion = await openai.models.list()
const model = await openai.models.retrieve("llama3"); const model = await openai.models.retrieve("llama3");
const embedding = await openai.embeddings.create({
model: "all-minilm",
input: ["why is the sky blue?", "why is the grass green?"],
});
``` ```
### `curl` ### `curl`
@ -77,6 +87,13 @@ curl http://localhost:11434/v1/chat/completions \
curl http://localhost:11434/v1/models curl http://localhost:11434/v1/models
curl https://api.openai.com/v1/models/llama3 curl https://api.openai.com/v1/models/llama3
curl http://localhost:11434/v1/embeddings \
-H "Content-Type: application/json" \
-d '{
"model": "all-minilm",
"input": ["why is the sky blue?", "why is the grass green?"]
}'
``` ```
## Endpoints ## Endpoints
@ -128,6 +145,20 @@ curl https://api.openai.com/v1/models/llama3
- `created` corresponds to when the model was last modified - `created` corresponds to when the model was last modified
- `owned_by` corresponds to the ollama username, defaulting to `"library"` - `owned_by` corresponds to the ollama username, defaulting to `"library"`
### `/v1/embeddings`
#### Supported request fields
- [x] `model`
- [x] `input`
- [x] string
- [x] array of strings
- [ ] array of tokens
- [ ] array of token arrays
- [ ] `encoding format`
- [ ] `dimensions`
- [ ] `user`
## Models ## Models
Before using a model, pull it locally `ollama pull`: Before using a model, pull it locally `ollama pull`: