-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from toshiakit/dev
Support the latest models released by OpenAI on April 9, 2024
- Loading branch information
Showing
19 changed files
with
123 additions
and
90 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
function [image,message,response] = imageGenGenerate(chat,messages) | ||
% IMAGEGENGENERATE generates image using chat api with function calling | ||
|
||
% generate a response to the prompt for image generation | ||
[txt,message,response] = generate(chat,messages); | ||
% if tool_call is returned | ||
if isfield(message,"tool_calls") | ||
toolCalls = message.tool_calls; | ||
fcn = toolCalls.function.name; | ||
% make sure it calls for 'generateImage' | ||
if strcmp(fcn,"generateImage") | ||
args = jsondecode(toolCalls.function.arguments); | ||
prompt = string(args.prompt); | ||
% execute 'generateImage' using the provided prompt | ||
[image,revisedPrompt,response] = generateImage(prompt); | ||
message = struct("role","assistant","content", string(revisedPrompt)); | ||
end | ||
else | ||
image = txt; | ||
end | ||
end | ||
|
||
% helper function 'generateImage' to call DALL-E 3 | ||
function [image, revisedPrompt ,response] = generateImage(prompt) | ||
mdl = openAIImages(ModelName="dall-e-3"); | ||
[images, response] = generate(mdl,string(prompt)); | ||
image = images{1}; | ||
revisedPrompt = response.Body.Data.data.revised_prompt; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+9.67 KB
helpers/llms-with-matlab/examples/AnalyzeScientificPapersUsingFunctionCalls.mlx
Binary file not shown.
Binary file added
BIN
+4.77 KB
helpers/llms-with-matlab/examples/AnalyzeSentimentinTextUsingChatGPTinJSONMode.mlx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
-197 Bytes
(97%)
helpers/llms-with-matlab/examples/ExampleParallelFunctionCalls.mlx
Binary file not shown.
Binary file added
BIN
+5.42 KB
helpers/llms-with-matlab/examples/InformationRetrievalUsingOpenAIDocumentEmbedding.mlx
Binary file not shown.
Binary file added
BIN
+5.42 KB
...llms-with-matlab/examples/ProcessGeneratedTextinRealTimebyUsingChatGPTinStreamingMode.mlx
Binary file not shown.
Binary file added
BIN
+5.5 KB
helpers/llms-with-matlab/examples/RetrievalAugmentedGenerationUsingChatGPTandMATLAB.mlx
Binary file not shown.
Binary file added
BIN
+5.68 KB
helpers/llms-with-matlab/examples/SummarizeLargeDocumentsUsingChatGPTandMATLAB.mlx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.