Skip to content

Commit 230ff4e

Browse files
hjh320MiriamScharnke
authored andcommitted
Make model choices explicit in Open AI examples
Co-authored-by: Miriam Scharnke <[email protected]>
1 parent 9ce1693 commit 230ff4e

12 files changed

+81
-37
lines changed

examples/AnalyzeScientificPapersUsingFunctionCalls.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ Set up the function to store paper details and initiate a chat with the OpenAI A
2525

2626
Define the function that you want the model to have access to. In this example the used function is `writePaperDetails`.
2727

28+
29+
This example uses the model gpt\-4.1\-mini.
30+
2831
```matlab
2932
f = openAIFunction("writePaperDetails", "Function to write paper details to a table.");
3033
f = addParameter(f, "name", type="string", description="Name of the paper.");
@@ -33,9 +36,9 @@ f = addParameter(f, "explanation", type="string", description="Explanation on wh
3336
3437
paperVerifier = openAIChat("You are an expert in filtering scientific papers. " + ...
3538
"Given a certain topic, you are able to decide if the paper" + ...
36-
" fits the given topic or not.");
39+
" fits the given topic or not.", ModelName="gpt-4.1-mini");
3740
38-
paperExtractor = openAIChat("You are an expert in extracting information from a paper.", Tools=f);
41+
paperExtractor = openAIChat("You are an expert in extracting information from a paper.", Tools=f, ModelName="gpt-4.1-mini");
3942
4043
function writePaperDetails(name, url, desc)
4144
filename = "papers_to_read.csv";

examples/AnalyzeSentimentinTextUsingChatGPTwithStructuredOutput.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ prototype = struct with fields:
5050
```
5151

5252

53-
Create a chat object and set `ResponseFormat` to `prototype`.
53+
Create a chat object and set `ResponseFormat` to `prototype`. This example uses the model GPT\-4.1 nano.
5454

5555
```matlab
56-
chat = openAIChat(systemPrompt, ResponseFormat=prototype);
56+
chat = openAIChat(systemPrompt, ResponseFormat=prototype, ModelName="gpt-4.1-nano");
5757
```
5858

5959
Concatenate the prompt and input text and generate an answer with the model.
@@ -84,12 +84,12 @@ T = movevars(T,"text","Before","sentiment")
8484
|:--:|:--:|:--:|:--:|
8585
|1|"I can't stand homework."|negative|0.9500|
8686
|2|"This sucks. I'm bored."|negative|0.9500|
87-
|3|"I can't wait for Halloween!!!"|positive|0.9500|
88-
|4|"I am neither for nor against the idea."|neutral|0.9500|
87+
|3|"I can't wait for Halloween!!!"|positive|0.8500|
88+
|4|"I am neither for nor against the idea."|neutral|0.9000|
8989
|5|"My cat is adorable ❤️❤️"|positive|0.9500|
9090
|6|"I hate chocolate"|negative|0.9500|
91-
|7|"More work. Great."|negative|0.8500|
92-
|8|"More work. Great!"|positive|0.9000|
91+
|7|"More work. Great."|negative|0.8000|
92+
|8|"More work. Great!"|positive|0.8000|
9393

9494

9595

examples/CreateSimpleChatBot.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ loadenv(".env")
2020
```
2121
# Setup Model
2222

23-
Set the maximum allowable number of words per chat session and define the keyword that, when entered by the user, ends the chat session. This example uses the model o1.
23+
Set the maximum allowable number of words per chat session and define the keyword that, when entered by the user, ends the chat session. This example uses the model GPT\-4.1 nano.
2424

2525
```matlab
2626
wordLimit = 2000;
2727
stopWord = "end";
28-
modelName = "o1";
28+
modelName = "gpt-4.1-nano";
2929
```
3030

3131
Create an instance of `openAIChat` to perform the chat and `messageHistory` to store the conversation history`.`
@@ -114,15 +114,15 @@ end
114114

115115
```matlabTextOutput
116116
User: Hello, how much do you know about physics?
117-
AI: I have broad knowledge spanning classical, relativistic, and quantum physics.
117+
AI: I know basics of physics, including classical mechanics, electromagnetism, thermodynamics, and modern physics.
118118
User: What is torque?
119-
AI: Torque is a measure of how a force causes rotational motion around an axis.
119+
AI: Torque is a measure of the rotational force applied to an object.
120120
User: What is force?
121-
AI: Force is an interaction that changes an object's state of motion.
121+
AI: Force is a push or pull that can cause an object to move or change motion.
122122
User: What is motion?
123123
AI: Motion is the change in an object's position over time.
124124
User: What is time?
125-
AI: Time is the dimension in which events occur sequentially from past to future.
125+
AI: Time is a measurable period during which events occur.
126126
User: end
127127
AI: Closing the chat. Have a great day!
128128
```

examples/ProcessGeneratedTextinRealTimebyUsingChatGPTinStreamingMode.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ To run this example, you need a valid API key from a paid OpenAI™ API account.
1919
```matlab
2020
loadenv(".env")
2121
```
22+
23+
This example uses the model GPT\-4.1 nano.
24+
2225
# Print Stream Directly to Screen
2326

2427
In this example, the streamed output is printed directly to the screen.
@@ -35,7 +38,7 @@ end
3538
Create the chat object with the defined function as a handle.
3639

3740
```matlab
38-
chat = openAIChat(StreamFun=@printToken);
41+
chat = openAIChat(StreamFun=@printToken, ModelName="gpt-4.1-nano");
3942
```
4043

4144
Generate response to a prompt in streaming mode.
@@ -46,7 +49,15 @@ generate(chat, prompt, MaxNumTokens=500);
4649
```
4750

