This is a Flask application that allows users to submit clinical queries and retrieve responses using the Clair server. The application uses server-sent events (SSE) to stream the generated text back to the client as it becomes available.
-
Clone the repository:
git clone https://github.com/Jonathan-Adly/clair_streaming_demo
-
Install the required dependencies using pip:
pip install -r requirements.txt
Before running the application, you need to provide your Clair access token. You can get a Clair access token by making developer account at https://askclair.ai . Feel free to contact us at [email protected] .
Follow these steps:
- Open the
app.py
file. - Locate the line
TOKEN = ""
. - Replace
TOKEN
with your actual Clair access token.
You should use enviromental variables in production.
To start the Flask application, run the following command:
flask run
This will start the Flask development server, and you should see the application running on http://localhost:5000
.
- 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.
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. H
-
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.
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.
If you'd like to contribute to this project, please follow these steps:
- Fork the repository on GitHub.
- Create a new branch with a descriptive name for your feature or bug fix.
- Commit your changes and push the branch to your fork.
- Submit a pull request explaining your changes and why they should be merged.
This project is licensed under the MIT License.