A powerful OpenAI playground for pro-users and developers
MIT License
A powerful OpenAI playground for pro-users and developers.
Metacello new
repository: 'github://brackendev/OpenAI-Pharo/src';
baseline: 'OpenAI';
load.
(An examples package is also included.)
"Lists the currently available models"
(OpenAISDK createWithAPIKey: 'API_KEY') listModels.
"Programatically use a chat session"
sdk := OpenAISDK createWithAPIKey: 'API_KEY'.
chatSession := OpenAIChatSession startWithSDK: sdk.
chatSession model: 'gpt-4'. "Optional. Default is gpt-3.5-turbo"
chatSession submitSystemPrompt: 'You are a chatbot named OMM 0000.'.
chatSession submitUserPrompt: 'Who are you?'.
chatSession lastChat inspect. "Inspects the response: I am OMM 0000..."
chatSession submitUserPrompt: 'Show me Pharo code to add numbers to your name. Respond with only Pharo code, no other text, no code block.'.
chatSession lastChat inspect. "Inspects the Pharo code response"
chatSession lastChat evaluate inspect. "Inspects the Pharo code evaluated"
"Programtically generate images"
sdk := OpenAISDK createWithAPIKey: 'API_KEY'.
sdk createImageWithPrompt: 'An elephant drinking water on the moon' number: 2 size: '1024x1024'.
"Open a chat session GUI"
sdk := OpenAISDK createWithAPIKey: 'API_KEY'.
OpenAIChatGUI openWithSDK: sdk.
"Open an image generation GUI"
sdk := OpenAISDK createWithAPIKey: 'API_KEY'.
OpenAIImageGUI openWithSDK: sdk.
"Update any class comment with the generated Class Responsibility Collaborator (based on class definitions and source code)"
sdk := OpenAISDK createWithAPIKey: 'API_KEY'.
AnyClassYouWant updateCommentWithOpenAICRCWithSDK: sdk.
This project makes use of the following third-party libraries and utilities:
Bracken Spencer
OpenAI-Pharo is released under the MIT license. See the LICENSE file for more info.