izammohammed commited on
Commit
479188c
β€’
1 Parent(s): 734240a

uploaded main files

Browse files
Files changed (7) hide show
  1. CONTRIBUTING.md +33 -0
  2. LICENSE +21 -0
  3. README.md +49 -13
  4. app.py +52 -0
  5. requirements.txt +13 -0
  6. setup.py +10 -0
  7. store_index.py +0 -0
CONTRIBUTING.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributing to Legal Chatbot LLM
2
+
3
+ Thank you for considering contributing to the Legal Chatbot LLM project! Your contributions are highly valued and appreciated. To maintain a smooth and collaborative development process, please adhere to the following guidelines:
4
+
5
+ ## How to Contribute
6
+
7
+ 1. **Fork the Repository**: Fork the project on GitHub and create your own copy.
8
+
9
+ 2. **Create a Branch**: Create a new branch for your changes using `git checkout -b feature/improvement`.
10
+
11
+ 3. **Make Changes**: Implement your desired changes or improvements.
12
+
13
+ 4. **Commit Changes**: Commit your changes with a descriptive message using `git commit -am 'Add/Fix feature'`.
14
+
15
+ 5. **Push Changes**: Push your committed changes to your forked repository using `git push origin feature/improvement`.
16
+
17
+ 6. **Create a Pull Request**: Open a pull request on this repository's `main` branch.
18
+
19
+ ## Code Style and Standards
20
+
21
+ - Follow the coding style guidelines specified in the project. we are using `black` formatter and `flake8` linting
22
+ - Ensure your code adheres to the established standards and practices.
23
+ - Write clear and concise commit messages to facilitate the review process.
24
+
25
+ ## Reporting Issues
26
+
27
+ If you encounter any issues or bugs, please feel free to open an issue on the repository. Include detailed information about the problem, steps to reproduce it, and any relevant screenshots or error messages.
28
+
29
+ ## Contact
30
+
31
+ For any questions, suggestions, or discussions, please feel free to open an issue or contact the maintainer **Izam Mohammed** at **izamdeveloper1@gmail.com**.
32
+
33
+ Your contributions contribute to the continued improvement and success of the Legal Chatbot LLM project. Thank you for your support!
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Izam Mohammed
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,13 +1,49 @@
1
- ---
2
- title: Legal Advisor
3
- emoji: πŸ”₯
4
- colorFrom: blue
5
- colorTo: gray
6
- sdk: streamlit
7
- sdk_version: 1.31.1
8
- app_file: app.py
9
- pinned: false
10
- license: apache-2.0
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Legal Chatbot LLM
2
+
3
+ ## Overview
4
+ This project is a Legal Chatbot powered by Large Language Models (LLM) and RAG model. It allows users to ask questions related to legal terms and receive accurate responses. The chatbot utilizes a RAG (Retrieval-Augmented Generation) model to enhance its performance.
5
+
6
+ ![](assets/demo.png)
7
+
8
+ ## Features
9
+ - Utilizes LLM for natural language understanding and generation.
10
+ - Integrates vector databases for efficient retrieval of legal information.
11
+ - Implements a RAG model to combine retrieval and generation approaches for improved responses.
12
+ - Allows users to ask questions related to legal terms and concepts.
13
+ - Provides accurate and concise responses to user queries.
14
+ - User-friendly interface for seamless interaction.
15
+
16
+ ## Usage
17
+ 1. Clone the repository to your local machine.
18
+ 2. Install the required dependencies specified in the `requirements.txt` file.
19
+ 3. Run the main script to start the chatbot.
20
+ 4. Enter your legal queries and interact with the chatbot to receive responses.
21
+
22
+ ## Technologies Used
23
+ - Large Language Models (LLM)
24
+ - Vector Databases
25
+ - RAG (Retrieval-Augmented Generation) Model
26
+ - Python
27
+
28
+ ## Installation
29
+ ```bash
30
+ git clone https://github.com/your_username/legal-chatbot.git
31
+ cd legal-chatbot
32
+ pip install -r requirements.txt
33
+ python app.py
34
+ ```
35
+
36
+ ## Contributing
37
+ Contributions are welcome! If you'd like to contribute to this project, please follow these steps:
38
+ 1. Fork the repository.
39
+ 2. Create a new branch (`git checkout -b feature/improvement`).
40
+ 3. Make your changes.
41
+ 4. Commit your changes (`git commit -am 'Add new feature'`).
42
+ 5. Push to the branch (`git push origin feature/improvement`).
43
+ 6. Create a new Pull Request.
44
+
45
+ ## License
46
+ This project is under [MIT Licence](LICENSE)
47
+
48
+ ## Contact
49
+ For any inquiries or feedback, please contact [Izam mohammed] at [izamdeveloper1@gmail.com].
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.title("Legal Advisor πŸ“š")
4
+
5
+ # Sidebar for selecting the chatbot
6
+ selected_chatbot = st.sidebar.radio("Select Chatbot", ("OpenAI", "Llama 2"))
7
+ if selected_chatbot == "OpenAI":
8
+ from src import openai_call
9
+ elif selected_chatbot == "Llama 2":
10
+ st.warning(
11
+ "It might take some time to get response becuase of the size of Llama 2 model ⚠️"
12
+ )
13
+ from src import llama_call
14
+
15
+ # Initialize chat history
16
+ if "messages" not in st.session_state:
17
+ st.session_state.messages = []
18
+ st.info("""
19
+ **Legal Advisor Bot:**
20
+ - **Objective:** Develop a conversational AI chatbot to provide legal advice and assistance. πŸ€–πŸ’Ό
21
+ - **Technology Stack:** Utilizes Streamlit for the user interface, integrates with external chatbot APIs (such as OpenAI and Llama 2) for natural language processing. πŸ–₯οΈπŸ“‘
22
+ - **Features:**
23
+ - Allows users to select between different chatbot models for varied responses. πŸ”„
24
+ - Provides a chat history feature to track user interactions. πŸ“
25
+ - Displays loading spinner while fetching responses from the selected chatbot. ⏳
26
+ - Offers a user-friendly interface for asking legal questions. πŸ’¬
27
+ - **Emphasis:** Focuses on simplicity, efficiency, and accessibility in delivering legal information and support through conversational AI. 🎯
28
+ """)
29
+ # Display chat messages from history on app rerun
30
+ for message in st.session_state.messages:
31
+ with st.chat_message(message["role"]):
32
+ st.markdown(message["content"])
33
+
34
+ # React to user input
35
+ if prompt := st.chat_input("Ask something about law"):
36
+ # Display user message in chat message container
37
+ st.chat_message("user").markdown(prompt)
38
+ # Add user message to chat history
39
+ st.session_state.messages.append({"role": "user", "content": prompt})
40
+
41
+ # Add a loading spinner while waiting for response
42
+ with st.spinner("Thinking ✨..."):
43
+ if selected_chatbot == "Llama 2":
44
+ response = llama_call(prompt)
45
+ elif selected_chatbot == "OpenAI":
46
+ response = openai_call(prompt)
47
+
48
+ # Display assistant response in chat message container
49
+ with st.chat_message("assistant"):
50
+ st.markdown(response)
51
+ # Add assistant response to chat history
52
+ st.session_state.messages.append({"role": "assistant", "content": response})
requirements.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ langchain
2
+ pymupdf
3
+ pinecone-client
4
+ sentence-transformers
5
+ pypdf
6
+ langchain_pinecone
7
+ ctransformers
8
+ openai
9
+ python-dotenv
10
+ # faiss-gpu==1.7.2
11
+ streamlit
12
+ langchain-community
13
+ langchain-openai
setup.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from setuptools import find_packages, setup
2
+
3
+ setup(
4
+ name="Legal Chatbot",
5
+ version="0.0.1",
6
+ author="Izam Mohammed",
7
+ author_email="izamdeveloper1@gmail.com",
8
+ packages=find_packages(),
9
+ install_requires=[],
10
+ )
store_index.py ADDED
File without changes