From 8e4e509fa4e8e1c49cedfc2754e9a0c9ed0f2fae Mon Sep 17 00:00:00 2001 From: Patrick Devine Date: Wed, 28 Aug 2024 17:11:46 -0700 Subject: [PATCH] update the openai docs to explain how to set the context size (#6548) --- docs/openai.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/openai.md b/docs/openai.md index 75d2c595..0cbea6cc 100644 --- a/docs/openai.md +++ b/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 +PARAMETER num_ctx +``` + +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!" + } + ] + }' +```