In this tutorial, you’ll learn to build a simple chatbot in Python that utilizes Anaconda Desktop’s OpenAI-compatible API server to process natural language queries. You will use conda to establish a working environment to develop the chatbot, build the chatbot application using the OpenAI Python library, and interact with the chatbot at the command line.Prerequisites
Before you begin, ensure that you have the conda installed on your machine. You can install conda by downloading either Anaconda Distribution or Miniconda.
You must have a text-generation type model downloaded onto your local machine. Walk through the Getting started with Anaconda Desktop guide before you begin the tutorial.
When working on a new conda project, it is recommended that you create a new environment for development. Follow these steps to set up an environment for your chatbot:
Open (Terminal on macOS/Linux).
This terminal can be opened from within an (JupyterLab, PyCharm, VS Code, Spyder), if preferred.
Create the for your chatbot development and install the packages you’ll need by running the following command:
conda create --name chataconda python openai
Activate your newly created conda environment by running the following command:
conda activate chataconda
For more information and best practices for managing environments, see Environments.
Below, you’ll find the necessary code to build your chatbot, along with an explanation of each section to help you understand the functionality of the code.Using your preferred IDE, create a new file on your machine, and name it chatter-max.py.
The application uses the OpenAI Python library to communicate with the API server. We’ll import the necessary modules for making API calls and handling errors.Make this the first line of code in your chatter-max.py file:
from openai import OpenAI, APIError, APIConnectionError
In order for your application to programmatically process natural language inputs to generate responses and perform other actions, it is crucial that you properly structure your application to interact with the API server.The base_url can be constructed by combining the Server Address and Server Port specified in Anaconda Desktop, like this: http://<SERVER_ADDRESS>:<SERVER_PORT>.Set the base_url to point to the default server address by adding the following line to your file.
base_url = 'http://localhost:8080'
localhost and 127.0.0.1 are semantically identical.
The OpenAI chat completions API is the main endpoint you’ll use to interact with your model. For a full list of API endpoints and detailed information, see the OpenAI Chat Completions API documentation.To enable your application to communicate with the API server, you need to implement a function that makes the chat completion API call.
To interact with the model, you need a function that sends messages to the chat completion endpoint and receives responses. This function handles the API call and error management.The messages parameter is a list of conversation messages, where each message has a role (system, user, or assistant) and content. This format allows the model to understand the full context of the conversation.The parameters in client.chat.completions.create() control how the AI model generates responses. These parameters dictate the model’s behavior during the completion process.The stop parameter specifies tokens that tell the model when to stop generating text. The tokens <|im_end|> and <|im_start|> are special control markers used by the ChatML chat template to denote message boundaries. By including these as stop tokens, you prevent the model from accidentally generating these markers in its response, which could confuse the conversation structure or cause the model to generate both sides of the conversation.Add the following lines to your chatter-max.py file:
def get_completion(client, messages): """Send messages to the chat completion API and return the response.""" try: response = client.chat.completions.create( model="", messages=messages, temperature=0.8, top_p=0.95, max_completion_tokens=400, stop=["<|im_end|>", "<|im_start|>"] ) return response.choices[0].message.content.strip(), True except APIConnectionError as e: return f"Connection error: {e}", False except APIError as e: return f"API error: {e}", False
The model parameter can be left empty when using Anaconda Desktop’s API server, as the model is already loaded on the server.
The main function initiates the chatbot, handles user inputs, and manages the flow of the conversation. This is where you set the initial system prompt that defines the assistant’s behavior.
Play around with the system prompt to see how it impacts the responses you receive from your model!If you set an API key value on the Model Servers page in Anaconda Desktop, you can pass it to the OpenAI client by replacing the empty string in the api_key parameter. Otherwise, leave it as an empty string to skip authentication.
Add the following lines to your chatter-max.py file:
def main(): """Run the interactive chatbot loop.""" client = OpenAI(base_url=base_url, api_key="") system_prompt = ('You are a friendly AI assistant designed to provide ' 'helpful, succinct, and accurate information.') messages = [{'role': 'system', 'content': system_prompt}] print(f"Connected to: {base_url}") while True: user_input = input("Enter a prompt or type 'exit' to quit: ") if user_input.lower() == 'exit': break messages.append({'role': 'user', 'content': user_input}) assistant_response, success = get_completion(client, messages) print('Assistant:', assistant_response) if success: messages.append({'role': 'assistant', 'content': assistant_response}) else: messages.pop()if __name__ == "__main__": main()
Try adjusting the following parameters in the get_completion() function to see how they affect the output from the model.
Visit OpenAI’s official documentation for additional available parameters. Note that some parameters might not be supported by all available models on Anaconda Desktop.
Adjusting the temperature of your model can increase or decrease the randomness of the responses you receive from your prompts. Higher values (example 2.0) make the output more creative and varied. Lower values (example 0.2) make the output more deterministic and focused. Valid range is 0.0 to 2.0. Defaults to 0.8.
Limits token selection to a subset of tokens with a cumulative probability above a threshold to balance creativity with coherence. Higher values (closer to 1.0) allow the model to provide more creative responses, and lower values enhance focus. Valid range is 0.0 to 1.0. Adjust top_p to see how it affects the model’s descriptiveness for the same prompt. Defaults to 0.95.
Controls the maximum number of tokens the model can generate in its response. One token is roughly equivalent to 4 characters or 0.75 words in English. Increasing this value allows for longer responses, while decreasing it keeps responses more concise. Defaults to 400.
Reduces the likelihood of the model repeating the same words or phrases. Higher values (up to 2.0) make the model avoid repetition more strongly, while lower or negative values allow more repetition. Valid range is -2.0 to 2.0. Defaults to 0.0.
Encourages the model to introduce new topics rather than continuing with existing ones. Higher values (up to 2.0) push the model to be more exploratory, while lower values allow it to stay on topic. Valid range is -2.0 to 2.0. Defaults to 0.0.
You can continue to develop and extend this chatbot by adding features like conversation history persistence, multi-turn context management, or integration with other tools. When you’re done, you can delete this file and clean up your conda environment by running the following command:
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Anaconda","description":"Guides, tutorials, and reference material for Anaconda's Python, data science, and AI tools","colors":{"primary":"#1d6cf7","light":"#1d6cf7","dark":"#96f778"},"logo":{"light":"https://mintcdn.com/anaconda-29683c67/s-9WR15r5rZoaPqb/logo/light.svg?fit=max\u0026auto=format\u0026n=s-9WR15r5rZoaPqb\u0026q=85\u0026s=5996719b8530aaf065dc1ee1f39b2e67","dark":"https://mintcdn.com/anaconda-29683c67/s-9WR15r5rZoaPqb/logo/dark.svg?fit=max\u0026auto=format\u0026n=s-9WR15r5rZoaPqb\u0026q=85\u0026s=db482b1eac6af589d234160a76de3400","href":"https://www.anaconda.com/docs/main"},"favicon":"https://mintcdn.com/anaconda-29683c67/p8JNFuYYvTL8gfpM/favicon.png?fit=max\u0026auto=format\u0026n=p8JNFuYYvTL8gfpM\u0026q=85\u0026s=51a585758330bbe8f1ea032113854252","api":{"playground":{"display":"simple"}},"background":{"color":{"light":"#f4f5f8","dark":"#10121a"}},"navbar":{},"footer":{"socials":{"linkedin":"https://www.linkedin.com/company/anacondainc","github":"https://github.com/ContinuumIO","youtube":"https://www.youtube.com/c/ContinuumIo"},"links":[{"header":"Company","items":[{"label":"Anaconda Newsletter","href":"https://www.anaconda.com/newsletter"}]}]},"seo":{"metatags":{"canonical":"https://www.anaconda.com/docs"}},"styling":{"eyebrows":"breadcrumbs","latex":false},"integrations":{"ga4":{"measurementId":"G-VQTY6YKM6J"},"heap":{"appId":"758475466"}},"contextual":{"options":["claude","chatgpt","perplexity","cursor","vscode","add-mcp","copy"],"display":"header"},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"anaconda-29683c67","hasAudioNarration":false,"actualSubdomain":"anaconda-29683c67","customDomains":["anaconda.com"],"gitSource":{"type":"github","owner":"anaconda","repo":"documentation","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6aea08d2c81e6432c321c947","collectionId":"38ddf31b-3676-491b-84ac-1c1ef58c36bd","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6aea08d2c81e6432c321c947"},"feedback":{"thumbs":true,"contextualFeedback":{"allowEmail":true,"emailDisclaimer":"Your email will only be used to follow up on this feedback."}},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"REMOVE_BRANDING":{"status":"ENABLED"},"CONTEXTUAL_FEEDBACK":{"status":"ENABLED"},"CODE_SNIPPET_FEEDBACK":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6aea08d2c81e6432c321c947","clientVersion":"0.0.4045","searchFilterCounts":[{"language":"default","tag":"Data Science \u0026 AI Workbench","count":240},{"language":"default","tag":"Anaconda Platform","count":150},{"language":"default","tag":"Package Security Manager","count":128},{"language":"default","tag":"Anaconda CLI","count":112},{"language":"default","tag":"Guides","count":105},{"language":"default","tag":"Anaconda CLI \u0026 MCP","count":104},{"language":"default","tag":"Plugins","count":93},{"language":"default","tag":"Commands","count":91},{"language":"default","tag":"Anaconda Desktop","count":86},{"language":"default","tag":"Platform Guides","count":86}],"searchSettings":{"isFiltersEnabled":true}},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":true,"enableContextualStarterQuestions":true,"deflection":{"enabled":true,"email":"support@anaconda.com"}},"basePath":"/docs","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"custom.css","href":"/docs/_mintlify/custom/anaconda-29683c67/8e7e337189353d6a/custom.css"}],"page":{"pagePath":"anaconda-desktop/tutorials/chatbot-tutorial","slug":"/anaconda-desktop/tutorials/chatbot-tutorial","pageMetadata":{"title":"Developing a chatbot","searchDescription":"Tutorial for developing a chatbot with Anaconda Desktop.","keywords":["chatbot","development","tutorial","natural language","ai","model","anaconda desktop"],"description":null,"href":"/anaconda-desktop/tutorials/chatbot-tutorial"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,hr:`hr`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Tip,Tooltip,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Tip)_missingMdxReference(`Tip`,true);if(!Tooltip)_missingMdxReference(`Tooltip`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`In this tutorial, you’ll learn to build a simple chatbot in Python that utilizes Anaconda Desktop’s OpenAI-compatible API server to process natural language queries. You will use conda to establish a working environment to develop the chatbot, build the chatbot application using the OpenAI Python library, and interact with the chatbot at the command line.`}),`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`Prerequisites`})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Before you begin, ensure that you have the conda `,_jsx(Tooltip,{tip:`A collection of software tools that automates the process of installing, updating, configuring, and removing packages. Also known as a package management system.`,children:`package manager`}),` installed on your machine. You can install `,_jsx(_components.code,{children:`conda`}),` by downloading either `,_jsx(_components.a,{href:`/getting-started/concepts/anaconda-or-miniconda`,children:`Anaconda Distribution or Miniconda`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`You must have a `,_jsx(_components.code,{children:`text-generation`}),` type model downloaded onto your local machine. Walk through the `,_jsx(_components.a,{href:`/anaconda-desktop/getting-started-desktop`,children:`Getting started with Anaconda Desktop`}),` guide before you begin the tutorial.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`setting-up-your-environment`,children:`Setting up your environment`}),`\n`,_jsx(_components.p,{children:`When working on a new conda project, it is recommended that you create a new environment for development. Follow these steps to set up an environment for your chatbot:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Open `,_jsx(Tooltip,{tip:`A command-line application included with Windows installations of Anaconda Distribution and Miniconda. Find it by searching 'Anaconda Prompt' in the Windows Start menu.`,children:`Anaconda Prompt`}),` (Terminal on macOS/Linux).`]}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`This terminal can be opened from within an `,_jsx(Tooltip,{tip:`An interactive development environment. A suite of software tools that combines everything a developer needs to write and test software.`,children:`IDE`}),` (JupyterLab, PyCharm, VS Code, Spyder), if preferred.`]})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Create the `,_jsx(Tooltip,{tip:`An isolated folder containing specific conda packages and dependencies that won't interfere with other projects. Each environment maintains its own versions of libraries and packages, so changes in one environment don't affect others.`,children:`conda environment`}),` for your chatbot development and install the packages you’ll need by running the following command:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`conda`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` create`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --name`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` chataconda`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` python`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` openai`})]}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Activate your newly created conda environment by running the following command:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`conda`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` activate`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` chataconda`})]}),`\n`]})})}),`\n`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`For more information and best practices for managing environments, see `,_jsx(_components.a,{href:`/getting-started/working-with-conda/environments`,children:`Environments`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`building-the-chatbot`,children:`Building the chatbot`}),`\n`,_jsx(_components.p,{children:`Below, you’ll find the necessary code to build your chatbot, along with an explanation of each section to help you understand the functionality of the code.`}),`\n`,_jsxs(_components.p,{children:[`Using your preferred IDE, create a new file on your machine, and name it `,_jsx(_components.code,{children:`chatter-max.py`}),`.`]}),`\n`,_jsx(Heading,{level:`3`,id:`importing-libraries`,children:`Importing libraries`}),`\n`,_jsx(_components.p,{children:`The application uses the OpenAI Python library to communicate with the API server. We’ll import the necessary modules for making API calls and handling errors.`}),`\n`,_jsxs(_components.p,{children:[`Make this the first line of code in your `,_jsx(_components.code,{children:`chatter-max.py`}),` file:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` openai `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAI, APIError, APIConnectionError`})]}),`\n`]})})}),`\n`,_jsxs(Heading,{level:`3`,id:`setting-the-base_url`,children:[`Setting the `,_jsx(_components.code,{children:`base_url`})]}),`\n`,_jsx(_components.p,{children:`In order for your application to programmatically process natural language inputs to generate responses and perform other actions, it is crucial that you properly structure your application to interact with the API server.`}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`base_url`}),` can be constructed by combining the `,_jsx(_components.strong,{children:`Server Address`}),` and `,_jsx(_components.strong,{children:`Server Port`}),` specified in Anaconda Desktop, like this: `,_jsx(_components.code,{children:`http://\u003cSERVER_ADDRESS>:\u003cSERVER_PORT>`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`Set the `,_jsx(_components.code,{children:`base_url`}),` to point to the default server address by adding the following line to your file.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`base_url `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'http://localhost:8080'`})]}),`\n`]})})}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`localhost`}),` and `,_jsx(_components.code,{children:`127.0.0.1`}),` are semantically identical.`]})}),`\n`,_jsx(Heading,{level:`3`,id:`adding-the-api-calls`,children:`Adding the API calls`}),`\n`,_jsxs(_components.p,{children:[`The OpenAI chat completions API is the main endpoint you’ll use to interact with your model. For a full list of API endpoints and detailed information, see the `,_jsx(_components.a,{href:`https://developers.openai.com/api/reference/chat-completions/overview`,children:`OpenAI Chat Completions API documentation`}),`.`]}),`\n`,_jsx(_components.p,{children:`To enable your application to communicate with the API server, you need to implement a function that makes the chat completion API call.`}),`\n`,_jsx(Heading,{level:`4`,id:`creating-the-completion-function`,children:`Creating the completion function`}),`\n`,_jsx(_components.p,{children:`To interact with the model, you need a function that sends messages to the chat completion endpoint and receives responses. This function handles the API call and error management.`}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`messages`}),` parameter is a list of conversation messages, where each message has a `,_jsx(_components.code,{children:`role`}),` (system, user, or assistant) and `,_jsx(_components.code,{children:`content`}),`. This format allows the model to understand the full context of the conversation.`]}),`\n`,_jsxs(_components.p,{children:[`The parameters in `,_jsx(_components.code,{children:`client.chat.completions.create()`}),` control how the AI model generates responses. These parameters dictate the model’s behavior during the completion process.`]}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`stop`}),` parameter specifies tokens that tell the model when to stop generating text. The tokens `,_jsx(_components.code,{children:`\u003c|im_end|>`}),` and `,_jsx(_components.code,{children:`\u003c|im_start|>`}),` are special control markers used by the ChatML chat template to denote message boundaries. By including these as stop tokens, you prevent the model from accidentally generating these markers in its response, which could confuse the conversation structure or cause the model to generate both sides of the conversation.`]}),`\n`,_jsxs(_components.p,{children:[`Add the following lines to your `,_jsx(_components.code,{children:`chatter-max.py`}),` file:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`16`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`16`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` get_completion`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`client`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`messages`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`):`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\"\"Send messages to the chat completion API and return the response.\"\"\"`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` try`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.chat.completions.create(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`messages,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` temperature`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0.8`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` top_p`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0.95`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` max_completion_tokens`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`400`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` stop`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003c|im_end|>\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003c|im_start|>\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` )`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response.choices[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].message.content.strip(), `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` except`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` APIConnectionError `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` e:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Connection error: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`e`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`False`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` except`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` APIError `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`as`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` e:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"API error: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`e`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`False`})]}),`\n`]})})}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`model`}),` parameter can be left empty when using Anaconda Desktop’s API server, as the model is already loaded on the server.`]})}),`\n`,_jsx(Heading,{level:`3`,id:`constructing-the-main-function`,children:`Constructing the main function`}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`main`}),` function initiates the chatbot, handles user inputs, and manages the flow of the conversation. This is where you set the initial system prompt that defines the assistant’s behavior.`]}),`\n`,_jsxs(Tip,{children:[_jsx(_components.p,{children:`Play around with the system prompt to see how it impacts the responses you receive from your model!`}),_jsx(_components.hr,{}),_jsxs(_components.p,{children:[`If you set an API key value on the `,_jsx(_components.strong,{children:`Model Servers`}),` page in Anaconda Desktop, you can pass it to the OpenAI client by replacing the empty string in the `,_jsx(_components.code,{children:`api_key`}),` parameter. Otherwise, leave it as an empty string to skip authentication.`]})]}),`\n`,_jsxs(_components.p,{children:[`Add the following lines to your `,_jsx(_components.code,{children:`chatter-max.py`}),` file:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`27`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`27`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`def`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` main`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`():`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"\"\"Run the interactive chatbot loop.\"\"\"`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAI(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`base_url`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`base_url, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`api_key`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` system_prompt `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'You are a friendly AI assistant designed to provide '`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'helpful, succinct, and accurate information.'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` messages `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'role'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'system'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'content'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: system_prompt}]`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Connected to: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`base_url`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` while`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` user_input `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` input`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Enter a prompt or type 'exit' to quit: \"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` user_input.lower() `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`==`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'exit'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` break`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` messages.append({`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'role'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'user'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'content'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: user_input})`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` assistant_response, success `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` get_completion(client, messages)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'Assistant:'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, assistant_response)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` success:`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` messages.append({`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'role'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'assistant'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'content'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: assistant_response})`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` else`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` messages.pop()`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`if`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:` __name__`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ==`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"__main__\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` main()`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`running-the-chatbot`,children:`Running the chatbot`}),`\n`,_jsx(_components.p,{children:`With your chatbot constructed, it’s time to take your model for a test run!`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`Open Anaconda Desktop and `,_jsx(_components.a,{href:`/anaconda-desktop/servers#creating-a-server`,children:`create and start a model server`}),`. Leave the `,_jsx(_components.strong,{children:`Server Address`}),` and `,_jsx(_components.strong,{children:`Server Port`}),` at the default values.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsxs(_components.p,{children:[`In your terminal (with the `,_jsx(_components.code,{children:`chataconda`}),` environment activated), navigate to the directory where you stored your `,_jsx(_components.code,{children:`chatter-max.py`}),` file.`]}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`Initiate the chatbot by running the following command:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`python`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` chatter-max.py`})]}),`\n`]})})}),`\n`]}),`\n`,_jsxs(_components.li,{children:[`\n`,_jsx(_components.p,{children:`If everything is set up correctly, you’ll see a confirmation message showing the connected URL, and you can start chatting with your model.`}),`\n`]}),`\n`]}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Make sure the API server is running in Anaconda Desktop before running your chatbot. If the server isn’t running, you’ll see a connection error.`})}),`\n`,_jsx(Heading,{level:`2`,id:`having-some-fun-with-the-model`,children:`Having some fun with the model`}),`\n`,_jsxs(_components.p,{children:[`Try adjusting the following parameters in the `,_jsx(_components.code,{children:`get_completion()`}),` function to see how they affect the output from the model.`]}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`Visit OpenAI’s `,_jsx(_components.a,{href:`https://developers.openai.com/api/reference/chat-completions/overview`,children:`official documentation`}),` for additional available parameters. Note that some parameters might not be supported by all available models on Anaconda Desktop.`]})}),`\n`,_jsx(Heading,{level:`3`,id:`temperature`,children:_jsx(_components.code,{children:`temperature`})}),`\n`,_jsxs(_components.p,{children:[`Adjusting the temperature of your model can increase or decrease the randomness of the responses you receive from your prompts. Higher values (example `,_jsx(_components.code,{children:`2.0`}),`) make the output more creative and varied. Lower values (example `,_jsx(_components.code,{children:`0.2`}),`) make the output more deterministic and focused. Valid range is `,_jsx(_components.code,{children:`0.0`}),` to `,_jsx(_components.code,{children:`2.0`}),`. Defaults to `,_jsx(_components.code,{children:`0.8`}),`.`]}),`\n`,_jsx(Heading,{level:`3`,id:`top_p`,children:_jsx(_components.code,{children:`top_p`})}),`\n`,_jsxs(_components.p,{children:[`Limits token selection to a subset of tokens with a cumulative probability above a threshold to balance creativity with coherence. Higher values (closer to `,_jsx(_components.code,{children:`1.0`}),`) allow the model to provide more creative responses, and lower values enhance focus. Valid range is `,_jsx(_components.code,{children:`0.0`}),` to `,_jsx(_components.code,{children:`1.0`}),`. Adjust `,_jsx(_components.code,{children:`top_p`}),` to see how it affects the model’s descriptiveness for the same prompt. Defaults to `,_jsx(_components.code,{children:`0.95`}),`.`]}),`\n`,_jsx(Heading,{level:`3`,id:`max_completion_tokens`,children:_jsx(_components.code,{children:`max_completion_tokens`})}),`\n`,_jsxs(_components.p,{children:[`Controls the maximum number of tokens the model can generate in its response. One token is roughly equivalent to 4 characters or 0.75 words in English. Increasing this value allows for longer responses, while decreasing it keeps responses more concise. Defaults to `,_jsx(_components.code,{children:`400`}),`.`]}),`\n`,_jsx(Heading,{level:`3`,id:`frequency_penalty`,children:_jsx(_components.code,{children:`frequency_penalty`})}),`\n`,_jsxs(_components.p,{children:[`Reduces the likelihood of the model repeating the same words or phrases. Higher values (up to `,_jsx(_components.code,{children:`2.0`}),`) make the model avoid repetition more strongly, while lower or negative values allow more repetition. Valid range is `,_jsx(_components.code,{children:`-2.0`}),` to `,_jsx(_components.code,{children:`2.0`}),`. Defaults to `,_jsx(_components.code,{children:`0.0`}),`.`]}),`\n`,_jsx(Heading,{level:`3`,id:`presence_penalty`,children:_jsx(_components.code,{children:`presence_penalty`})}),`\n`,_jsxs(_components.p,{children:[`Encourages the model to introduce new topics rather than continuing with existing ones. Higher values (up to `,_jsx(_components.code,{children:`2.0`}),`) push the model to be more exploratory, while lower values allow it to stay on topic. Valid range is `,_jsx(_components.code,{children:`-2.0`}),` to `,_jsx(_components.code,{children:`2.0`}),`. Defaults to `,_jsx(_components.code,{children:`0.0`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`next-steps`,children:`Next steps`}),`\n`,_jsx(_components.p,{children:`You can continue to develop and extend this chatbot by adding features like conversation history persistence, multi-turn context management, or integration with other tools. When you’re done, you can delete this file and clean up your conda environment by running the following command:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`conda`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` deactivate`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`conda`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` remove`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --name`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` chataconda`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --all`})]}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Developing a chatbot","searchDescription":"Tutorial for developing a chatbot with Anaconda Desktop.","keywords":["chatbot","development","tutorial","natural language","ai","model","anaconda desktop"],"description":null,"href":"/anaconda-desktop/tutorials/chatbot-tutorial"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Setting up your environment","slug":"setting-up-your-environment","depth":2,"children":[]},{"title":"Building the chatbot","slug":"building-the-chatbot","depth":2,"children":[{"title":"Importing libraries","slug":"importing-libraries","depth":3,"children":[]},{"title":"Setting the base_url","slug":"setting-the-base_url","depth":3,"children":[]},{"title":"Adding the API calls","slug":"adding-the-api-calls","depth":3,"children":[]},{"title":"Creating the completion function","slug":"creating-the-completion-function","depth":4,"children":[]},{"title":"Constructing the main function","slug":"constructing-the-main-function","depth":3,"children":[]}]},{"title":"Running the chatbot","slug":"running-the-chatbot","depth":2,"children":[]},{"title":"Having some fun with the model","slug":"having-some-fun-with-the-model","depth":2,"children":[{"title":"temperature","slug":"temperature","depth":3,"children":[]},{"title":"top_p","slug":"top_p","depth":3,"children":[]},{"title":"max_completion_tokens","slug":"max_completion_tokens","depth":3,"children":[]},{"title":"frequency_penalty","slug":"frequency_penalty","depth":3,"children":[]},{"title":"presence_penalty","slug":"presence_penalty","depth":3,"children":[]}]},{"title":"Next steps","slug":"next-steps","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/docs/_mintlify/custom/anaconda-29683c67/b738e1eb47e9934c/_transcend.js","/docs/_mintlify/custom/anaconda-29683c67/3ca111da84ffed5d/docs-dropdown-tooltip.js","/docs/_mintlify/custom/anaconda-29683c67/a3d1c2dd97aa6593/toc-indicator.js"],"subdomain":"anaconda-29683c67","siteName":"Anaconda","title":"Developing a chatbot - Anaconda","contextualStarterQuestions":[{"_id":"6ada7bce1864d9f201477289","deploymentId":"6781700c5f1e7d2ac00fcc4a","questionText":"What model do I need for this?","status":"active","generatedBy":"contextual","path":"anaconda-desktop/tutorials/chatbot-tutorial","createdAt":"2026-10-22T21:10:38.049Z","updatedAt":"2026-10-22T21:10:38.049Z","__v":0},{"_id":"6ada7bce1864d9f20147728a","deploymentId":"6781700c5f1e7d2ac00fcc4a","questionText":"How do I build the chatbot?","status":"active","generatedBy":"contextual","path":"anaconda-desktop/tutorials/chatbot-tutorial","createdAt":"2026-10-22T21:10:38.049Z","updatedAt":"2026-10-22T21:10:38.049Z","__v":0},{"_id":"6ada7bce1864d9f201477288","deploymentId":"6781700c5f1e7d2ac00fcc4a","questionText":"How do I set up a conda environment?","status":"active","generatedBy":"contextual","path":"anaconda-desktop/tutorials/chatbot-tutorial","createdAt":"2026-10-22T21:10:38.049Z","updatedAt":"2026-10-22T21:10:38.049Z","__v":0}],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-22T21:02:42.901Z","originalFileLocation":"anaconda-desktop/tutorials/chatbot-tutorial.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"application-name\" content=\"Anaconda\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/anaconda-29683c67/Q6mS5k5M0lNdBscF/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/docs/mintlify-assets/_mintlify/favicons/anaconda-29683c67/Q6mS5k5M0lNdBscF/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/anaconda-29683c67/Q6mS5k5M0lNdBscF/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/anaconda-29683c67/Q6mS5k5M0lNdBscF/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/anaconda-29683c67/Q6mS5k5M0lNdBscF/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/anaconda-29683c67/Q6mS5k5M0lNdBscF/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/anaconda-29683c67/Q6mS5k5M0lNdBscF/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/anaconda-29683c67/Q6mS5k5M0lNdBscF/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/anaconda-29683c67/Q6mS5k5M0lNdBscF/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Developing a chatbot - Anaconda\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Anaconda\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://www.anaconda.com/docs/anaconda-desktop/tutorials/chatbot-tutorial\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://anaconda-29683c67.mintlify.app/_mintlify/api/og/v2?division=Tutorials\u0026amp;title=Developing+a+chatbot\u0026amp;theme=a631e829865976b88c6af112\u0026amp;signature=03c0e048ae8f8af71858fb54e20cf3464b671197386a5f33c1f1451b5a659b7f\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Developing a chatbot - Anaconda\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://anaconda-29683c67.mintlify.app/_mintlify/api/og/v2?division=Tutorials\u0026amp;title=Developing+a+chatbot\u0026amp;theme=a631e829865976b88c6af112\u0026amp;signature=03c0e048ae8f8af71858fb54e20cf3464b671197386a5f33c1f1451b5a659b7f\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/docs/mintlify-assets/_mintlify/favicons/anaconda-29683c67/Q6mS5k5M0lNdBscF/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Anaconda\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#1d6cf7\">\u003clink data-mint-head rel=\"canonical\" href=\"https://www.anaconda.com/docs/anaconda-desktop/tutorials/chatbot-tutorial\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/anaconda-desktop/tutorials/chatbot-tutorial.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://www.anaconda.com/#organization\",\"name\":\"Anaconda\",\"url\":\"https://www.anaconda.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/anaconda-29683c67/s-9WR15r5rZoaPqb/logo/light.svg?fit=max\u0026auto=format\u0026n=s-9WR15r5rZoaPqb\u0026q=85\u0026s=5996719b8530aaf065dc1ee1f39b2e67\"}},{\"@type\":\"WebSite\",\"@id\":\"https://www.anaconda.com/docs#website\",\"name\":\"Anaconda\",\"url\":\"https://www.anaconda.com/docs\",\"publisher\":{\"@id\":\"https://www.anaconda.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://www.anaconda.com/docs/anaconda-desktop/tutorials/chatbot-tutorial#webpage\",\"url\":\"https://www.anaconda.com/docs/anaconda-desktop/tutorials/chatbot-tutorial\",\"name\":\"Developing a chatbot\",\"dateModified\":\"2026-10-22T21:02:42.901Z\",\"isPartOf\":{\"@id\":\"https://www.anaconda.com/docs#website\"},\"breadcrumb\":{\"@id\":\"https://www.anaconda.com/docs/anaconda-desktop/tutorials/chatbot-tutorial#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://www.anaconda.com/docs/anaconda-desktop/tutorials/chatbot-tutorial#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Anaconda Desktop\",\"item\":\"https://www.anaconda.com/docs/anaconda-desktop/key-features\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Developing a chatbot\",\"item\":\"https://www.anaconda.com/docs/anaconda-desktop/tutorials/chatbot-tutorial\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://www.anaconda.com/docs/anaconda-desktop/tutorials/chatbot-tutorial#article\",\"headline\":\"Developing a chatbot\",\"name\":\"Developing a chatbot\",\"url\":\"https://www.anaconda.com/docs/anaconda-desktop/tutorials/chatbot-tutorial\",\"mainEntityOfPage\":{\"@id\":\"https://www.anaconda.com/docs/anaconda-desktop/tutorials/chatbot-tutorial#webpage\"},\"dateModified\":\"2026-10-22T21:02:42.901Z\",\"keywords\":\"chatbot, development, tutorial, natural language, ai, model, anaconda desktop\",\"publisher\":{\"@id\":\"https://www.anaconda.com/#organization\"},\"isPartOf\":{\"@id\":\"https://www.anaconda.com/docs#website\"}}]}\u003c/script>","siteName":"Anaconda","nav":{"global":null,"products":[{"product":"Anaconda Docs","icon":"https://mintlify.s3.us-west-1.amazonaws.com/anaconda-29683c67/images/anaconda-icon.svg","pages":[{"title":"Anaconda Docs","href":"/main"}]},{"product":"Getting Started","icon":"rocket-launch","pages":[{"title":"Getting Started","href":"/getting-started/main"}]},{"product":"Anaconda.org","icon":"globe","pages":[{"title":"Anaconda.org","href":"/anaconda-org/key-features"}]},{"product":"Anaconda Desktop","icon":"desktop","groups":[{"group":"Anaconda Desktop","tag":"Beta","pages":[{"title":"Anaconda Desktop","sidebarTitle":"Key features","href":"/anaconda-desktop/key-features"},{"title":"System requirements","href":"/anaconda-desktop/system-requirements"},{"title":"Installing Desktop","href":"/anaconda-desktop/install-desktop"},{"title":"Getting started with Anaconda Desktop","sidebarTitle":"Getting started","href":"/anaconda-desktop/getting-started-desktop"},{"title":"Environments","href":"/anaconda-desktop/environments"},{"title":"Packages","href":"/anaconda-desktop/packages"},{"title":"Channels","href":"/anaconda-desktop/channels"},{"title":"Model catalog","href":"/anaconda-desktop/model-catalog"},{"title":"Application catalog","href":"/anaconda-desktop/application-catalog"},{"title":"AI Models","href":"/anaconda-desktop/models"},{"title":"Chat","href":"/anaconda-desktop/chat"},{"title":"Model servers","href":"/anaconda-desktop/servers"},{"group":"Agent Studio","root":{"title":"Anaconda Agent Studio","sidebarTitle":"Agent Studio","tag":"Beta","href":"/anaconda-desktop/agent-studio/main"},"tag":"Beta","pages":[{"title":"Anaconda Assistant","sidebarTitle":"Anaconda Assistant","href":"/anaconda-desktop/agent-studio/anaconda-assistant"},{"title":"Agents","href":"/anaconda-desktop/agent-studio/agents"},{"title":"Configuring AI providers","sidebarTitle":"AI providers","href":"/anaconda-desktop/agent-studio/ai-providers"},{"title":"Plugins","sidebarTitle":"Plugins","href":"/anaconda-desktop/agent-studio/plugins"},{"title":"Skills","sidebarTitle":"Skills","href":"/anaconda-desktop/agent-studio/skills"},{"title":"Tool servers","sidebarTitle":"Tool servers","href":"/anaconda-desktop/agent-studio/tool-servers"},{"title":"Settings","sidebarTitle":"Settings","href":"/anaconda-desktop/agent-studio/settings"}]},{"title":"Anaconda MCP","sidebarTitle":"Anaconda MCP","tag":"Beta","href":"/anaconda-desktop/mcp"},{"title":"Anaconda Assistant","sidebarTitle":"Anaconda Assistant","tag":"Beta","href":"/anaconda-desktop/anaconda-assistant"},{"title":"Resource consumption","href":"/anaconda-desktop/resource-consumption"},{"title":"Settings","href":"/anaconda-desktop/settings"},{"group":"Desktop API","root":{"title":"Anaconda Desktop API","sidebarTitle":"Getting started","href":"/anaconda-desktop/desktop-api/getting-started"},"pages":[{"group":"Models","pages":[{"title":"Check the health of the models API","deprecated":null,"version":null,"openapi":"/api-reference/desktop-api.json get /api/models/health","href":"/api-reference/models/check-the-health-of-the-models-api"},{"title":"Get all models","deprecated":null,"version":null,"openapi":"/api-reference/desktop-api.json get /api/models","href":"/api-reference/models/get-all-models"},{"title":"Get model details by ID","deprecated":null,"version":null,"openapi":"/api-reference/desktop-api.json get /api/models/{id}","href":"/api-reference/models/get-model-details-by-id"},{"title":"List all files for a specific model","deprecated":null,"version":null,"openapi":"/api-reference/desktop-api.json get /models/{modelId}/files","href":"/api-reference/models/list-all-files-for-a-specific-model"},{"title":"Get details of a specific model file","deprecated":null,"version":null,"openapi":"/api-reference/desktop-api.json get /api/models/{modelId}/files/{fileId}","href":"/api-reference/models/get-details-of-a-specific-model-file"},{"title":"Delete a model file","deprecated":null,"version":null,"openapi":"/api-reference/desktop-api.json delete /api/models/{modelId}/files/{fileId}","href":"/api-reference/models/delete-a-model-file"},{"title":"Update download status of a model file","deprecated":null,"version":null,"openapi":"/api-reference/desktop-api.json patch /api/models/{modelId}/files/{fileId}","href":"/api-reference/models/update-download-status-of-a-model-file"}]},{"group":"Servers","pages":[{"title":"Check the health of the servers API","deprecated":null,"version":null,"openapi":"/api-reference/desktop-api.json get /api/servers/health","href":"/api-reference/servers/check-the-health-of-the-servers-api"},{"title":"Get all servers","deprecated":null,"version":null,"openapi":"/api-reference/desktop-api.json get /api/servers","href":"/api-reference/servers/get-all-servers"},{"title":"Create a new server","deprecated":null,"version":null,"openapi":"/api-reference/desktop-api.json post /api/servers","href":"/api-reference/servers/create-a-new-server"},{"title":"Get server details by ID","deprecated":null,"version":null,"openapi":"/api-reference/desktop-api.json get /api/servers/{serverId}","href":"/api-reference/servers/get-server-details-by-id"},{"title":"Delete a server","deprecated":null,"version":null,"openapi":"/api-reference/desktop-api.json delete /api/servers/{serverId}","href":"/api-reference/servers/delete-a-server"},{"title":"Control server state (start/stop)","description":null,"deprecated":null,"version":null,"openapi":"/api-reference/desktop-api.json patch /api/servers/{serverId}","href":"/api-reference/servers/control-server-state-startstop"}]}]},{"group":"Tutorials","pages":[{"title":"Developing a chatbot","href":"/anaconda-desktop/tutorials/chatbot-tutorial"},{"title":"Comparing text using embeddings","description":null,"href":"/anaconda-desktop/tutorials/embedding-tutorial"},{"title":"Crafting effective system prompts","href":"/anaconda-desktop/tutorials/system-prompt"}]},{"group":"Resources","pages":[{"title":"Frequently asked questions","href":"/anaconda-desktop/resources/faq"},{"title":"Security practices","href":"/anaconda-desktop/resources/desktop-security"},{"title":"Release notes","href":"/anaconda-desktop/resources/release-notes"}]},{"title":"Uninstalling Desktop","href":"/anaconda-desktop/uninstall-desktop"}]}]},{"product":"Package Security Manager","icon":"shield-check","versions":[{"version":"6.8.0"},{"version":"6.7.2"},{"version":"6.7.1"},{"version":"6.7.0"},{"version":"6.6.5"},{"version":"6.6.4"},{"version":"6.6.3"},{"version":"6.6.2"},{"version":"6.6.1"},{"version":"6.6.0"},{"version":"6.5.3"},{"version":"6.5.2"},{"version":"6.5.1"},{"version":"6.4.0"},{"version":"6.3.1"},{"version":"6.3.0"},{"version":"6.2.0"},{"version":"6.1.9"},{"version":"6.1.8"},{"version":"6.1.7"},{"version":"6.1.6"},{"version":"6.1.4"}],"pages":[{"title":"Package Security Manager","href":"/anaconda-platform/main"}]},{"product":"Anaconda Platform","icon":"layer-group","pages":[{"title":"Anaconda Platform","href":"/platform/main"}]},{"product":"Data Science \u0026 AI Workbench","icon":"chart-network","versions":[{"version":"5.9.0"},{"version":"5.8.1"},{"version":"5.8.0"},{"version":"5.7.1"},{"version":"5.7.0"},{"version":"5.6.2"},{"version":"5.6.1"},{"version":"5.6.0"},{"version":"5.5.2"},{"version":"5.5.1"}],"pages":[{"title":"Data Science \u0026 AI Workbench","href":"/data-science/latest/main"}]},{"product":"Anaconda CLI \u0026 MCP","icon":"terminal","pages":[{"title":"Anaconda CLI \u0026 MCP","href":"/cli-reference/anaconda-cli/getting-started"}]},{"product":"Legacy applications","icon":"window-restore","pages":[{"title":"Legacy applications","href":"/legacy/anaconda-navigator/main"}]},{"product":"Reference","icon":"book","pages":[{"title":"Reference","href":"/reference/release-notes"}]},{"product":"Support \u0026 Troubleshooting","icon":"headset","pages":[{"title":"Support \u0026 Troubleshooting","href":"/reference/help-support"}]},{"product":"Repository Managers","hidden":true,"pages":[{"title":"Repository Managers","href":"/repo-managers/main"}]}]},"basePath":"","title":"Developing a chatbot - Anaconda","buildId":"dpl_Acry4NrQAgjcikyFgVE2eJ7XQCAv","deploymentId":"dpl_Acry4NrQAgjcikyFgVE2eJ7XQCAv","dynamics":[],"chunks":[]}