Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge changes from main #17

Closed
wants to merge 16 commits into from
Closed
52 changes: 31 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,29 @@ Some of the current LLMs supported are:

For details on the specification of each model, check the official [OpenAI documentation](https://platform.openai.com/docs/models).

## Requirements

### MathWorks Products (https://www.mathworks.com)

- Requires MATLAB release R2024a or newer.
- Some examples require Text Analytics Toolbox™.

### 3rd Party Products:

- An active OpenAI API subscription and API key.

## Setup

If you would like to use this repository with MATLAB Online, simply click [![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=matlab-deep-learning/llms-with-matlab)
### MATLAB Online

To use this repository with MATLAB Online, click [![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=matlab-deep-learning/llms-with-matlab)


If you would like to use it with MATLAB Desktop, proceed with the following steps:
### MATLAB Desktop

1. Clone the repository to your local machine.
To use this repository with a local installation of MATLAB, first clone the repository.

1. In the system command prompt, run:

```bash
git clone https://github.com/matlab-deep-learning/llms-with-matlab.git
Expand All @@ -32,7 +48,9 @@ If you would like to use it with MATLAB Desktop, proceed with the following step
addpath('path/to/llms-with-matlab');
```

4. Set up your OpenAI API key. Create a `.env` file in the project root directory with the following content.
### Setting up your API key

Set up your OpenAI API key. Create a `.env` file in the project root directory with the following content.

```
OPENAI_API_KEY=<your key>
Expand All @@ -44,15 +62,6 @@ If you would like to use it with MATLAB Desktop, proceed with the following step
loadenv(".env")
```

### MathWorks Products (https://www.mathworks.com)

- Requires MATLAB release R2023a or newer.

### 3rd Party Products:

- An active OpenAI API subscription and API key.


## Getting Started with Chat Completion API

To get started, you can either create an `openAIChat` object and use its methods or use it in a more complex setup, as needed.
Expand Down Expand Up @@ -320,15 +329,16 @@ imshow(images{1})
## Examples
To learn how to use this in your workflows, see [Examples](/examples/).

- [ExampleStreaming.mlx](/examples/ExampleStreaming.mlx): Learn to implement a simple chat that stream the response.
- [ExampleSummarization.mlx](/examples/ExampleSummarization.mlx): Learn to create concise summaries of long texts with ChatGPT. (Requires Text Analytics Toolbox™)
- [ExampleChatBot.mlx](/examples/ExampleChatBot.mlx): Build a conversational chatbot capable of handling various dialogue scenarios using ChatGPT. (Requires Text Analytics Toolbox)
- [ExampleFunctionCalling.mlx](/examples/ExampleFunctionCalling.mlx): Learn how to create agents capable of executing MATLAB functions.
- [ProcessGeneratedTextinRealTimebyUsingChatGPTinStreamingMode.mlx](/examples/ProcessGeneratedTextinRealTimebyUsingChatGPTinStreamingMode.mlx): Learn to implement a simple chat that stream the response.
- [SummarizeLargeDocumentsUsingChatGPTandMATLAB.mlx](/examples/SummarizeLargeDocumentsUsingChatGPTandMATLAB.mlx): Learn to create concise summaries of long texts with ChatGPT. (Requires Text Analytics Toolbox™)
- [CreateSimpleChatBot.mlx](/examples/CreateSimpleChatBot.mlx): Build a conversational chatbot capable of handling various dialogue scenarios using ChatGPT. (Requires Text Analytics Toolbox)
- [AnalyzeScientificPapersUsingFunctionCalls.mlx](/examples/AnalyzeScientificPapersUsingFunctionCalls.mlx): Learn how to create agents capable of executing MATLAB functions.
- [ExampleParallelFunctionCalls.mlx](/examples/ExampleParallelFunctionCalls.mlx): Learn how to take advantage of parallel function calling.
- [ExampleRetrievalAugmentedGeneration.mlx](/examples/ExampleRetrievalAugmentedGeneration.mlx): Learn about retrieval augmented generation with a simple use case. (Requires Text Analytics Toolbox™)
- [ExampleGPT4Vision.mlx](/examples/ExampleGPT4Vision.mlx): Learn how to use GPT-4 Turbo with Vision to understand the content of an image.
- [ExampleJSONMode.mlx](/examples/ExampleJSONMode.mlx): Learn how to use JSON mode in chat completions
- [ExampleDALLE.mlx](/examples/ExampleDALLE.mlx): Learn how to generate images, create variations and edit the images.
- [RetrievalAugmentedGenerationUsingChatGPTandMATLAB.mlx](/examples/RetrievalAugmentedGenerationUsingChatGPTandMATLAB.mlx): Learn about retrieval augmented generation with a simple use case. (Requires Text Analytics Toolbox™)
- [DescribeImagesUsingChatGPT.mlx](/examples/DescribeImagesUsingChatGPT.mlx): Learn how to use GPT-4 Turbo with Vision to understand the content of an image.
- [AnalyzeSentimentinTextUsingChatGPTinJSONMode.mlx](/examples/AnalyzeSentimentinTextUsingChatGPTinJSONMode.mlx): Learn how to use JSON mode in chat completions
- [UsingDALLEToEditImages.mlx](/examples/UsingDALLEToEditImages.mlx): Learn how to generate images
- [UsingDALLEToGenerateImages.mlx](/examples/UsingDALLEToGenerateImages.mlx): Create variations of images and editimages.

## License

Expand Down
Binary file not shown.
Binary file not shown.
Binary file added examples/CreateSimpleChatBot.mlx
Binary file not shown.
Binary file added examples/DescribeImagesUsingChatGPT.mlx
Binary file not shown.
Binary file removed examples/ExampleChatBot.mlx
Binary file not shown.
Binary file removed examples/ExampleDALLE.mlx
Binary file not shown.
Binary file removed examples/ExampleEmbeddings.mlx
Binary file not shown.
Binary file removed examples/ExampleFunctionCalling.mlx
Binary file not shown.
Binary file removed examples/ExampleGPT4Vision.mlx
Binary file not shown.
Binary file removed examples/ExampleJSONMode.mlx
Binary file not shown.
Binary file removed examples/ExampleRetrievalAugmentedGeneration.mlx
Binary file not shown.
Binary file removed examples/ExampleStreaming.mlx
Binary file not shown.
Binary file removed examples/ExampleSummarization.mlx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added examples/UsingDALLEToEditImages.mlx
Binary file not shown.
Binary file added examples/UsingDALLEToGenerateImages.mlx
Binary file not shown.
6 changes: 3 additions & 3 deletions openAIChat.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@
systemPrompt {llms.utils.mustBeTextOrEmpty} = []
nvp.Tools (1,:) {mustBeA(nvp.Tools, "openAIFunction")} = openAIFunction.empty
nvp.ModelName (1,1) {mustBeMember(nvp.ModelName,["gpt-4", "gpt-4-0613", "gpt-4-32k", ...
"gpt-3.5-turbo", "gpt-3.5-turbo-16k",...
"gpt-4-1106-preview","gpt-3.5-turbo-1106", ...
"gpt-4-vision-preview", "gpt-4-turbo-preview"])} = "gpt-3.5-turbo"
"gpt-3.5-turbo", "gpt-4-1106-preview", ...
"gpt-3.5-turbo-1106", "gpt-4-vision-preview", ...
"gpt-4-turbo-preview"])} = "gpt-3.5-turbo"
nvp.Temperature {mustBeValidTemperature} = 1
nvp.TopProbabilityMass {mustBeValidTopP} = 1
nvp.StopSequences {mustBeValidStop} = {}
Expand Down
Loading