{"id":8803,"date":"2024-01-25T06:00:52","date_gmt":"2024-01-25T14:00:52","guid":{"rendered":"https:\/\/live-cometml.pantheonsite.io\/?p=8803"},"modified":"2025-04-24T17:03:27","modified_gmt":"2025-04-24T17:03:27","slug":"getting-started-with-openai-and-r-building-a-chat-interface-with-shiny","status":"publish","type":"post","link":"https:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny\/","title":{"rendered":"Getting Started with OpenAI and R: Building a Chat Interface with\u00a0Shiny"},"content":{"rendered":"\n<section class=\"section section--body\">\n<div class=\"section-divider\">\n<hr class=\"section-divider\">\n<\/div>\n<div class=\"section-content\">\n<div class=\"section-inner sectionLayout--insetColumn\">\n<h3 class=\"graf graf--h3 graf--empty\"><\/h3>\n<\/div>\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"graf-image alignnone\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1200\/1*cD6hNsPf0GWyKU65iOfuqw.png\" alt=\"graphic of 2 people coding\" width=\"1200\" height=\"675\" data-image-id=\"1*cD6hNsPf0GWyKU65iOfuqw.png\" data-width=\"1366\" data-height=\"768\" data-is-featured=\"true\"><\/figure><div class=\"section-inner sectionLayout--outsetColumn\">\n<figure class=\"graf graf--figure graf--layoutOutsetCenter\"><\/figure>\n<\/div>\n<div class=\"section-inner sectionLayout--insetColumn\">\n<p class=\"graf graf--p\">Picture a world where models can comprehend and reply to human language, facilitating genuine and smooth conversations. This remarkable concept is now a reality thanks to OpenAI&#8217;s advanced large language processing models. In this article, we will take a journey to examine a partnership between OpenAI and R, leading to the development of a lively and interactive chat interface utilizing the Shiny framework.<\/p>\n<p class=\"graf graf--p\">We will begin by setting up the OpenAI API and guiding you through acquiring the necessary keys to unlock its capabilities. As we delve deeper into R and its Shiny framework, you will discover the art of designing user-friendly interfaces that can hold conversations with users.<\/p>\n<h3 class=\"graf graf--h3\">Setting Up OpenAI&nbsp;API<\/h3>\n<p class=\"graf graf--p\">The OpenAI API is a valuable resource for developers, giving them access to advanced natural language processing models to integrate into their projects. These models can interpret and produce text that resembles human language, making them suitable for various applications like chatbots, virtual assistants, content creation, and translation. This section will explore the OpenAI API&#8217;s capabilities and guide you through the setup process.<\/p>\n<h4 class=\"graf graf--h4\">OpenAI API Capabilities<\/h4>\n<p class=\"graf graf--p\">The OpenAI API gives access to numerous language models, with GPT-3.5-Turbo being one of the most famous. The OpenAI API has the following significant capabilities:<\/p>\n<ul class=\"postList\">\n<li class=\"graf graf--li\">Natural Language Processing: The API is capable of analyzing and comprehending human language, allowing it to extract insights, sentiments, and meaning from text inputs.<\/li>\n<li class=\"graf graf--li\">Text Generation: Because it can generate human-like text responses, it is an excellent tool for developing chatbots, virtual assistants, and content generators.<\/li>\n<li class=\"graf graf--li\">Language Translation: The API can convert text from one language to another, making multilingual applications possible.<\/li>\n<li class=\"graf graf--li\">Summarizes: It can summarise extensive text passages, making it handy for crafting brief summaries of articles or documents.<\/li>\n<li class=\"graf graf--li\">Conversation Flow: Because the API can keep context and engage in dynamic dialogues, it is possible to create interactive chat interfaces.<\/li>\n<\/ul>\n<h4 class=\"graf graf--h4\">Signing Up for an OpenAI&nbsp;Account<\/h4>\n<p class=\"graf graf--p\">You&#8217;ll need to create an account before you can start using the OpenAI API. Here&#8217;s a simple guide to get you started:<\/p>\n<ol class=\"postList\">\n<li class=\"graf graf--li\">Head to the OpenAI Website: First, go to the OpenAI website by clicking <a class=\"markup--anchor markup--li-anchor\" href=\"http:\/\/www.openai.com\/\" target=\"_blank\" rel=\"noopener\" data-href=\"http:\/\/www.openai.com\">here<\/a><a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/www.openai.com\/]%28https:\/\/www.openai.com\/%29.\" target=\"_blank\" rel=\"nofollow noopener\" data-href=\"https:\/\/www.openai.com\/](https:\/\/www.openai.com\/).\">.<\/a><\/li>\n<li class=\"graf graf--li\">Locate the &#8220;Get Started&#8221; Button: Look for the &#8220;Get Started&#8221; button in the top-right corner of the page.<\/li>\n<\/ol>\n<figure class=\"graf graf--figure\"><img loading=\"lazy\" decoding=\"async\" class=\"graf-image alignnone\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*oTzNSQJukN3_IRble594Qg.png\" alt=\"openAI home page\" width=\"800\" height=\"404\" data-image-id=\"1*oTzNSQJukN3_IRble594Qg.png\" data-width=\"1341\" data-height=\"677\"><figcaption class=\"imageCaption\">Source: openai.com<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p class=\"graf graf--p\">3. Create Your Account: You&#8217;ll be asked to create an account by entering your email address and choosing a secure password.<\/p>\n<figure class=\"graf graf--figure\"><img loading=\"lazy\" decoding=\"async\" class=\"graf-image alignnone\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*sbCSNKKDbObX3xBF8wJbHw.png\" alt=\"screenshot of creating an OpenAI account\" width=\"800\" height=\"404\" data-image-id=\"1*sbCSNKKDbObX3xBF8wJbHw.png\" data-width=\"1366\" data-height=\"690\"><p><\/p>\n<figcaption class=\"imageCaption\">Source: openai.com<\/figcaption>\n<\/figure>\n<p>&nbsp;<\/p>\n<p class=\"graf graf--p\">4. Finish the Registration Process: Follow the prompts on the screen to complete the registration process, which may involve verifying your email address.<\/p>\n<p class=\"graf graf--p\">5. Sign In to Your Account: Once your account is set up, you can access the OpenAI platform by logging in with your email and password.<\/p>\n<h4 class=\"graf graf--h4\">Obtaining an API&nbsp;Key<\/h4>\n<p class=\"graf graf--p\">To use the OpenAI API, you&#8217;ll need an API key. Here&#8217;s how you can obtain it:<\/p>\n<ol class=\"postList\">\n<li class=\"graf graf--li\">Navigate to the API Section: After logging in to your OpenAI account, navigate to the API section. This is typically found in your account dashboard.<\/li>\n<\/ol>\n<figure class=\"graf graf--figure\"><img loading=\"lazy\" decoding=\"async\" class=\"graf-image alignnone\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*sHS2QSASs0MdMUiWh4Fvwg.png\" alt=\"screenshot of navigating to API screen in OpenAI\" width=\"800\" height=\"402\" data-image-id=\"1*sHS2QSASs0MdMUiWh4Fvwg.png\" data-width=\"1336\" data-height=\"672\"><p><\/p>\n<figcaption class=\"imageCaption\">Source: openai.com<\/figcaption>\n<\/figure>\n<p>&nbsp;<\/p>\n<p class=\"graf graf--p\">2. View API Keys: Navigate to the top right corner and click on the &#8220;Personal&#8221; link; from the dropdown, click View API Keys<\/p>\n<figure class=\"graf graf--figure\"><img loading=\"lazy\" decoding=\"async\" class=\"graf-image alignnone\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*vSzCzXGKFsIKRP2DXnB3Zw.png\" alt=\"OpenAI platform screenshot\" width=\"800\" height=\"431\" data-image-id=\"1*vSzCzXGKFsIKRP2DXnB3Zw.png\" data-width=\"1361\" data-height=\"733\"><p><\/p>\n<figcaption class=\"imageCaption\">Source: Author&#8217;s Openai&nbsp;account<\/figcaption>\n<\/figure>\n<p>&nbsp;<\/p>\n<p class=\"graf graf--p\">3. Create an API Key: In the API Keys section, you can create a new API secret key. Click on the &#8220;Create new secret key&#8221;.<\/p>\n<figure class=\"graf graf--figure\"><img loading=\"lazy\" decoding=\"async\" class=\"graf-image alignnone\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*jPUTDMcGjNTKZFBQDtss0Q.png\" alt=\"screenshot of creating an API key in OpenAI\" width=\"800\" height=\"424\" data-image-id=\"1*jPUTDMcGjNTKZFBQDtss0Q.png\" data-width=\"1360\" data-height=\"720\"><p><\/p>\n<figcaption class=\"imageCaption\">Source: Author&#8217;s OpenAI&nbsp;account<\/figcaption>\n<\/figure>\n<p>&nbsp;<\/p>\n<p class=\"graf graf--p\">4. Generate the API Key: Fill out the name for the secret key you are about to generate. Though the name is optional, you can click on Create Secret Key.<\/p>\n<figure class=\"graf graf--figure\"><img loading=\"lazy\" decoding=\"async\" class=\"graf-image alignnone\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*kpgYjH-G3Eid5gmbEsN16A.png\" alt=\"screenshot of API keys in OpenAI\" width=\"800\" height=\"422\" data-image-id=\"1*kpgYjH-G3Eid5gmbEsN16A.png\" data-width=\"1363\" data-height=\"719\"><p><\/p>\n<figcaption class=\"imageCaption\">Source: Author&#8217;s OpenAI&nbsp;account<\/figcaption>\n<\/figure>\n<p>&nbsp;<\/p>\n<p class=\"graf graf--p\">5. Secure Your API Key: Once your key is generated, copy it, as you can only access it once. Ensure you save your key details in a safe location and that they are not shared publicly.<\/p>\n<figure class=\"graf graf--figure\"><img loading=\"lazy\" decoding=\"async\" class=\"graf-image alignnone\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*KqQbiIIQ-K2GDkRI39iJ0A.png\" alt=\"screenshot of API keys in OpenAI\" width=\"800\" height=\"427\" data-image-id=\"1*KqQbiIIQ-K2GDkRI39iJ0A.png\" data-width=\"1343\" data-height=\"717\"><p><\/p>\n<figcaption class=\"imageCaption\">Source: Author&#8217;s OpenAI&nbsp;account<\/figcaption>\n<\/figure>\n<p>&nbsp;<\/p>\n<p class=\"graf graf--p\">With your OpenAI account and API key, you can use the OpenAI API to build powerful natural language processing applications.<\/p>\n<p class=\"graf graf--p\">In the following sections, we&#8217;ll delve into integrating the OpenAI API with R and creating interactive chat interfaces using R Shiny.<\/p>\n<h3 class=\"graf graf--h3\">R Shiny&nbsp;Basics<\/h3>\n<p class=\"graf graf--p\">Shiny is an innovative web application framework for the R programming language designed to streamline the development of interactive and data-driven web applications. With its user-friendly interface and powerful capabilities, Shiny empowers data scientists and analysts to create custom web-based solutions for data visualization, analysis, and decision support, all within the R ecosystem. You can read more on the Shiny framework<a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/shiny.posit.co\/\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/shiny.posit.co\/\"> here<\/a>.<\/p>\n<h4 class=\"graf graf--h4\">What is Shiny and Its Use in Building Web Applications in&nbsp;R?<\/h4>\n<p class=\"graf graf--p\">Shiny acts as a bridge between the web and R&#8217;s data analysis capabilities. It makes building web apps for R users simple. Here are some of Shiny&#8217;s key characteristics:<\/p>\n<ul class=\"postList\">\n<li class=\"graf graf--li\">Reactivity: Shiny apps may react in real-time to user interaction because they are reactive by nature. A crucial component that enables the creation of interactive and dynamic online programs is responsiveness.<\/li>\n<li class=\"graf graf--li\">UI: Shiny offers tools and elements for building user interfaces for online programs. These UI elements can create interactive dashboards, data entry forms, visualizations, and other things.<\/li>\n<li class=\"graf graf--li\">Shiny applications come with a server component that executes R code. Shiny programs are very flexible because this server logic can take user inputs, perform calculations, and return dynamic outcomes.<\/li>\n<li class=\"graf graf--li\">Integration with R: Shiny interfaces with R easily, allowing you to leverage current R code, statistical models, data analysis pipelines, and data visualization techniques in your web applications.<\/li>\n<li class=\"graf graf--li\">Deployment: Shiny applications are easy to share with others and deploy. You have a few options for hosting them: your server, Shiny Server, Posit Connect, or the Shinyapps.io hosting platform.<\/li>\n<li class=\"graf graf--li\">Customization: Shiny facilitates web development but doesn&#8217;t limit your imagination. Using HTML and CSS, you can, if necessary, change the appearance and functionality of your applications.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/section>\n\n\n\n<section class=\"section section--body\">\n<div class=\"section-divider\">\n<hr class=\"section-divider\">\n<\/div>\n<div class=\"section-content\">\n<div class=\"section-inner sectionLayout--insetColumn\">\n<p class=\"graf graf--p\">Now that we have introduced the technologies we will be using, let&#8217;s dive into development.<\/p>\n<h3 class=\"graf graf--h3\">Prerequisites<\/h3>\n<p class=\"graf graf--p\">To get started, have R and RStudio installed on your computer. R is the programming language we&#8217;ll be using, while RStudio is an integrated development environment that will make working with R much easier.<\/p>\n<ul class=\"postList\">\n<li class=\"graf graf--li\">To download R, go to the official CRAN website (<a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/cran.r-project.org\/\" target=\"_blank\" rel=\"nofollow noopener\" data-href=\"https:\/\/cran.r-project.org\/\">https:\/\/cran.r-project.org\/<\/a>).<\/li>\n<li class=\"graf graf--li\">To get RStudio, visit the RStudio download page (<a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/www.rstudio.com\/products\/rstudio\/download\/\" target=\"_blank\" rel=\"nofollow noopener\" data-href=\"https:\/\/www.rstudio.com\/products\/rstudio\/download\/\">https:\/\/www.rstudio.com\/products\/rstudio\/download\/<\/a>).<\/li>\n<\/ul>\n<h4 class=\"graf graf--h4\"><strong class=\"markup--strong markup--h4-strong\">Installing Required&nbsp;Packages<\/strong><\/h4>\n<p class=\"graf graf--p\">Now that you have the foundational tools, we must install a few R packages to help us build our chat interface. Open RStudio, and in your R script or console, run the following commands:<\/p>\n<pre class=\"graf graf--pre graf--preV2\" spellcheck=\"false\" data-code-block-mode=\"2\" data-code-block-lang=\"r\"><span class=\"pre--content\">install.packages<span class=\"hljs-punctuation\">(<\/span><span class=\"hljs-string\">\"shiny\"<\/span><span class=\"hljs-punctuation\">,<\/span><span class=\"hljs-string\">\"openai\"<\/span><span class=\"hljs-punctuation\">,<\/span><span class=\"hljs-string\">\"jsonlite\"<\/span><span class=\"hljs-punctuation\">)<\/span><\/span><\/pre>\n<ul class=\"postList\">\n<li class=\"graf graf--li\">You can go through the Shiny documentation <a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/cran.r-project.org\/web\/packages\/shiny\/shiny.pdf\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/cran.r-project.org\/web\/packages\/shiny\/shiny.pdf\">here<\/a><\/li>\n<li class=\"graf graf--li\">The documentation for OpenAI in R is <a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/cran.r-project.org\/web\/packages\/openai\/openai.pdf\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/cran.r-project.org\/web\/packages\/openai\/openai.pdf\">here<\/a><\/li>\n<li class=\"graf graf--li\"><a class=\"markup--anchor markup--li-anchor\" href=\"https:\/\/cran.r-project.org\/web\/packages\/jsonlite\/index.html\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/cran.r-project.org\/web\/packages\/jsonlite\/index.html\">Jsonlite<\/a> package helps us to process JSON responses<\/li>\n<\/ul>\n<h4 class=\"graf graf--h4\">Loading the Required Packages and Setting the Environment<\/h4>\n<pre class=\"graf graf--pre graf--preV2\" spellcheck=\"false\" data-code-block-mode=\"2\" data-code-block-lang=\"r\"><span class=\"pre--content\">library<span class=\"hljs-punctuation\">(<\/span>shiny<span class=\"hljs-punctuation\">)<\/span>\nlibrary<span class=\"hljs-punctuation\">(<\/span>openai<span class=\"hljs-punctuation\">)<\/span>\nlibrary<span class=\"hljs-punctuation\">(<\/span>jsonlite<span class=\"hljs-punctuation\">)<\/span>\n\n<span class=\"hljs-comment\">##Setting the enviroment variables<\/span>\nSys.setenv<span class=\"hljs-punctuation\">(<\/span>openai_api_key <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-string\">\"{secret_key}\"<\/span><span class=\"hljs-punctuation\">)<\/span>\n<span class=\"hljs-comment\">#{Secret_key-- Input the secret key you copied from your Openai account here<\/span><\/span><\/pre>\n<p class=\"graf graf--p\">Shiny utilizes its two fundamental components: the UI (User Interface) and the server.<\/p>\n<h4 class=\"graf graf--h4\">Shiny&#8217;s UI Component<\/h4>\n<p class=\"graf graf--p\">The UI component of Shiny is responsible for defining the layout and appearance of your web application. It provides a range of functions and elements that allow you to create a user-friendly interface for your application. Let&#8217;s develop the UI for the chat interface:<\/p>\n<pre class=\"graf graf--pre graf--preV2\" spellcheck=\"false\" data-code-block-mode=\"2\" data-code-block-lang=\"r\"><span class=\"pre--content\">ui <span class=\"hljs-operator\">&lt;-<\/span> fluidPage<span class=\"hljs-punctuation\">(<\/span>\n  titlePanel<span class=\"hljs-punctuation\">(<\/span><span class=\"hljs-string\">\"Chat Interface\"<\/span><span class=\"hljs-punctuation\">)<\/span><span class=\"hljs-punctuation\">,<\/span>\n  sidebarLayout<span class=\"hljs-punctuation\">(<\/span>\n    sidebarPanel<span class=\"hljs-punctuation\">(<\/span>\n      textInput<span class=\"hljs-punctuation\">(<\/span><span class=\"hljs-string\">\"user_message\"<\/span><span class=\"hljs-punctuation\">,<\/span> <span class=\"hljs-string\">\"Enter your message:\"<\/span><span class=\"hljs-punctuation\">)<\/span><span class=\"hljs-punctuation\">,<\/span>\n      sliderInput<span class=\"hljs-punctuation\">(<\/span><span class=\"hljs-string\">\"temperature\"<\/span><span class=\"hljs-punctuation\">,<\/span> <span class=\"hljs-string\">\"Temperature:\"<\/span><span class=\"hljs-punctuation\">,<\/span> <span class=\"hljs-built_in\">min<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-number\">0<\/span><span class=\"hljs-punctuation\">,<\/span> <span class=\"hljs-built_in\">max<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-number\">1<\/span><span class=\"hljs-punctuation\">,<\/span> value <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-number\">0.7<\/span><span class=\"hljs-punctuation\">,<\/span> step <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-number\">0.1<\/span><span class=\"hljs-punctuation\">)<\/span><span class=\"hljs-punctuation\">,<\/span>\n      actionButton<span class=\"hljs-punctuation\">(<\/span><span class=\"hljs-string\">\"submit_message\"<\/span><span class=\"hljs-punctuation\">,<\/span> <span class=\"hljs-string\">\"Submit Message\"<\/span><span class=\"hljs-punctuation\">)<\/span>\n    <span class=\"hljs-punctuation\">)<\/span><span class=\"hljs-punctuation\">,<\/span>\n    mainPanel<span class=\"hljs-punctuation\">(<\/span>\n      <span class=\"hljs-comment\"># in the UI function<\/span>\n      titlePanel<span class=\"hljs-punctuation\">(<\/span><span class=\"hljs-string\">\"Response:\"<\/span><span class=\"hljs-punctuation\">)<\/span><span class=\"hljs-punctuation\">,<\/span>\n      textOutput<span class=\"hljs-punctuation\">(<\/span>outputId <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-string\">\"assistant\"<\/span><span class=\"hljs-punctuation\">)<\/span>\n    <span class=\"hljs-punctuation\">)<\/span>\n  <span class=\"hljs-punctuation\">)<\/span>\n<span class=\"hljs-punctuation\">)<\/span><\/span><\/pre>\n<p class=\"graf graf--p\">This Shiny UI code creates a web page with a user-friendly chat interface. Users can input chat messages, adjust the temperature of responses, and click the &#8220;Submit Message&#8221; button. The chatbot&#8217;s responses will be displayed in the &#8220;Response&#8221; section of the web page as text outputs. Here&#8217;s a brief explanation of the code:<\/p>\n<ul class=\"postList\">\n<li class=\"graf graf--li\">`fluidPage`: In Shiny, the `fluidPage` function designs a web page layout that automatically adapts its content to the dimensions of the user&#8217;s web browser window.<\/li>\n<li class=\"graf graf--li\">&#8211; `titlePanel`: This function&#8217;s role is to establish a title panel at the top section of the webpage. In this instance, it assigns the title &#8220;Chat Interface&#8221; to the page.<br>\n&#8211; `sidebarLayout`: The `sidebarLayout` function defines the overall webpage layout, typically featuring a sidebar panel on the left and a main panel on the right.<br>\n&#8211; `sidebarPanel`: Nested within the sidebar panel are several UI elements:<br>\n\u2014\u200a`textInput`: This function creates a text input box labeled &#8220;Enter your message.&#8221; Users can utilize this input box to input their chat messages.<br>\n\u2014\u200a`sliderInput`: The `sliderInput` function aims to generate a slider labeled &#8220;Temperature.&#8221; Sliders enable users to modify a numerical value within a specified range. In this context, it regulates the temperature, a hyperparameter influencing the text generation&#8217;s randomness. Values between 0 and 1 are valid, with lower values yielding more focused and deterministic text, while higher values introduce greater randomness.<br>\n\u2014\u200a`actionButton`: This function generates a button labeled &#8220;Submit Message.&#8221; Users can employ this button to submit their chat messages.<\/li>\n<li class=\"graf graf--li\">`mainPanel`: Within the main panel, the subsequent elements are defined:<br>\n&#8211; `titlePanel`: Another title panel is created, labeled &#8220;Response.&#8221; This title serves to distinguish the input section from the response section.<br>\n&#8211; `textOutput`: This function designates a region where the chatbot or assistant&#8217;s responses will be exhibited. It specifies the `outputId` as &#8220;assistant_response,&#8221; which facilitates the dynamic updating of this area with the chatbot&#8217;s responses.<\/li>\n<\/ul>\n<h4 class=\"graf graf--h4\">Shiny&#8217;s Server Component<\/h4>\n<p class=\"graf graf--p\">The server component of Shiny is where the application&#8217;s logic resides. It handles user inputs, processes data, and generates dynamic outputs. Let&#8217;s write the server component:<\/p>\n<pre class=\"graf graf--pre graf--preV2\" spellcheck=\"false\" data-code-block-mode=\"2\" data-code-block-lang=\"r\"><span class=\"pre--content\">server <span class=\"hljs-operator\">&lt;-<\/span> <span class=\"hljs-keyword\">function<\/span><span class=\"hljs-punctuation\">(<\/span>input<span class=\"hljs-punctuation\">,<\/span> output<span class=\"hljs-punctuation\">,<\/span> session<span class=\"hljs-punctuation\">)<\/span> <span class=\"hljs-punctuation\">{<\/span>\n  chat_history <span class=\"hljs-operator\">&lt;-<\/span> <span class=\"hljs-built_in\">list<\/span><span class=\"hljs-punctuation\">(<\/span><span class=\"hljs-punctuation\">)<\/span>  <span class=\"hljs-comment\"># Store chat history<\/span>\n\n  observeEvent<span class=\"hljs-punctuation\">(<\/span>input<span class=\"hljs-operator\">$<\/span>submit_message<span class=\"hljs-punctuation\">,<\/span> <span class=\"hljs-punctuation\">{<\/span>\n    user_message <span class=\"hljs-operator\">&lt;-<\/span> input<span class=\"hljs-operator\">$<\/span>user_message\n\n    <span class=\"hljs-comment\"># Add user's message to chat history<\/span>\n    chat_history <span class=\"hljs-operator\">&lt;-<\/span> append<span class=\"hljs-punctuation\">(<\/span>chat_history<span class=\"hljs-punctuation\">,<\/span> <span class=\"hljs-built_in\">list<\/span><span class=\"hljs-punctuation\">(<\/span><span class=\"hljs-built_in\">list<\/span><span class=\"hljs-punctuation\">(<\/span><span class=\"hljs-string\">\"role\"<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-string\">\"user\"<\/span><span class=\"hljs-punctuation\">,<\/span>\n                               <span class=\"hljs-string\">\"content\"<\/span> <span class=\"hljs-operator\">=<\/span> user_message<span class=\"hljs-punctuation\">)<\/span><span class=\"hljs-punctuation\">)<\/span><span class=\"hljs-punctuation\">)<\/span>\n\n    <span class=\"hljs-comment\"># Clear the user input field<\/span>\n    updateTextInput<span class=\"hljs-punctuation\">(<\/span>session<span class=\"hljs-punctuation\">,<\/span> <span class=\"hljs-string\">\"user_message\"<\/span><span class=\"hljs-punctuation\">,<\/span> value <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-string\">\"\"<\/span><span class=\"hljs-punctuation\">)<\/span>\n\n    <span class=\"hljs-comment\"># Call the create_chat_completion function<\/span>\n    assistant_response <span class=\"hljs-operator\">&lt;-<\/span> create_chat_completion<span class=\"hljs-punctuation\">(<\/span>\n      model <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-string\">\"gpt-3.5-turbo\"<\/span><span class=\"hljs-punctuation\">,<\/span>\n      messages <span class=\"hljs-operator\">=<\/span> chat_history<span class=\"hljs-punctuation\">,<\/span>\n      temperature <span class=\"hljs-operator\">=<\/span> input<span class=\"hljs-operator\">$<\/span>temperature<span class=\"hljs-punctuation\">,<\/span>\n      openai_api_key <span class=\"hljs-operator\">=<\/span> Sys.getenv<span class=\"hljs-punctuation\">(<\/span><span class=\"hljs-string\">\"openai_api_key\"<\/span><span class=\"hljs-punctuation\">)<\/span>\n    <span class=\"hljs-punctuation\">)<\/span>\n\n    <span class=\"hljs-comment\"># Extract and append assistant's response content to chat history<\/span>\n    assistant_content <span class=\"hljs-operator\">&lt;-<\/span> assistant_response<span class=\"hljs-punctuation\">[[<\/span><span class=\"hljs-number\">5<\/span><span class=\"hljs-punctuation\">]<\/span><span class=\"hljs-punctuation\">]<\/span>\n    chat_history <span class=\"hljs-operator\">&lt;-<\/span> append<span class=\"hljs-punctuation\">(<\/span>chat_history<span class=\"hljs-punctuation\">,<\/span> <span class=\"hljs-built_in\">list<\/span><span class=\"hljs-punctuation\">(<\/span><span class=\"hljs-built_in\">list<\/span><span class=\"hljs-punctuation\">(<\/span><span class=\"hljs-string\">\"role\"<\/span> <span class=\"hljs-operator\">=<\/span> <span class=\"hljs-string\">\"assistant\"<\/span><span class=\"hljs-punctuation\">,<\/span>\n                                              <span class=\"hljs-string\">\"content\"<\/span> <span class=\"hljs-operator\">=<\/span> assistant_content<span class=\"hljs-punctuation\">)<\/span><span class=\"hljs-punctuation\">)<\/span><span class=\"hljs-punctuation\">)<\/span>\n    <span class=\"hljs-comment\"># Update the chat display in the mainPanel<\/span>\n    output<span class=\"hljs-operator\">$<\/span>assistant <span class=\"hljs-operator\">&lt;-<\/span>\n      renderText<span class=\"hljs-punctuation\">(<\/span><span class=\"hljs-punctuation\">{<\/span>\n        paste<span class=\"hljs-punctuation\">(<\/span>assistant_content<span class=\"hljs-punctuation\">[<\/span><span class=\"hljs-number\">4<\/span><span class=\"hljs-punctuation\">]<\/span><span class=\"hljs-punctuation\">)<\/span>\n      <span class=\"hljs-punctuation\">}<\/span><span class=\"hljs-punctuation\">)<\/span>\n\n     <span class=\"hljs-punctuation\">}<\/span><span class=\"hljs-punctuation\">)<\/span>\n    <span class=\"hljs-punctuation\">}<\/span><\/span><\/pre>\n<p class=\"graf graf--p\">This server code handles the submission of user messages, interacts with the OpenAI API to generate an assistant&#8217;s response, updates the chat history, and displays the conversation in the chat interface. It ensures that the Shiny web application processes and displays user messages and assistant responses.<\/p>\n<ul class=\"postList\">\n<li class=\"graf graf--li\"><code class=\"markup--code markup--li-code\">server<\/code>: This is the server function in Shiny, which handles the server-side logic of the web application. It takes three arguments: <code class=\"markup--code markup--li-code\">input<\/code>, <code class=\"markup--code markup--li-code\">output<\/code>, and <code class=\"markup--code markup--li-code\">session<\/code>.<\/li>\n<li class=\"graf graf--li\"><code class=\"markup--code markup--li-code\">chat_history<\/code>: This list stores the conversation history in the chat interface. Each message in the conversation is represented as a list with a &#8220;role&#8221; and &#8220;content&#8221; key.<\/li>\n<li class=\"graf graf--li\"><code class=\"markup--code markup--li-code\">observeEvent(input$submit_message, {...})<\/code>: This part of the code sets up an observer that watches for the event when the &#8220;Submit Message&#8221; button is clicked (<code class=\"markup--code markup--li-code\">input$submit_message<\/code>). When the button is clicked, the code within the block is executed.<\/li>\n<li class=\"graf graf--li\"><code class=\"markup--code markup--li-code\">user_message &lt;- input$user_message<\/code>: It captures the user&#8217;s message from the text input field (<code class=\"markup--code markup--li-code\">input$user_message<\/code>) and stores it in the <code class=\"markup--code markup--li-code\">user_message<\/code> variable.<\/li>\n<li class=\"graf graf--li\"><code class=\"markup--code markup--li-code\">chat_history &lt;- append(...)<\/code>: This line appends the user&#8217;s message to the <code class=\"markup--code markup--li-code\">chat_history<\/code> list as a new entry with the role &#8220;user&#8221; and the content being the user&#8217;s message.<\/li>\n<li class=\"graf graf--li\"><code class=\"markup--code markup--li-code\">updateTextInput(...)<\/code>: It clears the user input field (<code class=\"markup--code markup--li-code\">input$user_message<\/code>) by updating its value to an empty string and removing the text box after the user submits a message.<\/li>\n<li class=\"graf graf--li\"><code class=\"markup--code markup--li-code\">create_chat_completion(...)<\/code>: This line calls the <code class=\"markup--code markup--li-code\">create_chat_completion<\/code> function, and interacts with the OpenAI API. It sends the user&#8217;s chat history, including their message, to the OpenAI model for generating an assistant&#8217;s response. The <code class=\"markup--code markup--li-code\">temperature<\/code> parameter is used to control the randomness of the response.<\/li>\n<li class=\"graf graf--li\"><code class=\"markup--code markup--li-code\">assistant_content &lt;- assistant_response[[5]]<\/code>: This line extracts the content of the assistant&#8217;s response from the <code class=\"markup--code markup--li-code\">assistant_response<\/code>. The specific index <code class=\"markup--code markup--li-code\">[5]<\/code> corresponds to the content of the response.<\/li>\n<li class=\"graf graf--li\"><code class=\"markup--code markup--li-code\">output$assistant &lt;- renderText({...})<\/code>: This part defines a text output element named <code class=\"markup--code markup--li-code\">assistant<\/code>. It renders the assistant&#8217;s response content and makes it available for display in the UI.<\/li>\n<\/ul>\n<h4 class=\"graf graf--h4\">Interaction Between UI and&nbsp;Server<\/h4>\n<p class=\"graf graf--p\">The beauty of Shiny is its ability to connect the UI and server components seamlessly. Whenever a user interacts with a UI element, like submitting a form or adjusting a slider, the server component responds by running the necessary R code. The changes are then displayed in the UI, creating an engaging and interactive user interface.<\/p>\n<pre class=\"graf graf--pre graf--preV2\" spellcheck=\"false\" data-code-block-mode=\"2\" data-code-block-lang=\"r\"><span class=\"pre--content\"><span class=\"hljs-comment\">#Add the final Shiny code that integrate the UI and the Server logic together<\/span>\nshinyApp<span class=\"hljs-punctuation\">(<\/span>ui<span class=\"hljs-punctuation\">,<\/span> server<span class=\"hljs-punctuation\">)<\/span><\/span><\/pre>\n<p class=\"graf graf--p\">After adding all the code to your R script, run the app and open the interface in your browser.<\/p>\n<figure class=\"graf graf--figure\"><img loading=\"lazy\" decoding=\"async\" class=\"graf-image alignnone\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*OQ8E3TD87TyTZkeasNr6SQ.png\" alt=\"code screenshot in R\" width=\"800\" height=\"419\" data-image-id=\"1*OQ8E3TD87TyTZkeasNr6SQ.png\" data-width=\"924\" data-height=\"484\"><p><\/p>\n<figcaption class=\"imageCaption\">Source: Author<\/figcaption>\n<\/figure>\n<figure class=\"graf graf--figure\"><img loading=\"lazy\" decoding=\"async\" class=\"graf-image alignnone\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*MsDC_aevKE2EeQsutuhIhA.png\" alt=\"Shiny screenshot\" width=\"800\" height=\"548\" data-image-id=\"1*MsDC_aevKE2EeQsutuhIhA.png\" data-width=\"895\" data-height=\"613\"><p><\/p>\n<figcaption class=\"imageCaption\">Source: Author<\/figcaption>\n<\/figure>\n<\/div>\n<div class=\"section-inner sectionLayout--outsetColumn\">\n<figure class=\"graf graf--figure graf--layoutOutsetCenter\"><img loading=\"lazy\" decoding=\"async\" class=\"graf-image alignnone\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1200\/1*vft8Qdga2Ux5uwOUufkr0g.png\" alt=\"chat interface\" width=\"1200\" height=\"675\" data-image-id=\"1*vft8Qdga2Ux5uwOUufkr0g.png\" data-width=\"1366\" data-height=\"768\"><p><\/p>\n<figcaption class=\"imageCaption\">Source: Author<\/figcaption>\n<\/figure>\n<figure class=\"graf graf--figure graf--layoutOutsetCenter\"><img loading=\"lazy\" decoding=\"async\" class=\"graf-image alignnone\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1200\/1*-xXBuwWZBJlReNYfeoheKQ.png\" alt=\"chat interface\" width=\"1200\" height=\"675\" data-image-id=\"1*-xXBuwWZBJlReNYfeoheKQ.png\" data-width=\"1366\" data-height=\"768\"><p><\/p>\n<figcaption class=\"imageCaption\">Source: Author<\/figcaption>\n<\/figure>\n<\/div>\n<div class=\"section-inner sectionLayout--insetColumn\">\n<h3 class=\"graf graf--h3\">Conclusion<\/h3>\n<p class=\"graf graf--p\">This article explored the combination of OpenAI and R in creating chat interfaces. You can build engaging and interactive chatbots with natural language processing and analytical capabilities by using OpenAI&#8217;s language models like GPT-3.5-Turbo and seamlessly integrating them with R Shiny. This fusion has numerous benefits, including real-time interactivity and effortless deployment. When building chat interfaces, it can be helpful to explore advanced features and customization options so that your chatbot can be tailored to specific industries and applications. Armed with this knowledge, you can create chat interfaces that are intelligent, responsive, and highly functional, ultimately enhancing user experiences and streamlining interactions across diverse domains.<\/p>\n<p class=\"graf graf--p\">You can access the repo for the project <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/github.com\/Nerdthink\/R_and_Openai\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/github.com\/Nerdthink\/R_and_Openai\">here<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>Picture a world where models can comprehend and reply to human language, facilitating genuine and smooth conversations. This remarkable concept is now a reality thanks to OpenAI&#8217;s advanced large language processing models. In this article, we will take a journey to examine a partnership between OpenAI and R, leading to the development of a lively [&hellip;]<\/p>\n","protected":false},"author":103,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"customer_name":"","customer_description":"","customer_industry":"","customer_technologies":"","customer_logo":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[7],"tags":[],"coauthors":[201],"class_list":["post-8803","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>OpenAI and R: Building a Chat Interface with\u00a0Shiny<\/title>\n<meta name=\"description\" content=\"Explore the combination of OpenAI and R in creating chat interfaces and seamlessly integrating them with R Shiny.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Getting Started with OpenAI and R: Building a Chat Interface with\u00a0Shiny\" \/>\n<meta property=\"og:description\" content=\"Explore the combination of OpenAI and R in creating chat interfaces and seamlessly integrating them with R Shiny.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny\" \/>\n<meta property=\"og:site_name\" content=\"Comet\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cometdotml\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-25T14:00:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-24T17:03:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn-images-1.medium.com\/max\/1200\/1*cD6hNsPf0GWyKU65iOfuqw.png\" \/>\n<meta name=\"author\" content=\"Daniel Tope Omole\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Cometml\" \/>\n<meta name=\"twitter:site\" content=\"@Cometml\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Daniel Tope Omole\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"OpenAI and R: Building a Chat Interface with\u00a0Shiny","description":"Explore the combination of OpenAI and R in creating chat interfaces and seamlessly integrating them with R Shiny.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny","og_locale":"en_US","og_type":"article","og_title":"Getting Started with OpenAI and R: Building a Chat Interface with\u00a0Shiny","og_description":"Explore the combination of OpenAI and R in creating chat interfaces and seamlessly integrating them with R Shiny.","og_url":"https:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny","og_site_name":"Comet","article_publisher":"https:\/\/www.facebook.com\/cometdotml","article_published_time":"2024-01-25T14:00:52+00:00","article_modified_time":"2025-04-24T17:03:27+00:00","og_image":[{"url":"https:\/\/cdn-images-1.medium.com\/max\/1200\/1*cD6hNsPf0GWyKU65iOfuqw.png","type":"","width":"","height":""}],"author":"Daniel Tope Omole","twitter_card":"summary_large_image","twitter_creator":"@Cometml","twitter_site":"@Cometml","twitter_misc":{"Written by":"Daniel Tope Omole","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny#article","isPartOf":{"@id":"http:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny\/"},"author":{"name":"Daniel Tope Omole","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/47487ed5fe7e7af5875cb22018195ab9"},"headline":"Getting Started with OpenAI and R: Building a Chat Interface with\u00a0Shiny","datePublished":"2024-01-25T14:00:52+00:00","dateModified":"2025-04-24T17:03:27+00:00","mainEntityOfPage":{"@id":"http:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny\/"},"wordCount":2025,"publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny#primaryimage"},"thumbnailUrl":"https:\/\/cdn-images-1.medium.com\/max\/1200\/1*cD6hNsPf0GWyKU65iOfuqw.png","articleSection":["Tutorials"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny\/","url":"https:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny","name":"OpenAI and R: Building a Chat Interface with\u00a0Shiny","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny#primaryimage"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny#primaryimage"},"thumbnailUrl":"https:\/\/cdn-images-1.medium.com\/max\/1200\/1*cD6hNsPf0GWyKU65iOfuqw.png","datePublished":"2024-01-25T14:00:52+00:00","dateModified":"2025-04-24T17:03:27+00:00","description":"Explore the combination of OpenAI and R in creating chat interfaces and seamlessly integrating them with R Shiny.","breadcrumb":{"@id":"https:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny#primaryimage","url":"https:\/\/cdn-images-1.medium.com\/max\/1200\/1*cD6hNsPf0GWyKU65iOfuqw.png","contentUrl":"https:\/\/cdn-images-1.medium.com\/max\/1200\/1*cD6hNsPf0GWyKU65iOfuqw.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.comet.com\/site\/blog\/getting-started-with-openai-and-r-building-a-chat-interface-with-shiny#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.comet.com\/site\/"},{"@type":"ListItem","position":2,"name":"Getting Started with OpenAI and R: Building a Chat Interface with\u00a0Shiny"}]},{"@type":"WebSite","@id":"https:\/\/www.comet.com\/site\/#website","url":"https:\/\/www.comet.com\/site\/","name":"Comet","description":"Build Better Models Faster","publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.comet.com\/site\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.comet.com\/site\/#organization","name":"Comet ML, Inc.","alternateName":"Comet","url":"https:\/\/www.comet.com\/site\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","width":310,"height":310,"caption":"Comet ML, Inc."},"image":{"@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/cometdotml","https:\/\/x.com\/Cometml","https:\/\/www.youtube.com\/channel\/UCmN63HKvfXSCS-UwVwmK8Hw"]},{"@type":"Person","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/47487ed5fe7e7af5875cb22018195ab9","name":"Daniel Tope Omole","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/image\/778f74a11987e13bc49a91122af2400b","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/10\/cropped-1663571104654-96x96.jpg","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/10\/cropped-1663571104654-96x96.jpg","caption":"Daniel Tope Omole"},"url":"https:\/\/www.comet.com\/site\/blog\/author\/topeomole55gmail-com\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/8803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/users\/103"}],"replies":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/comments?post=8803"}],"version-history":[{"count":1,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/8803\/revisions"}],"predecessor-version":[{"id":15399,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/8803\/revisions\/15399"}],"wp:attachment":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/media?parent=8803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/categories?post=8803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/tags?post=8803"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/coauthors?post=8803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}