Spaces:
Runtime error

File size: 1,782 Bytes
ecdef15
 
 
 
 
 
 
 
 
 
 
 
9e11b68
 
ab02bb4
9e11b68
 
 
 
 
 
 
f9a0a33
9e11b68
f9a0a33
9e11b68
 
f9a0a33
9e11b68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ab02bb4
9e11b68
f9a0a33
9e11b68
 
f9a0a33
9e11b68
 
 
 
ab02bb4
377f682
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
title: KTUGPT
emoji: 📚
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 4.28.3
app_file: app.py
pinned: false
license: mit
---

# KTUGPT-Python

A Flask web application that is designed for answering questions based on the context from the PDFs. It uses the [mistralai/Mistral-7B-Instruct-v0.1](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1) model as the large language model (LLM) and the [hkunlp/instructor-xl](https://huggingface.co/hkunlp/instructor-xl) model for embedding text representations.


## Setup

- Clone this repository:

   ```
   git clone https://github.com/sameemul-haque/KTUGPT-Python.git
   ```
- After cloning the repository, navigate into the `KTUGPT-Python` directory

   ```
   cd KTUGPT-Python
   ```

- Set up a Python virtual environment:

   ```
   python -m venv venv
   ```

- Activate the virtual environment:

   - GNU/Linux | MacOS:
     ```
     source venv/bin/activate
     ```
   - Windows:
     ```
     venv\Scripts\activate
     ```

- Install dependencies:

   ```
   pip install -r requirements.txt
   ```

6. Create a `.env` file based on `.env.example` and add your [Hugging Face API token](https://huggingface.co/docs/hub/en/security-tokens) and [MongoDB Connection String](https://www.mongodb.com/docs/manual/reference/connection-string/)

- Run the app:

   ```
   python app.py 
   ```

## Usage

Once the Flask app is running, you can send POST requests to `http://127.0.0.1:5000` with a query parameter `q` containing your question. The app will return an answer based on the configured language model and retrieval method. For example, `http://127.0.0.1:5000/?q=what%20is%20operating%20system?`

![preview](https://raw.githubusercontent.com/sameemul-haque/KTUGPT-Python/preview/preview.png "preview")