瀏覽代碼

update the openai docs to explain how to set the context size (#6548)

Patrick Devine 8 月之前
父節點
當前提交
8e4e509fa4
共有 1 個文件被更改,包括 25 次插入0 次删除
  1. 25 0
      docs/openai.md

+ 25 - 0
docs/openai.md

@@ -300,3 +300,28 @@ curl http://localhost:11434/v1/chat/completions \
         ]
         ]
     }'
     }'
 ```
 ```
+
+### Setting the context size
+
+The OpenAI API does not have a way of setting the context size for a model. If you need to change the context size, create a `Modelfile` which looks like:
+
+```modelfile
+FROM <some model>
+PARAMETER num_ctx <context size>
+```
+
+Use the `ollama create mymodel` command to create a new model with the updated context size. Call the API with the updated model name:
+
+```shell
+curl http://localhost:11434/v1/chat/completions \
+    -H "Content-Type: application/json" \
+    -d '{
+        "model": "mymodel",
+        "messages": [
+            {
+                "role": "user",
+                "content": "Hello!"
+            }
+        ]
+    }'
+```