4851
```matlabTextOutput
49-
Model-Based Design is an approach to system development that uses graphical models to design and simulate systems before implementing them in hardware or software. It involves creating models that represent the behavior and interactions of system components, and using these models to analyze, validate, and optimize the system before building it. Model-Based Design can help to improve the efficiency, reliability, and quality of system development by enabling engineers to explore design alternatives, detect errors early in the development process, and facilitate collaboration between different teams working on the same project.
52+
Model-Based Design (MBD) is a systematic methodology used in engineering and development processes where models—often graphical or mathematical representations—are employed to design, analyze, simulate, and verify complex systems before they are physically built. This approach enables engineers to visualize system behavior, perform simulations, and validate functionality early in the development cycle, thereby reducing costs, minimizing risks, and improving overall reliability.
53+
54+
Key aspects of Model-Based Design include:
55+
- **Creating high-level models** of system components and interactions
56+
- **Simulating system behavior** to evaluate performance under various conditions
57+
- **Automatically generating code** from models for deployment on hardware
58+
- **Executing rapid prototyping and testing** within simulation environments
59+
60+
MBD is widely used in industries like aerospace, automotive, and robotics, especially for embedded systems and control applications, as it streamlines development and enhances collaboration among multidisciplinary teams.
5061
```
5162

5263
# Print Stream to HTML UI Component
@@ -70,7 +81,7 @@ resetTable(h);
7081
Create the chat object with the function handle, which requires the `uihtml` object created earlier.
7182

7283
```matlab
73-
chat = openAIChat(StreamFun=@(x)printStream(h,x));
84+
chat = openAIChat(StreamFun=@(x)printStream(h,x), ModelName="gpt-4.1-nano");
7485
```
7586

7687
Add the user prompt to the table in the HTML UI component.

examples/RetrievalAugmentedGenerationUsingChatGPTandMATLAB.md

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,14 @@ Split the text data into paragraphs with the helper function `preprocessDocument
6464
documents = preprocessDocuments(str);
6565
```
6666

67-
Initialize the chatbot with a system prompt and API key. Include your API key in the environment variable `OPENAI_API_KEY` or pass your key using the `APIKey` name\-value pair.
67+
Initialize the chatbot with a system prompt and API key. Include your API key in the environment variable `OPENAI_API_KEY` or pass your key using the `APIKey` name\-value pair. This example uses the model GPT\-4.1 mini.
6868

6969
```matlab
7070
chat = openAIChat("You are a helpful assistant. You will get a " + ...
7171
"context for each question, but only use the information " + ...
7272
"in the context if that makes sense to answer the question. " + ...
73-
"Let's think step-by-step, explaining how you reached the answer.");
73+
"Let's think step-by-step, explaining how you reached the answer.", ...
74+
ModelName="gpt-4.1-mini");
7475
```
7576
# Retrieve Relevant Documents
7677

@@ -123,18 +124,41 @@ wrapText(response)
123124

124125
```matlabTextOutput
125126
ans =
126-
"The context provides information on how technical criteria can be used to
127-
streamline new approvals for grid-friendly DPV. It mentions that technical
128-
approvals for DPV installations to connect to the grid can be streamlined with
129-
prudent screening criteria for systems that meet certain specifications.
130-
Additionally, it emphasizes the importance of having a grid code that reflects
131-
expected future growth of distributed energy resources.
127+
"To streamline new approvals for grid-friendly distributed photovoltaics (DPV),
128+
prudent technical criteria can be applied that balance deployment with the
129+
technical requirements of the distribution system. Specifically:
132130
133-
Therefore, the technical criteria that can be used to streamline new approvals
134-
for grid-friendly DPV include having prudent screening criteria based on
135-
specific specifications and ensuring that the grid code is in line with the
136-
expected growth of distributed resources. This helps in facilitating the
137-
connection of DPV installations to the grid efficiently and effectively."
131+
1. **Technical Screening Criteria**: Utilities can use technical screening
132+
criteria based on metrics relevant to the impact of DPV on low-voltage
133+
distribution grids. For example, limiting DPV capacity relative to the minimum
134+
feeder daytime load helps prevent technical issues.
135+
136+
2. **Hosting Capacity Calculations**: These calculations estimate the point at
137+
which DPV penetration would induce technical impacts on system operation.
138+
Screening criteria derived from these calculations allow utilities to set
139+
limits that ensure grid stability.
140+
141+
3. **Connection Size Limits**: Some regulations specify maximum DPV
142+
installation sizes relative to customer peak load (e.g., 80 percent of peak
143+
load in India), serving as a straightforward technical criterion for approval.
144+
145+
4. **Advanced Inverter Functions**: Specifying that inverters have advanced
146+
capabilities such as reactive power control and active power curtailment before
147+
connection approval helps maintain grid stability and voltage management.
148+
149+
5. **Grid Codes Reflecting DPV Growth**: Adopting or updating grid codes to
150+
include expected growth of distributed energy resources and requirements for
151+
inverter functionalities streamlines approvals by setting clear technical
152+
standards.
153+
154+
6. **Cost-effective and Forward-looking Measures**: The criteria should be easy
155+
to implement, cost-efficient, and anticipate future system integration needs,
156+
helping avoid costly retrofits.
157+
158+
Thus, prudent technical criteria include setting size limits relative to load,
159+
applying hosting capacity-based screens, requiring advanced inverter
160+
functionalities, and updating grid codes to reflect DPV penetration—all
161+
facilitating streamlined, grid-friendly DPV approvals."
138162
139163
```
140164

