Skip to content

Commit ada0ff8

Browse files
Update openAIChat documentation.
1 parent b0f15e2 commit ada0ff8

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

doc/functions/openAIChat.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Connect to OpenAI™ Chat Completion API
1919

2020
## Description
2121

22-
Connect to the OpenAI Chat Completion API to generate text using large language models developed by OpenAI.
22+
Connect to the OpenAI Chat Completion API to generate text using large language models developed by OpenAI.
2323

2424

2525
To connect to the OpenAI API, you need a valid API key. For information on how to obtain an API key, see [https://platform.openai.com/docs/quickstart](https://platform.openai.com/docs/quickstart).
@@ -56,7 +56,7 @@ character vector | string scalar
5656
OpenAI API key to access OpenAI APIs such as ChatGPT.
5757

5858

59-
Instead of using the `APIKey` name\-value argument, you can also set the environment variable OPEN\_API\_KEY. For more information, see [https://github.com/matlab\-deep\-learning/llms\-with\-matlab/blob/main/doc/OpenAI.md](https://github.com/matlab-deep-learning/llms-with-matlab/blob/main/doc/OpenAI.md).
59+
Instead of using the `APIKey` name\-value argument, you can also set the environment variable OPEN\_API\_KEY. For more information, see [OpenAI API](../OpenAI.md).
6060

6161
### `ModelName` \- Model name
6262

@@ -66,7 +66,7 @@ Instead of using the `APIKey` name\-value argument, you can also set the environ
6666
Name of the OpenAI model to use for text or image generation.
6767

6868

69-
For a list of currently supported models, see [https://github.com/matlab\-deep\-learning/llms\-with\-matlab/blob/main/doc/OpenAI.md](https://github.com/matlab-deep-learning/llms-with-matlab/blob/main/doc/OpenAI.md).
69+
For a list of currently supported models, see [OpenAI API](../OpenAI.md).
7070

7171
### `Temperature` \- Temperature
7272

@@ -152,7 +152,7 @@ If you set the response format to `"json"`, then the generated output is a JSON
152152
- `ModelName="gpt-4"`
153153
- `ModelName="gpt-4-0613"`
154154

155-
To configure the format of the generated JSON file, describe the format using natural language and provide it to the model either in the system prompt or as a user message. For an example, see [Analyze Sentiment in Text Using ChatGPT in JSON Mode](https://github.com/matlab-deep-learning/llms-with-matlab/blob/main/examples/AnalyzeSentimentinTextUsingChatGPTinJSONMode.md).
155+
To configure the format of the generated JSON file, describe the format using natural language and provide it to the model either in the system prompt or as a user message. For an example, see [Analyze Sentiment in Text Using ChatGPT in JSON Mode](../../examples/AnalyzeSentimentinTextUsingChatGPTinJSONMode.md).
156156

157157
# Properties
158158
### `SystemPrompt` \- System prompt
@@ -176,7 +176,7 @@ The system prompt is a natural\-language description that provides the framework
176176
Name of the OpenAI model to use for text or image generation.
177177

178178

179-
For a list of currently supported models, see [https://github.com/matlab\-deep\-learning/llms\-with\-matlab/blob/main/doc/OpenAI.md](https://github.com/matlab-deep-learning/llms-with-matlab/blob/main/doc/OpenAI.md).
179+
For a list of currently supported models, see [OpenAI API](../OpenAI.md).
180180

181181
### `Temperature` \- Temperature
182182

@@ -190,7 +190,7 @@ Temperature value for controlling the randomness of the output. Higher temperatu
190190
`1` (default) | numeric scalar between `0` and `1`
191191

192192

193-
Top probability mass for controlling the diversity of the generated output. Higher top probability mass corresponds to higher diversity.
193+
Top probability mass for controlling the diversity of the generated output using top-p sampling. Higher top probability mass corresponds to higher diversity.
194194

195195
### `StopSequences` \- Stop sequences
196196

@@ -246,13 +246,20 @@ Format of generated output.
246246
If the response format is `"text"`, then the generated output is a string.
247247

248248

249-
If the response format is `"json"`, then the generated output is a JSON (\*.json) file. This option is not supported for these models:
249+
If the response format is `"json"`, then the generated output is a string containing JSON encoded data.
250+
251+
252+
To configure the format of the generated JSON file, describe the format using natural language and provide it to the model either in the system prompt or as a user message. The prompt or message describing the format must contain the word `"json"` or `"JSON"`.
253+
254+
255+
For an example, see [Analyze Sentiment in Text Using ChatGPT in JSON Mode](../../examples/AnalyzeSentimentinTextUsingChatGPTinJSONMode.md).
256+
257+
258+
The JSON response format is not supported for these models:
250259

251260
- `ModelName="gpt-4"`
252261
- `ModelName="gpt-4-0613"`
253262

254-
To configure the format of the generated JSON file, describe the format using natural language and provide it to the model either in the system prompt or as a user message. For an example, see [Analyze Sentiment in Text Using ChatGPT in JSON Mode](https://github.com/matlab-deep-learning/llms-with-matlab/blob/main/examples/AnalyzeSentimentinTextUsingChatGPTinJSONMode.md).
255-
256263
### `FunctionNames` \- Names of OpenAI functions to use during output generation
257264

258265
string array
@@ -280,10 +287,9 @@ chat = openAIChat(StreamFun=sf);
280287
generate(chat,"Why is a raven like a writing desk?")
281288
```
282289
# See Also
283-
- [Create Simple Chat Bot](https://github.com/matlab-deep-learning/llms-with-matlab/blob/main/examples/CreateSimpleChatBot.md)
284-
- [Process Generated Text in Real Time Using ChatGPT in Streaming Mode](https://github.com/matlab-deep-learning/llms-with-matlab/blob/main/examples/ProcessGeneratedTextinRealTimebyUsingChatGPTinStreamingMode.md)
285-
- [Analyze Scientific Papers Using Function Calls](https://github.com/matlab-deep-learning/llms-with-matlab/blob/main/examples/AnalyzeScientificPapersUsingFunctionCalls.md)
286-
- [Analyze Sentiment in Text Using ChatGPT in JSON Mode](https://github.com/matlab-deep-learning/llms-with-matlab/blob/main/examples/AnalyzeSentimentinTextUsingChatGPTinJSONMode.md)
287-
288-
Copyright 2024 The MathWorks, Inc.
290+
- [Create Simple Chat Bot](../../examples/CreateSimpleChatBot.md)
291+
- [Process Generated Text in Real Time Using ChatGPT in Streaming Mode](../../examples/ProcessGeneratedTextinRealTimebyUsingChatGPTinStreamingMode.md)
292+
- [Analyze Scientific Papers Using Function Calls](../../examples/AnalyzeScientificPapersUsingFunctionCalls.md)
293+
- [Analyze Sentiment in Text Using ChatGPT in JSON Mode](../../examples/AnalyzeSentimentinTextUsingChatGPTinJSONMode.md)
289294

295+
Copyright 2024 The MathWorks, Inc.

0 commit comments

Comments
 (0)