{"id":14965996,"url":"https://github.com/antononcube/raku-www-openai","last_synced_at":"2025-10-25T13:30:56.400Z","repository":{"id":159789628,"uuid":"612252403","full_name":"antononcube/Raku-WWW-OpenAI","owner":"antononcube","description":"Raku package that provides access to the algorithms/models of OpenAI (https://platform.openai.com).","archived":false,"fork":false,"pushed_at":"2024-09-16T21:35:40.000Z","size":4336,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-31T07:11:54.531Z","etag":null,"topics":["chatgpt-api","openai-api","raku","raku-module","rakulang"],"latest_commit_sha":null,"homepage":"https://raku.land/zef:antononcube/WWW::OpenAI","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antononcube.png","metadata":{"files":{"readme":"README-work.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-10T14:27:00.000Z","updated_at":"2024-11-12T19:29:23.000Z","dependencies_parsed_at":"2024-05-10T02:27:45.474Z","dependency_job_id":"3f791d68-d173-49c5-8f8d-73d093d5c7bc","html_url":"https://github.com/antononcube/Raku-WWW-OpenAI","commit_stats":{"total_commits":253,"total_committers":2,"mean_commits":126.5,"dds":"0.0039525691699604515","last_synced_commit":"6ecd772b763d41f41da1ef7d1136640c1f8826e3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antononcube%2FRaku-WWW-OpenAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antononcube%2FRaku-WWW-OpenAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antononcube%2FRaku-WWW-OpenAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antononcube%2FRaku-WWW-OpenAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antononcube","download_url":"https://codeload.github.com/antononcube/Raku-WWW-OpenAI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238147562,"owners_count":19424284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt-api","openai-api","raku","raku-module","rakulang"],"created_at":"2024-09-24T13:35:40.161Z","updated_at":"2025-10-25T13:30:56.392Z","avatar_url":"https://github.com/antononcube.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WWW::OpenAI Raku package\n\n## In brief\n\nThis Raku package provides access to the machine learning service [OpenAI](https://platform.openai.com), [OAI1].\nFor more details of the OpenAI's API usage see [the documentation](https://platform.openai.com/docs/api-reference/making-requests), [OAI2].\n\n**Remark:** To use the OpenAI API one has to register and obtain authorization key.\n\n**Remark:** This Raku package is much \"less ambitious\" than the official Python package, [OAIp1], developed by OpenAI's team.\nGradually, over time, I expect to add features to the Raku package that correspond to features of [OAIp1].\n\nThe original design and implementation of \"WWW::OpenAI\" were very similar to those of\n[\"Lingua::Translation::DeepL\"](https://raku.land/zef:antononcube/Lingua::Translation::DeepL), [AAp1].\nMajor refactoring of the original code was done -- now each OpenAI functionality targeted by \"WWW::OpenAI\"\nhas its code placed in a separate file.\n\n-----\n\n## Installation\n\nPackage installations from both sources use [zef installer](https://github.com/ugexe/zef)\n(which should be bundled with the \"standard\" Rakudo installation file.)\n\nTo install the package from [Zef ecosystem](https://raku.land/) use the shell command:\n\n```\nzef install WWW::OpenAI\n```\n\nTo install the package from the GitHub repository use the shell command:\n\n```\nzef install https://github.com/antononcube/Raku-WWW-OpenAI.git\n```\n\n----\n\n## Usage examples\n\n**Remark:** When the authorization key, `auth-key`, is specified to be `Whatever`\nthen the functions `openai-*` attempt to use the env variable `OPENAI_API_KEY`.\n\n### Universal \"front-end\"\n\nThe package has an universal \"front-end\" function `openai-playground` for the \n[different functionalities provided by OpenAI](https://platform.openai.com/docs/api-reference/introduction).\n\nHere is a simple call for a \"chat completion\":\n\n```perl6\nuse WWW::OpenAI;\nopenai-playground('Where is Roger Rabbit?', max-tokens =\u003e 64);\n```\n\nAnother one using Bulgarian:\n\n```perl6\nopenai-playground('Колко групи могат да се намерят в този облак от точки.', max-tokens =\u003e 64);\n```\n\n**Remark:** The function `openai-completion` can be used instead in the examples above. \nSee the section \n[\"Create chat completion\"](https://platform.openai.com/docs/api-reference/chat/create) of [OAI2]\nfor more details.\n\n### Models\n\nThe current OpenAI models can be found with the function `openai-models`:\n\n```perl6\nopenai-models\n```\n\n### Code generation\n\nThere are two types of completions : text and chat. Let us illustrate the differences\nof their usage by Raku code generation. Here is a text completion:\n\n```perl6\nopenai-completion(\n        'generate Raku code for making a loop over a list',\n        type =\u003e 'text',\n        max-tokens =\u003e 120,\n        format =\u003e 'values');\n```\n\nHere is a chat completion:\n\n```perl6\nopenai-completion(\n        'generate Raku code for making a loop over a list',\n        type =\u003e 'chat',\n        max-tokens =\u003e 120,\n        format =\u003e 'values');\n```\n\n**Remark:** The argument \"type\" and the argument \"model\" have to \"agree.\" (I.e. be found agreeable by OpenAI.)\nFor example: \n- `model =\u003e 'text-davinci-003'` implies `type =\u003e 'text'`\n- `model =\u003e 'gpt-3.5-turbo'` implies `type =\u003e 'chat'`\n\n\n### Image generation\n\n**Remark:** See the files [\"Image-generation*\"](./docs/Image-generation.md) for more details.\n\nImages can be generated with the function `openai-create-image` -- see the section\n[\"Images\"](https://platform.openai.com/docs/api-reference/images) of [OAI2].\n\n\nHere is an example:\n\n```perl6, eval=FALSE\nmy $imgB64 = openai-create-image(\n        \"racoon with a sliced onion in the style of Raphael\",\n        response-format =\u003e 'b64_json',\n        model = 'dalle-e-3',\n        n =\u003e 1,\n        size =\u003e '1024x1024',\n        format =\u003e 'values',\n        method =\u003e 'tiny');\n```\n\nHere are the options descriptions:\n\n- `response-format` takes the values \"url\" and \"b64_json\"\n- `n` takes a positive integer, for the number of images to be generated\n- `size` takes the values '1024x1024', '512x512', '256x256', 'large', 'medium', 'small'. \n\nHere we generate an image, get its URL, and place (embed) a link to it via the output of the code cell:\n\n```perl6, results='asis', eval=FALSE\nmy @imgRes = |openai-create-image(\n        \"racoon and onion in the style of Roy Lichtenstein\",\n        response-format =\u003e 'url',\n        n =\u003e 1,\n        size =\u003e 'small',\n        method =\u003e 'tiny');\n\n'![](' ~ @imgRes.head\u003curl\u003e ~ ')';\n```\n\n**Remark:** The argument \"model\" can be `Whatever` of one of \"dall-e-2\" or \"dall-e-3\". \nNot all parameters that are valid for one of the models are valid or respected by the other --\nsee the subsection [\"Create image\"](https://platform.openai.com/docs/api-reference/images/create) of \n[OpenAI's documentation](https://platform.openai.com/docs/api-reference).\n\n\n### Image variation\n\n**Remark:** See the files [\"Image-variation*\"](./docs/Image-variation-and-edition.md) for more details.\n\nImages variations over image files can be generated with the function `openai-variate-image` \n-- see the section\n[\"Images\"](https://platform.openai.com/docs/api-reference/images) of [OAI2].\n\nHere is an example:\n\n```perl6, eval=FALSE\nmy $imgB64 = openai-variate-image(\n        $*CWD ~ '/resources/RandomMandala.png',\n        response-format =\u003e 'b64_json',\n        n =\u003e 1,\n        size =\u003e 'small',\n        format =\u003e 'values',\n        method =\u003e 'tiny');\n```\n\nHere are the options descriptions:\n\n- `response-format` takes the values \"url\" and \"b64_json\"\n- `n` takes a positive integer, for the number of images to be generated\n- `size` takes the values '1024x1024', '512x512', '256x256', 'large', 'medium', 'small'.\n\n**Remark:** Same arguments are used by `openai-generate-image`. See the previous sub-section.\n\nHere we generate an image, get its URL, and place (embed) a link to it via the output of the code cell:\n\n```perl6, results='asis', eval=FALSE\nmy @imgRes = |openai-variate-image(\n        $*CWD ~ '/resources/RandomMandala.png',\n        response-format =\u003e 'url',\n        n =\u003e 1,\n        size =\u003e 'small',\n        method =\u003e 'tiny');\n\n'![](' ~ @imgRes.head\u003curl\u003e ~ ')';\n```\n\n### Image edition\n\n**Remark:** See the files [\"Image-variation*\"](./docs/Image-variation-and-edition.md) for more details.\n\nEditions of images can be generated with the function `openai-edit-image` -- see the section\n[\"Images\"](https://platform.openai.com/docs/api-reference/images) of [OAI2].\n\nHere are the descriptions of positional arguments:\n\n- `file` is a file name string (a PNG image with [RGBA color space](https://en.wikipedia.org/wiki/RGBA_color_model))\n- `prompt` is a prompt tha describes the image edition\n\nHere are the descriptions of the named arguments (options):\n\n- `mask-file` a file name of a mask image (can be an empty string or `Whatever`)\n- `n` takes a positive integer, for the number of images to be generated\n- `size` takes the values '1024x1024', '512x512', '256x256', 'large', 'medium', 'small'.\n- `response-format` takes the values \"url\" and \"b64_json\"\n- `method` takes the values \"tiny\" and \"curl\"\n\nHere is a random mandala color (RGBA) image:\n\n![](../resources/RandomMandala2.png)\n\nHere we generate a few editions of the colored mandala image above, get their URLs,\nand place (embed) the image links using a table:\n\n```perl6, results=asis, eval=FALSE\nmy @imgRes = |openai-edit-image(\n        $*CWD ~ '/../resources/RandomMandala2.png',\n        'add cosmic background',\n        response-format =\u003e 'url',\n        n =\u003e 2,\n        size =\u003e 'small',\n        format =\u003e 'values',\n        method =\u003e 'tiny');\n\n@imgRes.map({ '![](' ~ $_ ~ ')' }).join(\"\\n\\n\")       \n```\n\n\n### Vision\n\nIn the fall of 2023 OpenAI introduced image vision model\n[\"gpt-4-vision-preview\"](https://openai.com/blog/new-models-and-developer-products-announced-at-devday), [OAIb1].\n\nIf the function `openai-completion` is given a list of images, textual results corresponding to those images is returned.\nThe argument \"images\" is a list of image URLs, image file names, or image Base64 representations. (Any combination of those element types.)\n\nHere is an example with three images:\n\n```perl6\nmy $url1 = 'https://i.imgur.com/LEGfCeq.jpg';\nmy $url2 = 'https://i.imgur.com/UcRYl9Y.jpg';\nmy $fname3 = $*CWD ~ '/resources/ThreeHunters.jpg';\nmy @images = [$url1, $url2, $fname3];\nsay openai-completion(\"Give concise descriptions of the images.\", :@images, max-tokens =\u003e 900, format =\u003e 'values');\n```\n\nThe function `encode-image` from the namespace `WWW::OpenAI::ChatCompletions` can be used\nto get Base64 image strings corresponding to image files. For example:\n\n```perl6, results=asis, eval=FALSE\nmy $img3 = WWW::OpenAI::ChatCompletions::encode-image($fname3);\nsay \"![]($img3)\"  \n```\n\nWhen a file name is given to the argument \"images\" of `openai-completion` then the function `encode-image` is applied to it.\n\n\n### Moderation\n\nHere is an example of using \n[OpenAI's moderation](https://platform.openai.com/docs/api-reference/moderations):\n\n```perl6\nmy @modRes = |openai-moderation(\n\"I want to kill them!\",\nformat =\u003e \"values\",\nmethod =\u003e 'tiny');\n\nfor @modRes -\u003e $m { .say for $m.pairs.sort(*.value).reverse; }\n```\n\n### Audio transcription and translation\n\nHere is an example of using\n[OpenAI's audio transcription](https://platform.openai.com/docs/api-reference/audio):\n\n```perl6\nmy $fileName = $*CWD ~ '/resources/HelloRaccoonsEN.mp3';\nsay openai-audio(\n        $fileName,\n        format =\u003e 'json',\n        method =\u003e 'tiny');\n```\n\nTo do translations use the named argument `type`:\n\n```perl6\nmy $fileName = $*CWD ~ '/resources/HowAreYouRU.mp3';\nsay openai-audio(\n        $fileName,\n        type =\u003e 'translations',\n        format =\u003e 'json',\n        method =\u003e 'tiny');\n```\n\n### Audio speech generation\n\nHere is an example of text-to-speech generation - `type`, `prompt`, have to be specified:\n\n```perl6\nmy $fileName = $*CWD ~ '/resources/EveryDay.mp3';\nmy $res = openai-audio(\n        $fileName, \n        prompt =\u003e 'Every day is a summer day!',\n        type =\u003e 'speech',\n        format =\u003e 'mp3',\n        voice =\u003e 'alloy',\n        speed =\u003e 1,\n        method =\u003e 'tiny');\n```\n\n\n### Embeddings\n\n[Embeddings](https://platform.openai.com/docs/api-reference/embeddings)\ncan be obtained with the function `openai-embeddings`. Here is an example of finding the embedding vectors\nfor each of the elements of an array of strings:\n\n```perl6\nmy @queries = [\n    'make a classifier with the method RandomForeset over the data dfTitanic',\n    'show precision and accuracy',\n    'plot True Positive Rate vs Positive Predictive Value',\n    'what is a good meat and potatoes recipe'\n];\n\nmy $embs = openai-embeddings(@queries, format =\u003e 'values', method =\u003e 'tiny');\n$embs.elems;\n```\n\nHere we show:\n- That the result is an array of four vectors each with length 1536\n- The distributions of the values of each vector\n\n```perl6\nuse Data::Reshapers;\nuse Data::Summarizers;\n\nsay \"\\$embs.elems : { $embs.elems }\";\nsay \"\\$embs\u003e\u003e.elems : { $embs\u003e\u003e.elems }\";\nrecords-summary($embs.kv.Hash.\u0026transpose);\n```\n\nHere we find the corresponding dot products and (cross-)tabulate them:\n\n```perl6\nuse Data::Reshapers;\nuse Data::Summarizers;\nmy @ct = (^$embs.elems X ^$embs.elems).map({ %( i =\u003e $_[0], j =\u003e $_[1], dot =\u003e sum($embs[$_[0]] \u003e\u003e*\u003c\u003c $embs[$_[1]])) }).Array;\n\nsay to-pretty-table(cross-tabulate(@ct, 'i', 'j', 'dot'), field-names =\u003e (^$embs.elems)\u003e\u003e.Str);\n````\n\n**Remark:** Note that the fourth element (the cooking recipe request) is an outlier.\n(Judging by the table with dot products.)\n\n### Chat completions with engineered prompts\n\nHere is a prompt for \"emojification\" (see the\n[Wolfram Prompt Repository](https://resources.wolframcloud.com/PromptRepository/)\nentry\n[\"Emojify\"](https://resources.wolframcloud.com/PromptRepository/resources/Emojify/)):\n\n```perl6\nmy $preEmojify = q:to/END/;\nRewrite the following text and convert some of it into emojis.\nThe emojis are all related to whatever is in the text.\nKeep a lot of the text, but convert key words into emojis.\nDo not modify the text except to add emoji.\nRespond only with the modified text, do not include any summary or explanation.\nDo not respond with only emoji, most of the text should remain as normal words.\nEND\n```\n\nHere is an example of chat completion with emojification:\n\n```perl6\nopenai-chat-completion([ system =\u003e $preEmojify, user =\u003e 'Python sucks, Raku rocks, and Perl is annoying'], max-tokens =\u003e 200, format =\u003e 'values')\n```\n\nFor more examples see the document [\"Chat-completion-examples\"](./docs/Chat-completion-examples_woven.md).\n\n### Finding textual answers\n\nThe models of OpenAI can be used to find sub-strings in texts that appear to be\nanswers to given questions. This is done via the package \n[\"ML::FindTextualAnswer\"](https://raku.land/zef:antononcube/ML::FindTextualAnswer), [AAp3],\nusing the parameter specs `llm =\u003e 'chatgpt'` or `llm =\u003e 'openai'`.\n\n\nHere is an example of finding textual answers:\n\n```perl6\nuse ML::FindTextualAnswer;\nmy $text = \"Lake Titicaca is a large, deep lake in the Andes \non the border of Bolivia and Peru. By volume of water and by surface \narea, it is the largest lake in South America\";\n\nfind-textual-answer($text, \"Where is Titicaca?\", llm =\u003e 'openai')\n```\n\nBy default `find-textual-answer` tries to give short answers.\nIf the option \"request\" is `Whatever` then depending on the number of questions \nthe request is one those phrases:\n- \"give the shortest answer of the question:\"\n- \"list the shortest answers of the questions:\"\n\nIn the example above the full query given to OpenAI's models is:\n\n\u003e Given the text \"Lake Titicaca is a large, deep lake in the Andes\non the border of Bolivia and Peru. By volume of water and by surface\narea, it is the largest lake in South America\" \n\u003e give the shortest answer of the question:   \n\u003e Where is Titicaca?\n\nHere we get a longer answer by changing the value of \"request\":\n\n```perl6\nfind-textual-answer($text, \"Where is Titicaca?\", llm =\u003e 'chatgpt', request =\u003e \"answer the question:\")\n```\n\n**Remark:** The function `find-textual-answer` is inspired by the Mathematica function\n[`FindTextualAnswer`](https://reference.wolfram.com/language/ref/FindTextualAnswer.html); \nsee [JL1].\n\n#### Multiple questions\n\nIf several questions are given to the function `find-textual-answer`\nthen all questions are spliced with the given text into one query (that is sent to OpenAI.)\n\nFor example, consider the following text and questions:\n\n```perl6\nmy $query = 'Make a classifier with the method RandomForest over the data dfTitanic; show precision and accuracy.';\n\nmy @questions =\n        ['What is the dataset?',\n         'What is the method?',\n         'Which metrics to show?'\n        ];\n```\n\nThen the query send to OpenAI is:\n\n\u003e Given the text: \"Make a classifier with the method RandomForest over the data dfTitanic; show precision and accuracy.\"\n\u003e list the shortest answers of the questions:   \n\u003e 1) What is the dataset?   \n\u003e 2) What is the method?    \n\u003e 3) Which metrics to show?   \n\n\nThe answers are assumed to be given in the same order as the questions, each answer in a separated line.\nHence, by splitting the OpenAI result into lines we get the answers corresponding to the questions.  \n\nIf the questions are missing question marks, it is likely that the result may have a completion as \na first line followed by the answers. In that situation the answers are not parsed and a warning message is given.\n\n-------\n\n## Command Line Interface\n\n### Playground access\n\nThe package provides a Command Line Interface (CLI) script:\n\n```shell\nopenai-playground --help\n```\n\n**Remark:** When the authorization key argument \"auth-key\" is specified set to \"Whatever\"\nthen `openai-playground` attempts to use the env variable `OPENAI_API_KEY`.\n\n\n--------\n\n## Mermaid diagram\n\nThe following flowchart corresponds to the steps in the package function `openai-playground`:\n\n```mermaid\ngraph TD\n\tUI[/Some natural language text/]\n\tTO[/\"OpenAI\u003cbr/\u003eProcessed output\"/]\n\tWR[[Web request]]\n\tOpenAI{{https://platform.openai.com}}\n\tPJ[Parse JSON]\n\tQ{Return\u003cbr\u003ehash?}\n\tMSTC[Compose query]\n\tMURL[[Make URL]]\n\tTTC[Process]\n\tQAK{Auth key\u003cbr\u003esupplied?}\n\tEAK[[\"Try to find\u003cbr\u003eOPENAI_API_KEY\u003cbr\u003ein %*ENV\"]]\n\tQEAF{Auth key\u003cbr\u003efound?}\n\tNAK[/Cannot find auth key/]\n\tUI --\u003e QAK\n\tQAK --\u003e |yes|MSTC\n\tQAK --\u003e |no|EAK\n\tEAK --\u003e QEAF\n\tMSTC --\u003e TTC\n\tQEAF --\u003e |no|NAK\n\tQEAF --\u003e |yes|TTC\n\tTTC -.-\u003e MURL -.-\u003e WR -.-\u003e TTC\n\tWR -.-\u003e |URL|OpenAI \n\tOpenAI -.-\u003e |JSON|WR\n\tTTC --\u003e Q \n\tQ --\u003e |yes|PJ\n\tQ --\u003e |no|TO\n\tPJ --\u003e TO\n```\n\n--------\n\n## Potential problems\n\n### Tested on macOS only\n\nCurrently this package is tested on macOS only.\n\n### Not all models work\n\nNot all models listed and proclaimed by [OpenAI's documents](https://platform.openai.com/docs/models) \nwork with the corresponding endpoints. Certain models are not available for text- or chat completions,\nalthough the documentation says they are.\n\nSee and run the file [\"Models-run-verification.raku\"](./experiments/Models-run-verification.raku) \nto test the available models per endpoint.\n\nRelated is a (current) deficiency of the package \"WWW::OpenAI\" -- the known models are hardcoded.\n(Although, there the function `openai-models` uses an endpoint provided by OpenAI.)\n\n### SSL certificate problems (original package version)\n\n*(This subsection is for the original version of the package, not for the most recent one.)*\n\n\n- On macOS I get the errors:\n    \n  \u003e Cannot locate symbol 'SSL_get1_peer_certificate' in native library\n\n- See longer discussions about this problem \n  [here](https://stackoverflow.com/questions/72792280/macos-how-to-avoid-ssl-hell-on-intel-mac-with-raku)\n  and\n  [here](https://github.com/jnthn/p6-io-socket-async-ssl/issues/66)\n  \n- Interestingly: \n  - I did not get these messages while implementing the changes of ver\u003c1.1\u003e of this package\n  - I do not get these messages when using Raku in Markdown or Mathematica notebooks, [AA1],\n    via the package [\"Text::CodeProcessing\"](https://raku.land/zef:antononcube/Text::CodeProcessing)\n  \n- Because of those SSL problems I implemented the method option that takes the values 'cro' and 'curl'.\n  \n- The method \"curl\":\n  - Requires [`curl`](https://curl.se) to be installed\n  - Invokes the procedure [`shell`](https://docs.raku.org/routine/shell)\n  - Again, this is tested on macOS only.  \n\n- After \"discovering\" \"HTTP::Tiny\" and given the problems with \"Cro::HTTP::Client\", I removed the 'cro' method.\n  (I.e. the methods are 'tiny' and 'curl' in ver\u003c0.2.0+\u003e.)\n  \n--------\n\n## TODO\n\n- [X] DONE Comprehensive unit tests\n  - Note that this requires OpenAI auth token and costs money. (Ideally, not much.)\n  - [X] DONE Basic usage\n  - [X] DONE Completions - chat\n  - [X] DONE Completions - text\n  - [X] DONE Moderation\n  - [X] DONE Audio transcription\n  - [X] DONE Audio translation\n  - [X] DONE Image generation\n  - [X] DONE Image variation\n  - [X] DONE Image edition\n  - [X] DONE Embeddings\n  - [X] DONE Finding of textual answers\n  - [X] DONE Audio speech generation\n\n- [X] DONE HTTP(S) retrieval methods\n\n  - [X] DONE `curl`\n  - [X] DONE \"Cro\"\n     - Not used in ver\u003c0.2.0+\u003e.\n  - [X] DONE \"HTTP::Tiny\"\n\n- [X] DONE Models implementation\n\n- [X] DONE Embeddings implementation\n\n- [X] DONE Refactor the code, so each functionality (audio, completion, moderation, etc)\n  has a separate file.\n\n- [X] DONE Refactor HTTP(S) retrieval functions to be simpler and more \"uniform.\"\n\n- [X] DONE De-Cro the request code.\n\n  - Given the problems of using \"Cro::HTTP::Client\" and the implementations with `curl` and \n    [\"HTTP::Tiny\"](https://gitlab.com/jjatria/http-tiny/-/blob/master/examples/cookbook.md),\n    it seems it is better to make the implementation of \"WWW::OpenAI\" more lightweight.\n\n- [X] DONE Implement finding of textual answers\n\n- [X] DONE Factor out finding of textual answers into a separate package\n  - So, other LLMs can be used.\n  - See [\"ML::FindTextualAnswer\"](https://github.com/antononcube/Raku-ML-FindTextualAnswer).\n\n- [X] DONE Implement vision (over images)\n\n- [X] DONE Implement handling of tools (function calling)\n\n--------\n\n## References\n\n### Articles\n\n[AA1] Anton Antonov,\n[\"Connecting Mathematica and Raku\"](https://rakuforprediction.wordpress.com/2021/12/30/connecting-mathematica-and-raku/),\n(2021),\n[RakuForPrediction at WordPress](https://rakuforprediction.wordpress.com).\n\n[JL1] Jérôme Louradour,\n[\"New in the Wolfram Language: FindTextualAnswer\"](https://blog.wolfram.com/2018/02/15/new-in-the-wolfram-language-findtextualanswer),\n(2018),\n[blog.wolfram.com](https://blog.wolfram.com/).\n\n[OAIb1] OpenAI team,\n[\"New models and developer products announced at DevDay\"](https://openai.com/blog/new-models-and-developer-products-announced-at-devday),\n(2023),\n[OpenAI/blog](https://openai.com/blog).\n\n### Packages\n\n[AAp1] Anton Antonov,\n[Lingua::Translation::DeepL Raku package](https://github.com/antononcube/Raku-Lingua-Translation-DeepL),\n(2022),\n[GitHub/antononcube](https://github.com/antononcube).\n\n[AAp2] Anton Antonov,\n[Text::CodeProcessing](https://github.com/antononcube/Raku-Text-CodeProcessing),\n(2021),\n[GitHub/antononcube](https://github.com/antononcube).\n\n[AAp3] Anton Antonov,\n[ML::FindTextualAnswer](https://github.com/antononcube/Raku-ML-FindTextualAnswer),\n(2023),\n[GitHub/antononcube](https://github.com/antononcube).\n\n\n[OAI1] OpenAI Platform, [OpenAI platform](https://platform.openai.com/).\n\n[OAI2] OpenAI Platform, [OpenAI documentation](https://platform.openai.com/docs).\n\n[OAIp1] OpenAI,\n[OpenAI Python Library](https://github.com/openai/openai-python),\n(2020),\n[GitHub/openai](https://github.com/openai/).\n\n### Videos\n\n[AAv1] Anton Antonov,\n[\"Jupyter Chatbook LLM cells demo (Raku)\"](https://www.youtube.com/watch?v=cICgnzYmQZg),\n(2023),\n[YouTube/@AAA4prediction](https://www.youtube.com/@AAA4prediction).\n\n[AAv2] Anton Antonov,\n[\"Integrating Large Language Models with Raku\"](https://www.youtube.com/watch?v=-OxKqRrQvh0),\n(2023),\n[The Raku Conference at YouTube](https://www.youtube.com/@therakuconference6823).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantononcube%2Fraku-www-openai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantononcube%2Fraku-www-openai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantononcube%2Fraku-www-openai/lists"}