Create a chat generation Q&A application¶
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 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.
Note
When you deploy an LLM for a Q&A app, ensure that you add the playground LLM to the Model 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:
-
Access the deployment from the Console > Deployments page. Select the deployment and navigate to the Monitoring > Custom metrics tab.
-
Click Add new custom metric and select Add an external custom metric from the dropdown.
-
Configure the feedback metric as displayed in the screenshot below. When you have finished configuration, click Add custom metric.
-
Additionally, set up an association ID for 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.
-
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 the Actions menu on the configured custom metric in the deployment and click Edit. 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:
-
In the Registry, click the Applications page, and then click Add new application source > Create new application from template gallery in the top-right corner of the page.
-
From the template gallery, select the Q&A Chat Generation App template, and then click Create application source.
-
On the application source page, scroll down to the Runtime Parameters section and edit the
CUSTOM_METRIC_ID
andDEPLOYMENT ID
parameters by clicking the pencil icon. Provide the custom metric ID and the deployment ID from the text generation deployment configured previously. -
After specifying a deployment and custom metric ID, click Build application. The application is added to the All applications list with the Initializing status. After it builds, you can click Open to view and use the application.
Note
You can click the Actions menu next to a custom application in the Applications tab to Share or Delete the application.
Use the chat generation Q&A application¶
To begin using the chat generation Q&A application, go to the Registry, locate your QA app in the Applications > All applications list, then click Open.
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 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. The repo contains a modifiable template for application components. These components include multiple Streamlit settings. 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 or by uploading it via the Applications page.