# Create a chat generation Q&A application
URL: https://docs.datarobot.com/en/docs/wb-apps/custom-apps/create-qa-app.html

> Create a custom chat generation Q&A application in DataRobot to prototype, explore, and showcase the results of LLM models you've built.

# Create a chat generation Q&A application

> [!NOTE] Premium
> The chat generation Q&A application is a premium GenAI feature. To enable, contact your DataRobot representative.

You can create a chat generation Q&A application with DataRobot to explore knowledge base Q&A use cases while leveraging Generative AI to repeatedly make business decisions and showcase business value. The Q&A app offers an intuitive and responsive way to prototype, explore, and share the results of LLM models you've built. The Q&A app powers generative AI conversations backed by citations and allows you to provide feedback on responses. Additionally, you can [share](https://docs.datarobot.com/en/docs/wb-apps/custom-apps/manage-custom-app.html) the app with non-DataRobot users to expand its usability.

## Prepare a text generation deployment

To build a chat generation Q&A application, you must first prepare and configure a deployment. You need to create a deployment with a [text generation target type](https://docs.datarobot.com/en/docs/classic-ui/mlops/monitor/generative-model-monitoring.html#create-and-deploy-a-generative-custom-inference-model).

> [!NOTE] Note
> When you [deploy an LLM](https://docs.datarobot.com/en/docs/agentic-ai/playground-tools/deploy-llm.html#deploy-an-llm-from-the-playground) for a Q&A app, ensure that you add the playground LLM to the Workshop after enabling the Q&A app feature to provide citations for responses in the app.

Once you have created the deployment, you have the option to configure an external custom metric to collect feedback for the Q&A app's responses:

1. Access the deployment from theConsole > Deploymentspage. Select the deployment and navigate to theMonitoring > Custom metricstab.
2. ClickAdd new custom metricand selectAdd an external custom metricfrom the dropdown.
3. Configure the feedback metric as displayed in the screenshot below. When you have finished configuration, clickAdd custom metric.
4. Additionally, set up anassociation IDfor the deployment in order to store submitted feedback (via the custom metric) with the associated prompt and response data. Without an association ID, the feedback custom metric is only able to store responses aggregated by time values.
5. After configuring the deployment with the appropriate custom metrics,note the deployment ID and custom metric ID. They are be used to build the chat generation Q&A application. To locate the custom metric ID, select theActions menuon the configured custom metric in the deployment and clickEdit. The dialog box lists the metric ID.

## Build a chat generation Q&A application

To build a chat generation Q&A app, use the following steps:

1. InRegistry, go to theApplication sourcestile. Then, click the+ Add new application sourcedropdown and select+ Create new application from template gallery.
2. From the template gallery, select theQ&A Chat Generation Apptemplate, and then clickCreate application source.
3. On the application source page, scroll down to theRuntime Parameterssection and edit theCUSTOM_METRIC_IDandDEPLOYMENT IDparameters by clicking the pencil icon. Provide the custom metric ID and the deployment ID from the text generation deploymentconfigured previously.
4. After specifying a deployment and custom metric ID, clickBuild application. You can access the application by expanding the application source as well as theApplicationspage. After it builds, clickOpento view and use the application. NoteClick theActions menunext to an application toShareorDeletethe application.

## Use the chat generation Q&A application

To begin using the chat generation Q&A application, go to the Applications page, and then click Open next to your Q&A app.

> [!NOTE] Note
> If your Q&A application fails to load or displays a warning icon on the Open button, review the application source's logs to troubleshoot the behavior. If the app is shared with other users, the error may be stored in their logs.

When the Q&A application loads, provide a prompt to initiate a chat. Allow some time for the app to run and return an answer to the prompt.

The app will respond with an answer, accompanied by the response's latency and confidence scores. You can provide feedback for an application's prompt response by selecting thumbs up or down.  (For feedback, you must have [configured a custom metric](https://docs.datarobot.com/en/docs/wb-apps/custom-apps/create-qa-app.html#build-a-chat-generation-QA-application) for collecting prompt response feedback.)

Additionally, click Citations to view a dialog box that details the source(s) from which the application finds its answer to the prompt.

## Manage the chat generation Q&A application

You can use a code-first workflow to manage the chat generation Q&A application. To access the flow, navigate to [DataRobot's GitHub repo](https://github.com/datarobot-oss/qa-app-streamlit). The repo contains a modifiable template for application components. These components include multiple [Streamlit settings](https://docs.streamlit.io/develop/concepts/architecture/app-chrome). Review an overview of the template's contents below.

| File | Description |
| --- | --- |
| qa_chat_bot.py | The main app function, which includes all other necessary files. Here you can modify the basic page configuration (title, favicon, width) and add any additional elements such as sidebar or links to additional subpages. |
| constants.py | All translatable strings for application and user configuration: display name, app logo, sidebar settings, etc. |
| components.py | The render functions for both customized and default Streamlit elements used within the app. |
| dr_requests.py | The DataRobot API request functions. |
| styles/main.scss | A SASS stylesheet that is compiled to CSS on app start and is used to customize Streamlit-native components via SAL. You can compile it manually by running streamlit-sal compile. |
| styles/variables.scss | The styles used to modify various CSS variables such as colors or borders. |
| .streamlit/config.toml | The Streamlit configuration file. Under [theme] you can define your own app colors. Note that a full app restart is necessary for the values to take effect. |

To work with the repo, clone it and then continue to develop your version of the app by modifying the files above. You can release the modified application via [the DRApps CLI](https://docs.datarobot.com/en/docs/wb-apps/custom-apps/host-custom-app.html) or by [uploading it via theApplication sourcestile](https://docs.datarobot.com/en/docs/wb-apps/custom-apps/upload-custom-app.html).

---
