File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,47 @@ function testAnalyzeSentimentinTextUsingChatGPTinJSONMode(testCase)
65
65
testCase .verifyWarning(@AnalyzeSentimentinTextUsingChatGPTinJSONMode ,...
66
66
" llms:warningJsonInstruction" );
67
67
end
68
+
69
+ function testCreateSimpleChatBot(testCase )
70
+ % set up a fake input command, returning canned user prompts
71
+ count = 0 ;
72
+ prompts = [
73
+ " Hello, how much do you know about physics?"
74
+ " What is torque?"
75
+ " What is force?"
76
+ " What is motion?"
77
+ " What is time?"
78
+ " end"
79
+ " end"
80
+ " end"
81
+ ];
82
+ function res = input_(varargin )
83
+ count = count + 1 ;
84
+ res = prompts(count );
85
+ end
86
+ input = @input_ ; % #ok<NASGU>
87
+
88
+ % to avoid errors about a static workspace, let MATLAB know we
89
+ % want these variables to exist
90
+ wordLimit = []; % #ok<NASGU>
91
+ stopWord = []; % #ok<NASGU>
92
+ modelName = []; % #ok<NASGU>
93
+ chat = []; % #ok<NASGU>
94
+ messages = [];
95
+ totalWords = []; % #ok<NASGU>
96
+ messagesSizes = []; % #ok<NASGU>
97
+ query = []; % #ok<NASGU>
98
+ numWordsQuery = []; % #ok<NASGU>
99
+ text = []; % #ok<NASGU>
100
+ response = []; % #ok<NASGU>
101
+ numWordsResponse = []; % #ok<NASGU>
102
+
103
+ % Run the example
104
+ CreateSimpleChatBot ;
105
+
106
+ testCase .verifyEqual(count ,find(prompts ==" end" ,1 ));
107
+ testCase .verifySize(messages .Messages ,[1 2 *(count - 1 )]);
108
+ end
68
109
end
69
110
70
111
end
You can’t perform that action at this time.
0 commit comments