Skip to content

Commit 362628b

Browse files
committed
Initial commit
1 parent 86249d5 commit 362628b

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This repository contains example code to demonstrate how to connect MATLAB to the OpenAI™ Chat Completions API (which powers ChatGPT™). This allows you to leverage the natural language processing capabilities of GPT models directly within your MATLAB environment.
44

5-
The functionality shown here simply serve as an interface to the ChatGPT API. You should be familiar with the limitations and risks associated with using this technology as well as with [OpenAI terms and policies](https://openai.com/policies). You are responsible for any fees OpenAI may charge for the use of their API.
5+
The functionality shown here simply serves as an interface to the ChatGPT API. You should be familiar with the limitations and risks associated with using this technology as well as with [OpenAI terms and policies](https://openai.com/policies). You are responsible for any fees OpenAI may charge for the use of their API.
66

77
## Setup
88
1. Clone the repository to your local machine.
@@ -43,22 +43,23 @@ To get started, you can either create an `openAIChat` object and use its methods
4343

4444
### Simple call without preserving chat history
4545

46-
In some situations, you will want to use GPT models without preserving chat history. For example, when you want to perform independent queries in a programatic way.
46+
In some situations, you will want to use GPT models without preserving chat history. For example, when you want to perform independent queries in a programmatic way.
4747

4848
Here's a simple example of how to use the `openAIChat` for sentiment analysis:
4949
5050
```matlab
5151
% Initialize the OpenAI Chat object, passing a system prompt
5252
5353
% The system prompt tells the assistant how to behave, in this case, as a sentiment analyzer
54-
systemPrompt = "You are a sentiment analyser, you will look at a sentence and output a single word that classifier that sentence (positive or negative)."+....
54+
systemPrompt = "You are a sentiment analyser. You will look at a sentence and output"+...
55+
" a single word that classifies that sentence as either 'positive' or 'negative'."+....
5556
"Examples: \n"+...
56-
"The project was a complete failure.\n"+...
57-
"negative\n\n"+...
57+
"The project was a complete failure. \n"+...
58+
"negative \n\n"+...
5859
"The team successfully completed the project ahead of schedule."+...
59-
"positive\n\n"+...
60-
"His attitude was terribly discouraging to the team.\n"+...
61-
"negative\n\n";
60+
"positive \n\n"+...
61+
"His attitude was terribly discouraging to the team. \n"+...
62+
"negative \n\n";
6263
6364
chat = openAIChat(systemPrompt);
6465
@@ -90,7 +91,7 @@ history = addUserMessage(history, "What is an eigenvalue?");
9091
[text, response] = generate(chat, history)
9192
```
9293
93-
The output `text` will contain the answer and `response` will contain the full response, which you need to include in the hystory as follows
94+
The output `text` will contain the answer and `response` will contain the full response, which you need to include in the history as follows
9495
```matlab
9596
history = addResponseMessage(history, response);
9697
```
@@ -121,7 +122,7 @@ Then you can pass the functions to the chat API as follows:
121122
122123
```matlab
123124
chat = openAIChat("You are a helpful assistant", Functions=f);
124-
````
125+
```
125126
126127
The model will automatically determine if the function should be called based on the user input:
127128

0 commit comments

Comments
 (0)