examples/SummarizeLargeDocumentsUsingChatGPTandMATLAB.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ chunks = createChunks(incrementalSummary, limitChunkWords);
4848
```
4949
# Summarize Chunks
5050

51-
Initialize a ChatGPT session with the role of summarizing text
51+
Initialize a ChatGPT session with the role of summarizing text. This example uses the model GPT\-4.1 nano.
5252

5353
```matlab
54-
summarizer = openAIChat("You are a professional summarizer.");
54+
summarizer = openAIChat("You are a professional summarizer.", ModelName="gpt-4.1-nano");
5555
```
5656

5757
Looping process to gradually summarize the text chunk by chunk, reducing the chunk size with each iteration.
@@ -99,11 +99,17 @@ wrapText(fullSummary)
9999

100100
```matlabTextOutput
101101
ans =
102-
""Alice's Adventures in Wonderland" by Lewis Carroll follows the whimsical journey of a young girl, Alice, who falls into a fantastical world through a rabbit hole.
103-
Throughout her adventures, Alice encounters a series of peculiar characters and bizarre events while trying to find her way back home.
104-
She navigates through surreal situations such as a Caucus-race with talking animals, converses with a cryptic Caterpillar about identity and size changes, and experiences a mad tea party with the March Hare and the Hatter.
105-
Alice also interacts with the Queen of Hearts during a chaotic croquet game, intervenes in a trial involving the theft of tarts, and meets the Mock Turtle and Gryphon who share odd stories and engage in whimsical discussions about lobsters and fish tails.
106-
The narrative is filled with illogical and imaginative elements, capturing readers' imaginations with its colorful and eccentric storytelling."
102+
"The excerpt from Lewis Carroll's "Alice’s Adventures in Wonderland" vividly depicts Alice’s fantastical journey through a surreal and whimsical realm filled with eccentric characters, bizarre settings, and illogical scenarios.
103+
Initially, Alice adventures down a rabbit-hole while chasing the White Rabbit with a pocket watch, leading her into Wonderland, a land of constant size changes and peculiar encounters.
104+
She consumes mysterious cakes and potions that cause her to shrink or grow, sometimes making her over nine feet tall and other times too small to fit through doors, exemplifying the whimsical logic of the world.
105+
Throughout her travels, Alice interacts with a diverse array of characters, including the White Rabbit, a grumpy Caterpillar smoking a hookah who challenges her understanding of identity, the Cheshire Cat offering cryptic advice, the Duchess with her sarcastic banter, and various animals engaged in nonsensical activities.
106+
She explores strange environments such as a locked hall with a tiny door leading to a beautiful garden, chaotic kitchens, and a garden where roses are painted white.
107+
Notable scenes include the humorous Caucus-race where everyone wins prizes, Alice helping the White Rabbit find his gloves and fan, and her participation in a mad tea-party hosted by the March Hare and the Hatter, featuring riddles like “Why is a raven like a writing-desk?”
108+
and conversations about manipulating time and living at the bottom of a treacle well.
109+
Alice also witnesses the Queen of Hearts’ violent temper during a chaotic game of croquet using live hedgehogs and flamingoes, and observes a courtroom trial over stolen tarts with improbable evidence and absurd proceedings, satirizing judicial processes.
110+
Throughout her journey, Alice experiences moments of wonder, confusion, frustration, and curiosity.
111+
She contemplates her identity, questions her surroundings, and navigates the illogical world with a playful sense of imagination.
112+
The narrative's surreal and humorous tone highlights themes of curiosity, nonsense, authority, and the blurring of reality and imagination, creating a richly satirical and whimsical portrayal of Wonderland’s chaotic, absurd universe."
107113
108114
```
109115

27 Bytes
Binary file not shown.
Binary file not shown.
14 Bytes
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)