Quick Start
Introduction
The Clair base model have been trained to understand natural language clinical questions and provides natural language answer with references and evidence summary. Below is a demo open-source flask application that allows users to submit clinical queries and retrieve responses using the Clair API. The application uses server-sent events (SSE) to stream the generated text back to the client as it becomes available using the Clair JS SDK.
To explore other endpoints or use our model without streaming or the Clair JS SDK, checkout our API reference page.
Quick Start
If you want to see a demo application in action, follow the steps below. The repository contains all the code you need with comments explaining all the steps. If you are interested in the API reference, you can check out to our API reference page.
1. Clone the repository
2. Install the required dependencies using pip
3. Add your Clair API token
Before running the application, you need to provide your Clair access token. You can get a Clair access token by making a developer account at https://askclair.ai . Feel free to contact us at hello@askclair.ai
Follow these steps:
- Open the app.py file.
- Locate the line token = f"token {your_token}".
- Replace your_token with your actual Clair access token.
Note: You should use environment variables in production.
4. Usage
To start the Flask application, run the following command:
This will start the Flask development server, and you should see the application running on http://localhost:5000
.
5. Submitting a Query
- Open your web browser and navigate to http://localhost:5000.
- Enter your clinical query in the input field provided.
- Click the "Submit" button or press Enter to submit the query. The application will send the question to the Clair server and retrieve a streaming channel for receiving the generated text.
6. Listening for Responses
Once the query has been submitted and the streaming channel has been obtained, the application will render the listening.html template. This page allows you to listen for responses as they become available.
- Click the "Start Listening" button to initiate the connection and start receiving events.
- The page will update with the generated answer, context, and references as they are received from the Clair server.
- Once the stream ends, the console will display a message indicating that the stream has ended.
7. Retrieving Full Details
After the query has finished streaming, you can retrieve the full details by using the query_id. It is recommended to save the query_id in your database for later retrieval.