ソースを参照

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

* docs without usage

* no usage

* rm metric note
royjhan 9 ヶ月 前
コミット
558a54b098
1 ファイル変更31 行追加0 行削除
  1. 31 0
      docs/openai.md

+ 31 - 0
docs/openai.md

@@ -31,6 +31,11 @@ chat_completion = client.chat.completions.create(
 list_completion = client.models.list()
 
 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
@@ -53,6 +58,11 @@ const chatCompletion = await openai.chat.completions.create({
 const listCompletion = await openai.models.list()
 
 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`
@@ -77,6 +87,13 @@ curl http://localhost:11434/v1/chat/completions \
 curl http://localhost:11434/v1/models
 
 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
@@ -128,6 +145,20 @@ curl https://api.openai.com/v1/models/llama3
 - `created` corresponds to when the model was last modified
 - `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
 
 Before using a model, pull it locally `ollama pull`: