{"id":3599,"date":"2025-01-20T21:04:11","date_gmt":"2025-01-20T15:34:11","guid":{"rendered":"https:\/\/www.rangakrish.com\/?p=3599"},"modified":"2025-01-20T21:04:11","modified_gmt":"2025-01-20T15:34:11","slug":"using-openai-from-allegro-common-lisp","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2025\/01\/20\/using-openai-from-allegro-common-lisp\/","title":{"rendered":"Using OpenAI from Allegro Common Lisp"},"content":{"rendered":"<p><a href=\"https:\/\/franz.com\/products\/allegro-common-lisp\/\" target=\"_blank\" rel=\"noopener\"><em><strong>Allegro Common Lisp ver 11.0<\/strong><\/em><\/a>\u00a0introduced support for <em><strong>OpenAI<\/strong><\/em> LLMs. In this article, let us look at some of the functions for interacting with <em><strong>OpenAI<\/strong><\/em>.<\/p>\n<p>First we need to specify basic parameters such as the API key, LLM to use, Temperature, etc. I have defined a convenient function <em><strong>configure-openai<\/strong><\/em> to do this (full source is included at the end). So, let us launch the IDE and after loading our source file, execute this function:<\/p>\n<figure id=\"attachment_3600\" aria-describedby=\"caption-attachment-3600\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig1.jpg?ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"3600\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2025\/01\/20\/using-openai-from-allegro-common-lisp\/fig1-4\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig1.jpg\" data-orig-size=\"682,230\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1737211054&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Configuring the LLM\" data-image-description=\"&lt;p&gt;Configuring the LLM&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Configuring the LLM&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig1.jpg\" class=\"wp-image-3600\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig1.jpg?resize=400%2C135&#038;ssl=1\" alt=\"Configuring the LLM\" width=\"400\" height=\"135\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig1.jpg?resize=300%2C101&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig1.jpg?resize=680%2C230&amp;ssl=1 680w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig1.jpg?resize=675%2C230&amp;ssl=1 675w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig1.jpg?w=682&amp;ssl=1 682w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-3600\" class=\"wp-caption-text\"><strong>Configuring the LLM<\/strong><\/figcaption><\/figure>\n<p>I am using the <em><strong>\u201cgpt-4o-mini\u201d<\/strong><\/em> model for subsequent interaction.<\/p>\n<p>The function <em><strong>list-openai-models<\/strong><\/em> returns a list of the currently supported models:<\/p>\n<figure id=\"attachment_3601\" aria-describedby=\"caption-attachment-3601\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig2.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3601\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2025\/01\/20\/using-openai-from-allegro-common-lisp\/fig2-4\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig2.jpg\" data-orig-size=\"511,1187\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1737211171&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"OpenAI Models\" data-image-description=\"&lt;p&gt;OpenAI Models&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;OpenAI Models&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig2-441x1024.jpg\" class=\"wp-image-3601\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig2.jpg?resize=300%2C697&#038;ssl=1\" alt=\"OpenAI Models\" width=\"300\" height=\"697\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig2.jpg?resize=129%2C300&amp;ssl=1 129w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig2.jpg?resize=441%2C1024&amp;ssl=1 441w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig2.jpg?w=511&amp;ssl=1 511w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-3601\" class=\"wp-caption-text\"><strong>List of OpenAI Models<\/strong><\/figcaption><\/figure>\n<p>Let us define a simple function that asks the LLM a Math-related question:<\/p>\n<figure id=\"attachment_3602\" aria-describedby=\"caption-attachment-3602\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig3.jpg?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3602\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2025\/01\/20\/using-openai-from-allegro-common-lisp\/fig3-5\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig3.jpg\" data-orig-size=\"1042,101\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1737211233&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Asking Math Question\" data-image-description=\"&lt;p&gt;Asking Math Question&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Asking Math Question&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig3-1024x99.jpg\" class=\"wp-image-3602\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig3.jpg?resize=550%2C53&#038;ssl=1\" alt=\"Asking Math Question\" width=\"550\" height=\"53\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig3.jpg?resize=300%2C29&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig3.jpg?resize=1024%2C99&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig3.jpg?resize=768%2C74&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig3.jpg?w=1042&amp;ssl=1 1042w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-3602\" class=\"wp-caption-text\"><strong>Asking Math Question<\/strong><\/figcaption><\/figure>\n<p>As you can see, the function calls the built-in function <em><strong>ask-chat<\/strong><\/em>, finally returning a numeric value.<\/p>\n<p>Let us see if this works as expected:<\/p>\n<figure id=\"attachment_3603\" aria-describedby=\"caption-attachment-3603\" style=\"width: 450px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig4.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3603\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2025\/01\/20\/using-openai-from-allegro-common-lisp\/fig4-5\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig4.jpg\" data-orig-size=\"795,192\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1737211396&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Asking Math Questions\" data-image-description=\"&lt;p&gt;Asking Math Questions&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Asking Math Questions&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig4.jpg\" class=\"wp-image-3603\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig4.jpg?resize=450%2C109&#038;ssl=1\" alt=\"Asking Math Questions\" width=\"450\" height=\"109\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig4.jpg?resize=300%2C72&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig4.jpg?resize=768%2C185&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig4.jpg?w=795&amp;ssl=1 795w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/a><figcaption id=\"caption-attachment-3603\" class=\"wp-caption-text\"><strong>Math Questions Examples<\/strong><\/figcaption><\/figure>\n<p>That is good! The answers are correct.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>Another built-in function is <em><strong>ask-for-list<\/strong><\/em>. This sends a prompt to the LLM and returns the answer in the form of a list. Let us ask the LLM to give us a list of positive and negtive sentiment English words.<\/p>\n<figure id=\"attachment_3604\" aria-describedby=\"caption-attachment-3604\" style=\"width: 500px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig5.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3604\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2025\/01\/20\/using-openai-from-allegro-common-lisp\/fig5-5\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig5.jpg\" data-orig-size=\"904,136\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1737211474&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Returning List of Values\" data-image-description=\"&lt;p&gt;Returning List of Values&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Returning List of Values&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig5.jpg\" class=\"wp-image-3604\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig5.jpg?resize=500%2C75&#038;ssl=1\" alt=\"Returning List of Values\" width=\"500\" height=\"75\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig5.jpg?resize=300%2C45&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig5.jpg?resize=768%2C116&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig5.jpg?w=904&amp;ssl=1 904w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption id=\"caption-attachment-3604\" class=\"wp-caption-text\"><strong>Returning List of Values<\/strong><\/figcaption><\/figure>\n<p>Another function <em><strong>ask-for-map<\/strong><\/em> is a variant of the above and it returns a list of key-value pairs. Let us ask for southern states of India and their respective capitals:<\/p>\n<figure id=\"attachment_3605\" aria-describedby=\"caption-attachment-3605\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig6.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3605\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2025\/01\/20\/using-openai-from-allegro-common-lisp\/fig6-3\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig6.jpg\" data-orig-size=\"1313,97\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1737211550&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Returning Maps\" data-image-description=\"&lt;p&gt;Returning Maps&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Returning Maps&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig6-1024x76.jpg\" class=\"wp-image-3605\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig6.jpg?resize=600%2C44&#038;ssl=1\" alt=\"Returning Maps\" width=\"600\" height=\"44\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig6.jpg?resize=300%2C22&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig6.jpg?resize=1024%2C76&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig6.jpg?resize=768%2C57&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig6.jpg?w=1313&amp;ssl=1 1313w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-3605\" class=\"wp-caption-text\"><strong>Returning Maps<\/strong><\/figcaption><\/figure>\n<p>A further generalization of the above is <strong>ask-for-table<\/strong>, which returns multiple values as a table:<\/p>\n<figure id=\"attachment_3606\" aria-describedby=\"caption-attachment-3606\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig7.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3606\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2025\/01\/20\/using-openai-from-allegro-common-lisp\/fig7-2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig7.jpg\" data-orig-size=\"1348,114\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1737211651&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Returning a Table of Values\" data-image-description=\"&lt;p&gt;Returning a Table of Values&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Returning a Table of Values&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig7-1024x87.jpg\" class=\"wp-image-3606\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig7.jpg?resize=600%2C51&#038;ssl=1\" alt=\"Returning a Table of Values\" width=\"600\" height=\"51\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig7.jpg?resize=300%2C25&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig7.jpg?resize=1024%2C87&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig7.jpg?resize=768%2C65&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig7.jpg?w=1348&amp;ssl=1 1348w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-3606\" class=\"wp-caption-text\"><strong>Returning a Table of Values<\/strong><\/figcaption><\/figure>\n<p>Here is the complete code that I wrote:<\/p>\n<figure id=\"attachment_3607\" aria-describedby=\"caption-attachment-3607\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig8.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3607\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2025\/01\/20\/using-openai-from-allegro-common-lisp\/fig8\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig8.jpg\" data-orig-size=\"1059,454\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Admin&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1737215722&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Source Code\" data-image-description=\"&lt;p&gt;Source Code&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Source Code&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig8-1024x439.jpg\" class=\"wp-image-3607\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig8.jpg?resize=550%2C236&#038;ssl=1\" alt=\"Source Code\" width=\"550\" height=\"236\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig8.jpg?resize=300%2C129&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig8.jpg?resize=1024%2C439&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig8.jpg?resize=768%2C329&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/01\/fig8.jpg?w=1059&amp;ssl=1 1059w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-3607\" class=\"wp-caption-text\"><strong>Source Code<\/strong><\/figcaption><\/figure>\n<p>In addition to directly interacting with the LLM, <em><strong>Allegro CL<\/strong><\/em> also supports Vector database and RAG. I will discuss this in a future article.<\/p>\n<p>It is not clear to me why Franz decided to support only <em><strong>OpenAI<\/strong><\/em> in this <em><strong>Alegro CL<\/strong><\/em> version. It is not difficult to support other vendors such as <em><strong>Anthropic<\/strong><\/em> and open-source models. That is a major disappointment for me. Hope they will include this in a future version soon.<\/p>\n<p>Have a nice week!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Allegro Common Lisp ver 11.0\u00a0introduced support for OpenAI LLMs. In this article, let us look at some of the functions for interacting with OpenAI. First we need to specify basic parameters such as the API key, LLM to use, Temperature, etc. I have defined a convenient function configure-openai to do this (full source is included [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18,388,17],"tags":[411,376,354],"class_list":["post-3599","post","type-post","status-publish","format-standard","hentry","category-lisp","category-openai","category-programming","tag-allegro-cl","tag-llm","tag-openai"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-W3","jetpack-related-posts":[{"id":3514,"url":"https:\/\/www.rangakrish.com\/index.php\/2024\/10\/02\/using-openai-from-mathematica-part-2\/","url_meta":{"origin":3599,"position":0},"title":"Using OpenAI from Mathematica: Part-2","author":"admin","date":"October 2, 2024","format":false,"excerpt":"I had written an earlier article\u00a0showing how to use OpenAI models from Mathematica ver 14.0.\u00a0 Wolfram Mathematica ver 14.1 was released recently, with several improvements in the area of LLMs. Of course, there are many other core additions as well, but our focus is on LLMs in this article. This\u2026","rel":"","context":"In &quot;Mathematica&quot;","block_context":{"text":"Mathematica","link":"https:\/\/www.rangakrish.com\/index.php\/category\/mathematica\/"},"img":{"alt_text":"LLMSynthesize Function","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/10\/image1-300x71.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/10\/image1-300x71.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/10\/image1-300x71.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3381,"url":"https:\/\/www.rangakrish.com\/index.php\/2024\/05\/20\/using-openai-from-mathematica\/","url_meta":{"origin":3599,"position":1},"title":"Using OpenAI from Mathematica","author":"admin","date":"May 20, 2024","format":false,"excerpt":"Mathematica was among the first to integrate with OpenAI. The functionality is nicely exposed in terms of a few pre-defined functions. Let us explore some of the functionality in today\u2019s article. The simplest way to get started is to use LLMSynthesize\u00a0function: It can take a few seconds before you get\u2026","rel":"","context":"In &quot;Mathematica&quot;","block_context":{"text":"Mathematica","link":"https:\/\/www.rangakrish.com\/index.php\/category\/mathematica\/"},"img":{"alt_text":"LLMSynthesize Function","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/05\/Example1-300x27.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/05\/Example1-300x27.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/05\/Example1-300x27.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3626,"url":"https:\/\/www.rangakrish.com\/index.php\/2025\/02\/21\/using-openai-from-mathematica-part-3\/","url_meta":{"origin":3599,"position":2},"title":"Using OpenAI from Mathematica: Part-3","author":"admin","date":"February 21, 2025","format":false,"excerpt":"Let us continue our discussion on using Mathematica to interact with OpenAI (you may want to go through the earlier article as well). The simplest function to interact with the LLM is LLMSynthesize[]. As you might have guessed, this is a \u201csync\u201d (non-streaming) call. What if you expect a long\u2026","rel":"","context":"In &quot;Mathematica&quot;","block_context":{"text":"Mathematica","link":"https:\/\/www.rangakrish.com\/index.php\/category\/mathematica\/"},"img":{"alt_text":"Basic LLMSynthesize","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/02\/fig1-300x21.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/02\/fig1-300x21.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/02\/fig1-300x21.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3050,"url":"https:\/\/www.rangakrish.com\/index.php\/2023\/03\/16\/building-a-xojo-app-to-interact-with-openai-api\/","url_meta":{"origin":3599,"position":3},"title":"Building a Xojo App to Interact with OpenAI API","author":"admin","date":"March 16, 2023","format":false,"excerpt":"A few weeks ago I registered with OpenAI to access its services through API and created a secret Key for my use. I then decided to build a simple application to try out the \u201cChat\u201d and \u201cCompletion\u201d models. Since I have several tools at my disposal (RAD Studio, LispWorks, Allegro\u2026","rel":"","context":"In &quot;OpenAI&quot;","block_context":{"text":"OpenAI","link":"https:\/\/www.rangakrish.com\/index.php\/category\/openai\/"},"img":{"alt_text":"Initial Screen","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/03\/Initial-Screen-300x232.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3650,"url":"https:\/\/www.rangakrish.com\/index.php\/2025\/03\/26\/exploring-openai-agent-sdk\/","url_meta":{"origin":3599,"position":4},"title":"Exploring OpenAI Agent SDK","author":"admin","date":"March 26, 2025","format":false,"excerpt":"OpenAI recently released its open-source Agents SDK. The documentation looked interesting, so I decided to give it a try. The SDK supports multiple agents working together using \u201chandoffs\u201d. The example I am using in today\u2019s article involves 3 agents: 1) Agent who specializes in answering questions on Planetary positions 2)\u2026","rel":"","context":"In &quot;OpenAI&quot;","block_context":{"text":"OpenAI","link":"https:\/\/www.rangakrish.com\/index.php\/category\/openai\/"},"img":{"alt_text":"Using Structured Output","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/03\/code1-1-300x121.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/03\/code1-1-300x121.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/03\/code1-1-300x121.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3660,"url":"https:\/\/www.rangakrish.com\/index.php\/2025\/04\/11\/using-claude-to-generate-rdf-triples\/","url_meta":{"origin":3599,"position":5},"title":"Using Claude to Generate RDF Triples","author":"admin","date":"April 11, 2025","format":false,"excerpt":"We all know that LLMs are now capable of generating structured data. I have used OpenAI models earlier to generate Tables and JSON data, but this time I wanted to try a more complex example.\u00a0 As someone interested in Homeopathy, I wanted to generate remedy descriptions as RDF triples, in\u2026","rel":"","context":"In &quot;Homeopathy&quot;","block_context":{"text":"Homeopathy","link":"https:\/\/www.rangakrish.com\/index.php\/category\/homeopathy\/"},"img":{"alt_text":"Lycopodium TTL Format","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/04\/Lyco-300x232.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/04\/Lyco-300x232.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/04\/Lyco-300x232.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/3599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/comments?post=3599"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/3599\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=3599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=3599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=3599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}