
{"id":7252,"date":"2025-02-11T10:49:35","date_gmt":"2025-02-11T09:49:35","guid":{"rendered":"https:\/\/dasini.net\/blog\/?p=7252"},"modified":"2025-02-11T11:05:46","modified_gmt":"2025-02-11T10:05:46","slug":"building-an-interactive-llm-chatbot-with-heatwave-using-python","status":"publish","type":"post","link":"https:\/\/dasini.net\/blog\/2025\/02\/11\/building-an-interactive-llm-chatbot-with-heatwave-using-python\/","title":{"rendered":"Building an Interactive LLM Chatbot with  HeatWave Using Python"},"content":{"rendered":"\n<p>This article builds upon the concepts introduced in my previous blog posts:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/dasini.net\/blog\/2024\/09\/10\/heatwave-genai-sentiment-analysis-made-easy-peasy\/\" target=\"_blank\" rel=\"noopener\" title=\"HeatWave GenAI: Sentiment Analysis Made Easy-Peasy\">HeatWave GenAI: Sentiment Analysis Made Easy-Peasy<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/dasini.net\/blog\/2024\/08\/07\/heatwave-genai-your-ai-powered-content-creation-partner\/\" target=\"_blank\" rel=\"noopener\" title=\"&nbsp;HeatWave GenAI: Your AI-Powered Content Creation Partner\"><em>HeatWave GenAI: Your AI-Powered Content Creation Partner<\/em><\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/dasini.net\/blog\/2024\/08\/13\/in-database-llms-for-efficient-text-translation-with-heatwave-genai\/\" target=\"_blank\" rel=\"noopener\" title=\"In-Database LLMs for Efficient Text Translation with HeatWave GenAI\">In-Database LLMs for Efficient Text Translation with HeatWave GenAI<\/a> <\/li>\n\n\n\n<li><a href=\"https:\/\/dasini.net\/blog\/2024\/09\/10\/heatwave-genai-sentiment-analysis-made-easy-peasy\/\" target=\"_blank\" rel=\"noopener\" title=\"HeatWave GenAI: Sentiment Analysis Made Easy-Peasy\">HeatWave GenAI: Sentiment Analysis Made Easy-Peasy<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/dasini.net\/blog\/2024\/12\/10\/simplifying-ai-development-a-practical-guide-to-heatwave-genais-rag-vector-store-features\/\" target=\"_blank\" rel=\"noopener\" title=\"Simplifying AI Development: A Practical Guide to HeatWave GenAI\u2019s RAG &amp; Vector Store Features\">Simplifying AI Development: A Practical Guide to HeatWave GenAI\u2019s RAG &amp; Vector Store Features<\/a><\/li>\n<\/ul>\n\n\n\n<p>For a deeper understanding, also consider reading these articles.<\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69d8739d7a045&quot;}\" data-wp-interactive=\"core\/image\" class=\"aligncenter size-thumbnail wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"830\" height=\"271\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/12\/HeatWave_logo.png?resize=150%2C150&amp;ssl=1\" alt=\"HeatWave\" class=\"wp-image-7222\" srcset=\"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/12\/HeatWave_logo.png?w=830&amp;ssl=1 830w, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/12\/HeatWave_logo.png?resize=300%2C98&amp;ssl=1 300w, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/12\/HeatWave_logo.png?resize=800%2C261&amp;ssl=1 800w, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/12\/HeatWave_logo.png?resize=768%2C251&amp;ssl=1 768w\" sizes=\"auto, (max-width: 830px) 100vw, 830px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Agrandir\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on-async--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div>\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Building an Interactive LLM Chatbot with  HeatWave Using Python\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/LEoORbJ9YM4?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><figcaption class=\"wp-element-caption\"><em>Building an Interactive LLM Chatbot with HeatWave Using Python<\/em><\/figcaption><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>AI-powered applications require robust and scalable database solutions to manage and process large amounts of data efficiently. HeatWave is an excellent choice for such applications, providing high-performance OLTP, analytics, machine learning and generative artificial intelligence capabilities.<\/p>\n\n\n\n<p>In this article, we will explore a Python 3 <a href=\"https:\/\/github.com\/freshdaz\/heatwave-genai-text-chatbot\" target=\"_blank\" rel=\"noopener\" title=\"Interactive LLM Chatbot with HeatWave GenAI Using Python\">script<\/a> that connects to an HeatWave instance and enables users to interact with different large language models (LLMs) dynamically. This script demonstrates how to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Establish a connection with HeatWave using the <em><a href=\"https:\/\/dev.mysql.com\/doc\/connector-python\/en\/\" target=\"_blank\" rel=\"noopener\" title=\"MySQL Connector\/Python Developer Guide\"><code>mysql.connector<\/code> <\/a><\/em>module.<\/li>\n\n\n\n<li>Load and manage multiple <a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hw-genai-supported-models.html\" target=\"_blank\" rel=\"noopener\" title=\"Supported Languages, Embedding Models, and LLMs\">LLMs within HeatWave<\/a>.<\/li>\n\n\n\n<li>Allow users to select their preferred <a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hw-genai-supported-models.html#mys-hw-genai-in-db-llms\" target=\"_blank\" rel=\"noopener\" title=\"HeatWave GenAI - Supported Languages, Embedding Models, and LLMs\">model<\/a> dynamically.<\/li>\n\n\n\n<li>Facilitate chatbot interactions using <a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hw-genai-heatwave-chat.html\" target=\"_blank\" rel=\"noopener\" title=\"Running HeatWave Chat\"><strong>HeatWave Chat<\/strong><\/a> from <a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hw-genai.html\" target=\"_blank\" rel=\"noopener\" title=\"HeatWave GenAI - User guide\"><strong>HeatWave GenAI<\/strong><\/a>.<\/li>\n<\/ul>\n\n\n\n<p>By the end of this article, you&rsquo;ll have a deep understanding of how to <span style=\"text-decoration: underline;\"><strong>integrate HeatWave with Python for AI-driven applications<\/strong><\/span>.<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">HeatWave Chat<\/h2>\n\n\n\n<p><a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hw-genai-heatwave-chat.html\" target=\"_blank\" rel=\"noopener\" title=\"Running HeatWave Chat\"><strong>HeatWave Chat<\/strong><\/a> enables you to engage in human-like conversations with an AI. Within a single session, you can ask multiple queries and receive relevant responses. This conversational agent leverages powerful LLMs to understand your input and generate natural-sounding replies. <br>HeatWave Chat enhances the conversation by utilizing a chat history, allowing you to ask follow-up questions seamlessly. Furthermore, it employs vector search to access and utilize knowledge stored within its built-in vector store. <br>All communication and processing occur securely within the HeatWave service, ensuring fast and reliable responses.<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>In this article I&rsquo;m using HeatWave&nbsp;<strong>9.2.0-u1-cloud<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"SQL\" class=\"language-SQL\">SQL &gt; SELECT version();\n+----------------+\n| version()      |\n+----------------+\n| 9.2.0-u1-cloud |\n+----------------+\n<\/code><\/pre>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/freshdaz\/heatwave-genai-text-chatbot\" target=\"_blank\" rel=\"noopener\" title=\"Interactive LLM Chatbot with HeatWave GenAI Using Python\">Talk is cheap.&nbsp;<em>Show me the code<\/em>!<\/a><\/h2>\n\n\n\n<p>I use this quote from (<a href=\"https:\/\/phineasphreak.github.io\/assets\/docs\/linus-torvalds-quotes.pdf\" target=\"_blank\" rel=\"noopener\" title=\"Linus Torvarlds Quotes\">apparently<\/a>) <strong><a href=\"https:\/\/en.wikipedia.org\/wiki\/Linus_Torvalds\" target=\"_blank\" rel=\"noopener\" title=\"Linus Benedict Torvalds is the creator and lead developer of the Linux kernel and creator of the distributed version control system Git\">Linus Torvald<\/a><\/strong> to warn you that I&rsquo;m not a developer, so <a href=\"https:\/\/github.com\/freshdaz\/heatwave-genai-text-chatbot\" target=\"_blank\" rel=\"noopener\" title=\"heatwave-genai-text-chatbot on Github\">this code, available on my <strong>Github<\/strong><\/a>, is provided for illustrative purposes only. It may contain errors or limitations. Please <strong>use it at your own risk<\/strong> and adapt it to your specific needs (also feel free to share back).<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69d8739d7a6d3&quot;}\" data-wp-interactive=\"core\/image\" class=\"wp-block-image size-full wp-lightbox-container\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1180\" height=\"958\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/02\/HW-Chat-llama3-8b.gif?resize=1180%2C958&#038;ssl=1\" alt=\"simple but robust chatbot system leveraging HeatWave GenAI and its in-database Llama LLM\" class=\"wp-image-7337\"\/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Agrandir\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on-async--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;69d8739d7ab65&quot;}\" data-wp-interactive=\"core\/image\" class=\"wp-block-image size-full wp-lightbox-container\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1180\" height=\"958\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/02\/HW-Chat-mistral-7b.gif?resize=1180%2C958&#038;ssl=1\" alt=\"simple but robust chatbot system leveraging HeatWave GenAI and its in-database Mistral LLM\" class=\"wp-image-7339\"\/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"Agrandir\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on-async--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><figcaption class=\"wp-element-caption\">HeatWave GenAI and in-database Mistral LLM<\/figcaption><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Code Explanation<\/h2>\n\n\n\n<p>This Python script is a complete implementation of a chatbot system that interacts with <strong>HeatWave<\/strong>. It allows users to select and interact with different <strong>LLMs (Large Language Models)<\/strong>. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Importing Required Modules<\/strong><\/h3>\n\n\n\n<pre title=\"Importing Required Modules\" class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">import mysql.connector\nfrom typing import Tuple, Optional\nfrom mysql.connector.cursor import MySQLCursor\nfrom config.config_heatwave import DB_CONFIG  # Import the MySQL configuration\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><a href=\"https:\/\/dev.mysql.com\/downloads\/connector\/python\/\" target=\"_blank\" rel=\"noopener\" title=\"MySQL Connector\/Python 9.2.0\">mysql.connector<\/a><\/strong>: Used to interact with the HeatWave MySQL database.<\/li>\n\n\n\n<li><strong>typing (Tuple, Optional)<\/strong>: Provides type hints for better code readability and maintainability.<\/li>\n\n\n\n<li><strong>MySQLCursor<\/strong>: A specific cursor class from <strong>mysql.connector<\/strong> for executing MySQL queries.<\/li>\n\n\n\n<li><strong>DB_CONFIG<\/strong>: Imported from the external config file, storing database credentials and settings.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Connecting to the HeatWave MySQL Database<\/strong><\/h3>\n\n\n\n<pre title=\"Connecting to the MySQL Database\" class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">def connect_to_mysql() -&gt; mysql.connector.MySQLConnection:\n    \"\"\"Establish a connection to the MySQL database.\"\"\"\n    return mysql.connector.connect(**DB_CONFIG)<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Establishes a <strong>MySQL connection<\/strong> using <strong>DB_CONFIG<\/strong>.<\/li>\n\n\n\n<li>Returns a <strong>MySQLConnection object<\/strong> that will be used to execute queries.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Loading LLM Models into HeatWave<\/strong><\/h3>\n\n\n\n<pre title=\"Loading LLM Models into HeatWave\" class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">def load_llm(cursor: MySQLCursor, llm_options: Tuple[str, ...]) -&gt; None:\n    \"\"\"Load language models into HeatWave.\"\"\"\n    sql_load_llm = 'sys.ML_MODEL_LOAD'\n    for llm in llm_options:\n        args = (llm, 'NULL')\n        cursor.callproc(sql_load_llm, args)\n        print(f\"LLM Loaded: {llm}\")\n    print(\"All LLMs loaded successfully.\")<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hwaml-ml-model-load.html\" target=\"_blank\" rel=\"noopener\" title=\"ML_MODEL_LOAD loads a LLM into the HeatWave Cluster\">sys.ML_MODEL_LOAD<\/a><\/strong> loads a large language model into the HeatWave Cluster.<\/li>\n\n\n\n<li><strong><a href=\"https:\/\/dev.mysql.com\/doc\/connector-python\/en\/connector-python-api-mysqlcursor-callproc.html\" target=\"_blank\" rel=\"noopener\" title=\"MySQLCursor.callproc() Method\">callproc()<\/a><\/strong> executes the stored procedure for each <strong>LLM in <code>llm_options<\/code><\/strong>.<\/li>\n\n\n\n<li>Confirms successful loading with print statements.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. Selecting an LLM Model<\/strong><\/h3>\n\n\n\n<pre title=\"Selecting an LLM Model\" class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">def select_llm(llm_options: Tuple[str, ...]) -&gt; str:\n    \"\"\"\n    Prompt the user to select an LLM from the provided options.    \n    Supports up to 4 choices.\n    \"\"\"\n    option_map = {str(i + 1): llm for i, llm in enumerate(llm_options)}\n\n    while True:\n        # Dynamically build the prompt based on available options\n        prompt = \"Choose your LLM:\\n\"\n        for i, llm in enumerate(llm_options):\n            prompt += f\"{i + 1}-({llm})\\n\"\n        prompt += \"Enter your choice: \"\n\n        choice = input(prompt)\n\n        # Validate user input\n        if choice in option_map:\n            return option_map[choice]\n\n        print(f\"Invalid choice. Please select a number between 1 and {len(llm_options)}.\")\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Prompts the user to choose from <strong>up to 4 LLMs<\/strong> <em>(<a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hw-genai-supported-models.html#mys-hw-genai-in-db-llms\" target=\"_blank\" rel=\"noopener\" title=\"HeatWave In-Database LLMs\">2 from HeatWave<\/a> &#8211; Llama &amp; Mistral) and <a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hw-genai-supported-models.html#mys-hw-genai-oci-llms\" target=\"_blank\" rel=\"noopener\" title=\"OCI Generative AI Service LLMs\">2 from OCI Generative AI Service<\/a><\/em> &#8211; <em>Cohere &amp; Llama<\/em>).<\/li>\n\n\n\n<li>Uses a <strong>dictionary (<code>option_map<\/code>)<\/strong> to map <strong>number inputs to model names<\/strong>.<\/li>\n\n\n\n<li>Validates the user\u2019s choice and returns the corresponding model.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5. Chat Functionality<\/strong><\/h3>\n\n\n\n<pre title=\"Chat Functionality\" class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">def chat(cursor: MySQLCursor, llm: str) -&gt; Optional[str]:\n    \"\"\"Facilitate user chat with HeatWave.\"\"\"\n    question = input(\"Ask HeatWave?&gt; \")\n    response, chat_info = hw_chat(cursor, question, llm)\n    print(f\"Response: {response}\")\n    print(\"-\" * 30)\n    return chat_info\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Prompts the user for input.<\/li>\n\n\n\n<li>Calls <code><em><strong>hw_chat()<\/strong><\/em><\/code> to send the query to HeatWave and retrieve the response.<\/li>\n\n\n\n<li>Displays the chatbot\u2019s response.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>6. Interacting with HeatWave (Chat Processing)<\/strong><\/h3>\n\n\n\n<pre title=\"Chat Processing\" class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">def hw_chat(cursor: MySQLCursor, user_query: str, llm: str) -&gt; Tuple[str, Optional[str]]:\n    \"\"\"Send a user query to HeatWave and return the response.\"\"\"\n    sp_hw_chat = 'sys.HEATWAVE_CHAT'\n    cursor.callproc(sp_hw_chat, (user_query,))\n    response = \"\"\n    for result in cursor.stored_results():\n        response = result.fetchone()[0]\n\n    chat_info = get_chat_options(cursor)\n    return response, chat_info\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Calls HeatWave&rsquo;s stored procedure (<strong><code><a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hwgenai-hw-chat.html\" target=\"_blank\" rel=\"noopener\" title=\"HEATWAVE_CHAT\">sys.HEATWAVE_CHAT<\/a><\/code><\/strong>) with the user\u2019s query.<\/li>\n\n\n\n<li>Retrieves the response and any <strong>session-based chat options<\/strong>.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>7. Retrieving and Managing Chat Options<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Get Chat Options<\/strong><\/h4>\n\n\n\n<pre title=\"Get Chat Options\" class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">def get_chat_options(cursor: MySQLCursor) -&gt; Optional[str]:\n    \"\"\"Retrieve the session variable 'chat_options'.\"\"\"\n    cursor.execute(\"SELECT @chat_options\")\n    chat_options = cursor.fetchone()[0]\n    return chat_options\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Fetches the <strong>session variable <code><code><strong><a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hw-genai-chat-details.html\" target=\"_blank\" rel=\"noopener\" title=\"Chat Session Details\">@chat_options<\/a><\/strong><\/code><\/code><\/strong> that holds chat configurations.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Set Chat Options<\/strong><\/h4>\n\n\n\n<pre title=\"Set Chat Options\" class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">def set_chat_options(cursor: MySQLCursor, llm: str) -&gt; None:\n    \"\"\"Initialize or update the session variable 'chat_options'.\"\"\"\n    chat_options = get_chat_options(cursor)\n    if not chat_options:\n        # Initialize @chat_options if not set\n        options = f'{{\"model_options\": {{\"model_id\": \"{llm}\"}}}}'\n        sql = f\"SET @chat_options = '{options}'\"\n    else:\n        # Update @chat_options if already exists\n        sql = f\"SET @chat_options = JSON_SET(@chat_options, '$.model_options.model_id', '{llm}')\"\n    cursor.execute(sql)\n    print(f\"Using model: {llm}\")\n    print(\"-\" * 40)\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Initializes or updates<\/strong> the <code><strong><a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hw-genai-chat-details.html\" target=\"_blank\" rel=\"noopener\" title=\"Chat Session Details\">@chat_options<\/a><\/strong><\/code> session variable with the <strong>selected LLM<\/strong>.<\/li>\n\n\n\n<li>Uses <code><strong><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.4\/en\/json-modification-functions.html#function_json-set\" target=\"_blank\" rel=\"noopener\" title=\"- Inserts or updates data in a JSON document and returns the resultJSON_SET() \">JSON_SET<\/a>()<\/strong><\/code> to <strong>update an existing chat session<\/strong>.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>8. Main Function Execution<\/strong><\/h3>\n\n\n\n<pre title=\"Main Function Execution\" class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">def main() -&gt; None:\n    \"\"\"Main function to run the LLM interaction.\"\"\"\n    try:\n        with connect_to_mysql() as connection:\n            with connection.cursor() as cursor:\n                # Define available LLM options\n                llm_options = (\"llama3-8b-instruct-v1\", \"mistral-7b-instruct-v1\", \"cohere.command-r-plus-08-2024\", \"meta.llama-3.1-70b-instruct\")\n\n                # Load LLMs\n                load_llm(cursor, llm_options)\n\n                # Prompt user to select an LLM\n                selected_llm = select_llm(llm_options)\n\n                # Set chat options for the selected LLM\n                set_chat_options(cursor, selected_llm)\n\n                # Begin chat loop\n                while True:\n                    chat(cursor, selected_llm)\n    except mysql.connector.Error as err:\n        print(f\"Database error: {err}\")\n    except KeyboardInterrupt:\n        print(\"\\nExiting the application.\")\n    finally:\n        print(\"Goodbye!\")\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Uses <strong>context managers<\/strong> (<em><code>with<\/code> statement<\/em>) to <strong>manage MySQL connections safely<\/strong>.<\/li>\n\n\n\n<li>Calls <strong><code><em>load_llm()<\/em><\/code><\/strong>, <strong><code><em>select_llm()<\/em><\/code><\/strong>, and <strong><code><em>set_chat_options()<\/em><\/code><\/strong> before starting the chat loop.<\/li>\n\n\n\n<li>Handles <strong>database errors<\/strong> and <strong>user interruption (<code>Ctrl+C<\/code>)<\/strong>.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>9. <\/strong>Running the Script<\/h3>\n\n\n\n<pre title=\"Running the Script\" class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">if __name__ == \"__main__\":\n    main()\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ensures the script <strong>executes <code>main()<\/code> only <\/strong>when run directly.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Final Thoughts<\/strong><\/h2>\n\n\n\n<p>You can further extend this solution to use <strong>HeatWave Chat with Retrieval-Augmented Generation (RAG)<\/strong>. RAG is a technique that combines the power of Large Language Models with external knowledge bases. The primary goal of RAG is to enhance the quality, relevance, and accuracy of AI-generated responses by retrieving relevant information from these sources.<br>You can find more information and a practical example in this article: <a href=\"https:\/\/dasini.net\/blog\/2024\/12\/10\/simplifying-ai-development-a-practical-guide-to-heatwave-genais-rag-vector-store-features\/\" target=\"_blank\" rel=\"noopener\" title=\"Simplifying AI Development: A Practical Guide to HeatWave GenAI\u2019s RAG &amp; Vector Store Features\">Simplifying AI Development: A Practical Guide to HeatWave GenAI\u2019s RAG &amp; Vector Store Features<\/a><\/p>\n\n\n\n<p>You can also support <strong>additional LLMs, APIs, or advanced user interfaces<\/strong>. <br>To summarize, developers and data scientists can easily <strong>build intelligent applications that efficiently handle real-time AI interactions<\/strong> while leveraging the power of HeatWave.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Peroration<\/strong><\/h2>\n\n\n\n<p>This <a href=\"https:\/\/github.com\/freshdaz\/heatwave-genai-text-chatbot\" target=\"_blank\" rel=\"noopener\" title=\"Interactive LLM Chatbot with HeatWave GenAI Using Python\">Python script<\/a> demonstrates that with a few lines of codes, you can <strong>easily build a simple but robust chatbot system<\/strong> leveraging <strong>HeatWave GenAI <\/strong>and its <strong><a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hw-genai-supported-models.html#mys-hw-genai-in-db-llms\" target=\"_blank\" rel=\"noopener\" title=\"HeatWave In-Database LLMs\">in-database<\/a> or external (from <a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hw-genai-supported-models.html#mys-hw-genai-oci-llms\" target=\"_blank\" rel=\"noopener\" title=\"OCI Generative AI Service LLMs\">OCI Generative AI Service<\/a>) LLMs<\/strong>. <\/p>\n\n\n\n<p>It&rsquo;s an effective way to integrate HeatWave (and its MySQL API) with Python for AI-driven apps like chatbot interactions. By leveraging stored procedures and session variables, it allows seamless LLM management and user interaction.<\/p>\n\n\n\n<p>Key takeaways from this implementation:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><a href=\"https:\/\/github.com\/freshdaz\/heatwave-genai-text-chatbot\" target=\"_blank\" rel=\"noopener\" title=\"Interactive LLM Chatbot with HeatWave GenAI Using Python\">Modular and Scalable Design<\/a><\/strong>: The script is structured with reusable functions, making it easy to extend.<\/li>\n\n\n\n<li><strong><a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hw-genai-supported-models.html\" target=\"_blank\" rel=\"noopener\" title=\"Supported Languages, Embedding Models, and LLMs\">Dynamic LLM Selection<\/a><\/strong>: Users can choose from multiple LLMs, making it flexible for different use cases.<\/li>\n\n\n\n<li><strong><a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hw-genai.html\" target=\"_blank\" rel=\"noopener\" title=\"HeatWave GenAI\">HeatWave&rsquo;s Power in AI<\/a><\/strong>: Utilizing <strong><a href=\"https:\/\/dev.mysql.com\/doc\/heatwave\/en\/mys-hw-genai-heatwave-chat.html\" target=\"_blank\" rel=\"noopener\" title=\"HeatWave Chat\">HeatWave Chat<\/a><\/strong> for chatbot interactions showcases its potential beyond traditional database applications.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Stay tuned for more insights!<\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><a href=\"https:\/\/www.linkedin.com\/groups\/12524512\/\" target=\"_blank\" rel=\"noopener\" title=\"Olivier DASINI on Linkedin\">Follow me on Linkedin<\/a><\/p>\n\n\n\n<p>Watch my videos on my <a href=\"https:\/\/www.youtube.com\/channel\/UC12TulyJsJZHoCmby3Nm3WQ\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Olivier's MySQL Channel\">YouTube channel<\/a> and <a href=\"https:\/\/www.youtube.com\/channel\/UC12TulyJsJZHoCmby3Nm3WQ\/?sub_confirmation=1\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Subscribe\">subscribe<\/a>.<\/p>\n\n\n\n<p>My <a href=\"https:\/\/www.slideshare.net\/freshdaz\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Olivier DASINI on Slideshare\">Slideshare account<\/a>.<\/p>\n\n\n\n<p>My <a href=\"https:\/\/speakerdeck.com\/freshdaz\/\" target=\"_blank\" rel=\"noreferrer noopener\" title=\"Olivier DASINI on Speaker Deck\">Speaker Deck account<\/a>.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\"><strong>Thanks for using HeatWave &amp; MySQL!<\/strong><\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>AI-powered applications require robust and scalable database solutions to manage and process large amounts of data efficiently. HeatWave is an excellent choice for such applications, providing high-performance OLTP, analytics, machine learning and generative artificial intelligence capabilities.<\/p>\n<p>In this article, we will explore a Python 3 script that connects to an HeatWave instance and enables users to interact with different large language models (LLMs) dynamically.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"categories":[1694,339],"tags":[1732,1700,1697,1735],"class_list":["post-7252","post","type-post","status-publish","format-standard","hentry","category-heatwave-en","category-tuto-en","tag-chatbot-en","tag-genai","tag-heatwave-fr-en","tag-python-en"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9LfWW-1SY","jetpack-related-posts":[{"id":7812,"url":"https:\/\/dasini.net\/blog\/2025\/05\/13\/oracle-dev-days-2025-french-edition\/","url_meta":{"origin":7252,"position":0},"title":"Oracle Dev Days 2025 \u2013 French Edition","author":"Olivier DASINI","date":"13 mai 2025","format":false,"excerpt":"Join the Oracle Dev Days \u2013 French Edition, from May 20 to 22, 2025! This must-attend event (in French) offers a rich program exploring the latest advancements in AI, databases, cloud, and Java. Join me on May 21 at 2:00 PM for the day dedicated to \u201cDatabase & AI.\u201d I\u2019ll\u2026","rel":"","context":"Dans &quot;Conf\u00e9rence&quot;","block_context":{"text":"Conf\u00e9rence","link":"https:\/\/dasini.net\/blog\/category\/conference-en\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/05\/Olivier_Dasini_HeatWave.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/05\/Olivier_Dasini_HeatWave.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/05\/Olivier_Dasini_HeatWave.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/05\/Olivier_Dasini_HeatWave.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/05\/Olivier_Dasini_HeatWave.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":7363,"url":"https:\/\/dasini.net\/blog\/2025\/03\/13\/build-an-ai-powered-search-engine-with-heatwave-genai-part-1\/","url_meta":{"origin":7252,"position":1},"title":"Build an AI-Powered Search Engine with HeatWave GenAI (part 1)","author":"Olivier DASINI","date":"13 mars 2025","format":false,"excerpt":"Discover how to build an AI-powered search engine for your applications using HeatWave GenAI. This approach leverages large language models (LLMs) for semantic search, offering a smarter alternative to traditional SQL and full-text search methods. By using embeddings\u2014vector representations of words\u2014the search engine understands context and intent, delivering more relevant\u2026","rel":"","context":"Dans &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/dasini.net\/blog\/category\/ai\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/03\/HW_GenaI_search_engine.gif?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/03\/HW_GenaI_search_engine.gif?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/03\/HW_GenaI_search_engine.gif?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/03\/HW_GenaI_search_engine.gif?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/03\/HW_GenaI_search_engine.gif?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/03\/HW_GenaI_search_engine.gif?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":6752,"url":"https:\/\/dasini.net\/blog\/2024\/08\/07\/heatwave-genai-your-ai-powered-content-creation-partner\/","url_meta":{"origin":7252,"position":2},"title":"HeatWave GenAI: Your AI-Powered Content Creation Partner","author":"Olivier DASINI","date":"7 ao\u00fbt 2024","format":false,"excerpt":"Generative artificial intelligence (GenAI) is reshaping the content creation landscape. By training on vast datasets, these \"intelligent\" systems can produce new, human-quality content across a multitude of domains. Oracle's HeatWave GenAI (starting with version 9.0.1) is at the forefront of this revolution, offering an integrated platform that combines in-database large\u2026","rel":"","context":"Dans &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/dasini.net\/blog\/category\/ai\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":7711,"url":"https:\/\/dasini.net\/blog\/2025\/04\/15\/build-an-ai-powered-search-engine-with-heatwave-genai-part-3\/","url_meta":{"origin":7252,"position":3},"title":"Build an AI-Powered Search Engine with HeatWave GenAI (part 3)","author":"Olivier DASINI","date":"15 avril 2025","format":false,"excerpt":"In this latest post, the final part of my series on building an AI-powered search engine with HeatWave GenAI, I dive into enhancing AI-powered search by embedding full article content into HeatWave. By cleaning HTML, chunking content, generating embeddings, and running semantic similarity searches directly within HeatWave, we unlock highly\u2026","rel":"","context":"Dans &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/dasini.net\/blog\/category\/ai\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":7566,"url":"https:\/\/dasini.net\/blog\/2025\/04\/08\/build-an-ai-powered-search-engine-with-heatwave-genai-part-2\/","url_meta":{"origin":7252,"position":4},"title":"Build an AI-Powered Search Engine with HeatWave GenAI (part 2)","author":"Olivier DASINI","date":"8 avril 2025","format":false,"excerpt":"In this part 2 we focused on enhancing search relevance. We introduced reranking techniques using weighted distances of titles and excerpts to refine initial search results. Then we delved into leveraging article summaries for more effective semantic search, utilizing HeatWave's capability to execute JavaScript stored procedures for sanitizing HTML content\u2026","rel":"","context":"Dans &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/dasini.net\/blog\/category\/ai\/"},"img":{"alt_text":"Similarity search across title, excerpt and summary","src":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/04\/HWGenAIsearchEngine2.gif?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/04\/HWGenAIsearchEngine2.gif?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/04\/HWGenAIsearchEngine2.gif?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/04\/HWGenAIsearchEngine2.gif?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/04\/HWGenAIsearchEngine2.gif?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2025\/04\/HWGenAIsearchEngine2.gif?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":6825,"url":"https:\/\/dasini.net\/blog\/2024\/08\/13\/in-database-llms-for-efficient-text-translation-with-heatwave-genai\/","url_meta":{"origin":7252,"position":5},"title":"In-Database LLMs for Efficient Text Translation with HeatWave GenAI","author":"Olivier DASINI","date":"13 ao\u00fbt 2024","format":false,"excerpt":"While HeatWave GenAI excels at generating English text, its capabilities extend to translation as well. Let's explore how we can effectively translate English content into French using this powerful tool.","rel":"","context":"Dans &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/dasini.net\/blog\/category\/ai\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/dasini.net\/blog\/wp-content\/uploads\/2024\/07\/hw_product_image.png?resize=1400%2C800&ssl=1 4x"},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/7252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/comments?post=7252"}],"version-history":[{"count":103,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/7252\/revisions"}],"predecessor-version":[{"id":7361,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/posts\/7252\/revisions\/7361"}],"wp:attachment":[{"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/media?parent=7252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/categories?post=7252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dasini.net\/blog\/wp-json\/wp\/v2\/tags?post=7252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}