Spaces:
Sleeping
Sleeping
Merge pull request #55 from almutareb/hotfix_adding_sources_from_vs
Browse filesfixed the knowledgeBase_search function to use the sources cache properly
- CODE_OF_CONDUCT.md +85 -0
- CONTRIBUTION.md +32 -0
- README.md +51 -23
- rag_app/agents/react_agent.py +1 -1
- rag_app/structured_tools/structured_tools.py +9 -3
CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Code of Conduct
|
2 |
+
|
3 |
+
## Our Pledge
|
4 |
+
|
5 |
+
We as members, contributors, and leaders pledge to make participation in our community a respectful, inclusive, and collaborative experience for everyone. We commit to an environment where individuals can learn from each other, share knowledge, and grow together. Our core values are curiosity, respect, transparency, responsibility, and team spirit.
|
6 |
+
|
7 |
+
## Our Standards
|
8 |
+
|
9 |
+
To foster a positive environment, we pledge to:
|
10 |
+
|
11 |
+
- **Curiosity**: Encourage and support inquisitiveness and continuous learning.
|
12 |
+
- **Respect**: Be considerate and respectful to all members, valuing each individual’s contributions and perspectives.
|
13 |
+
- **Transparency**: Communicate openly and honestly, and provide clear and constructive feedback.
|
14 |
+
- **Responsibility**: Take ownership of our actions and their impact on others, acknowledging and rectifying mistakes.
|
15 |
+
- **Team Spirit**: Work collaboratively, supporting and uplifting one another to achieve common goals.
|
16 |
+
|
17 |
+
Examples of behavior that contributes to a positive environment include:
|
18 |
+
|
19 |
+
- Demonstrating empathy and kindness towards others
|
20 |
+
- Being respectful of differing opinions, viewpoints, and experiences
|
21 |
+
- Giving and gracefully accepting constructive feedback
|
22 |
+
- Focusing on what is best for the community
|
23 |
+
- Showing appreciation for contributions and celebrating successes
|
24 |
+
|
25 |
+
Examples of unacceptable behavior include:
|
26 |
+
|
27 |
+
- The use of sexualized language or imagery, and unwelcome sexual attention or advances
|
28 |
+
- Trolling, insulting or derogatory comments, and personal or political attacks
|
29 |
+
- Public or private harassment
|
30 |
+
- Publishing others’ private information, such as a physical or email address, without explicit permission
|
31 |
+
- Any other conduct which could reasonably be considered inappropriate in a professional setting
|
32 |
+
|
33 |
+
## Enforcement Responsibilities
|
34 |
+
|
35 |
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior. They will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
36 |
+
|
37 |
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that do not align with this Code of Conduct. They will communicate reasons for moderation decisions when appropriate.
|
38 |
+
|
39 |
+
## Scope
|
40 |
+
|
41 |
+
This Code of Conduct applies within all community spaces, and it also applies when an individual is representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as a representative at an online or offline event.
|
42 |
+
|
43 |
+
## Enforcement
|
44 |
+
|
45 |
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [[email protected]]. All complaints will be reviewed and investigated promptly and fairly.
|
46 |
+
|
47 |
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
48 |
+
|
49 |
+
## Enforcement Guidelines
|
50 |
+
|
51 |
+
Community leaders will follow these guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
52 |
+
|
53 |
+
### 1. Correction
|
54 |
+
|
55 |
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
56 |
+
|
57 |
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
58 |
+
|
59 |
+
### 2. Warning
|
60 |
+
|
61 |
+
**Community Impact**: A violation through a single incident or series of actions.
|
62 |
+
|
63 |
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
64 |
+
|
65 |
+
### 3. Temporary Ban
|
66 |
+
|
67 |
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
68 |
+
|
69 |
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
70 |
+
|
71 |
+
### 4. Permanent Ban
|
72 |
+
|
73 |
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
74 |
+
|
75 |
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
76 |
+
|
77 |
+
## Attribution
|
78 |
+
|
79 |
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
80 |
+
|
81 |
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
82 |
+
|
83 |
+
For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
84 |
+
|
85 |
+
[homepage]: https://www.contributor-covenant.org
|
CONTRIBUTION.md
CHANGED
@@ -1,3 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# Pull Request Template
|
2 |
|
3 |
## Description
|
|
|
1 |
+
# Contributing to Insurance Advisor Agent(s)
|
2 |
+
|
3 |
+
We are excited that you are interested in contributing to the Insurance Advisor Agent(s) project! Your contributions are invaluable to us. Please follow the guidelines below to contribute.
|
4 |
+
|
5 |
+
## How to Contribute
|
6 |
+
|
7 |
+
### Reporting Issues
|
8 |
+
If you find any bugs or have any suggestions for improvements, please report them by opening an issue in the repository.
|
9 |
+
|
10 |
+
### Fork and Pull Request Workflow
|
11 |
+
1. **Fork the Repository**: Click the "Fork" button on the top right of the repository page.
|
12 |
+
2. **Clone Your Fork**:
|
13 |
+
```sh
|
14 |
+
git clone https://github.com/your-username/insurance-advisor-agent.git
|
15 |
+
cd insurance-advisor-agent
|
16 |
+
|
17 |
+
3. **Create a Branch**:
|
18 |
+
```sh
|
19 |
+
git checkout -b feature-branch
|
20 |
+
|
21 |
+
4. **Make Your Changes: Make the necessary changes in your branch.**
|
22 |
+
5. **Commit Your Changes**:
|
23 |
+
```sh
|
24 |
+
git add .
|
25 |
+
git commit -m "Description of the changes"
|
26 |
+
|
27 |
+
6. **Push to Your Fork**:
|
28 |
+
```sh
|
29 |
+
git push origin feature-branch
|
30 |
+
|
31 |
+
7. **Create a Pull Request: Go to the original repository on GitHub and click "New Pull Request". Select your branch and submit your pull request.**
|
32 |
+
|
33 |
# Pull Request Template
|
34 |
|
35 |
## Description
|
README.md
CHANGED
@@ -12,26 +12,54 @@ pinned: false
|
|
12 |
|
13 |
# Insurance Advisor Agent(s)
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
# Insurance Advisor Agent(s)
|
14 |
|
15 |
+
Welcome to the Insurance Advisor Agent(s) project! This project aims to set up a modular, multi-agent system to handle inquiries for an insurance company. The system utilizes various approaches to provide reliable answers regarding insurance products.
|
16 |
+
|
17 |
+
## Features
|
18 |
+
|
19 |
+
### Vectorstore Search
|
20 |
+
- **Multi-index (chunks + summaries)**
|
21 |
+
- **Metadata Filtering**
|
22 |
+
- **Re-ranking** [DONE]
|
23 |
+
- **Hybrid Search (BM25 + Vectorstore)** [DONE]
|
24 |
+
- **HyDE/HyQE**
|
25 |
+
|
26 |
+
### ReAct Agent
|
27 |
+
- **Usage of ReAct Agent instead of Chain** [DONE]
|
28 |
+
- **Added Tools (Google Search Engine)** [DONE]
|
29 |
+
- **Query Re-writing**
|
30 |
+
- **Additional Enhancements**
|
31 |
+
|
32 |
+
### Corrective RAG
|
33 |
+
- Implementation of Corrective Retrieval-Augmented Generation
|
34 |
+
|
35 |
+
### Workflow for Agents
|
36 |
+
- Determination of the customer's funnel stage
|
37 |
+
- Custom prompts for each step
|
38 |
+
- Following a structured "script"
|
39 |
+
|
40 |
+
## Getting Started
|
41 |
+
|
42 |
+
To get started with this project, follow these steps:
|
43 |
+
|
44 |
+
1. **Clone the Repository**:
|
45 |
+
```sh
|
46 |
+
git clone https://github.com/your-username/insurance-advisor-agent.git
|
47 |
+
cd insurance-advisor-agent
|
48 |
+
|
49 |
+
2. **Install Dependencies**:
|
50 |
+
```sh
|
51 |
+
pip install -r requirements.txt
|
52 |
+
|
53 |
+
3. **Run the Application**:
|
54 |
+
```sh
|
55 |
+
python main.py
|
56 |
+
|
57 |
+
## Contributing
|
58 |
+
|
59 |
+
We welcome contributions! Please read our Contributing Guide to get started.
|
60 |
+
License
|
61 |
+
|
62 |
+
This project is licensed under the MIT License. See the LICENSE file for details.
|
63 |
+
Contact
|
64 |
+
|
65 |
+
If you have any questions or suggestions, feel free to open an issue or start a discussion.
|
rag_app/agents/react_agent.py
CHANGED
@@ -9,7 +9,7 @@ import os
|
|
9 |
from dotenv import load_dotenv
|
10 |
# local cache
|
11 |
from langchain.globals import set_llm_cache
|
12 |
-
from
|
13 |
#from langchain.cache import InMemoryCache # in memory cache
|
14 |
from rag_app.structured_tools.structured_tools import (
|
15 |
google_search, knowledgeBase_search
|
|
|
9 |
from dotenv import load_dotenv
|
10 |
# local cache
|
11 |
from langchain.globals import set_llm_cache
|
12 |
+
from langchain_community.cache import SQLiteCache # sqlite
|
13 |
#from langchain.cache import InMemoryCache # in memory cache
|
14 |
from rag_app.structured_tools.structured_tools import (
|
15 |
google_search, knowledgeBase_search
|
rag_app/structured_tools/structured_tools.py
CHANGED
@@ -9,7 +9,7 @@ from rag_app.loading_data.load_S3_vector_stores import get_chroma_vs
|
|
9 |
import chromadb
|
10 |
|
11 |
from rag_app.utils.utils import (
|
12 |
-
parse_list_to_dicts, format_search_results
|
13 |
)
|
14 |
import chromadb
|
15 |
import os
|
@@ -78,8 +78,14 @@ def knowledgeBase_search(query:str) -> str:
|
|
78 |
docs = retriever.invoke(query)
|
79 |
|
80 |
# add the session id to each element in `docs`
|
81 |
-
[i.
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
for doc in docs:
|
85 |
print(doc)
|
|
|
9 |
import chromadb
|
10 |
|
11 |
from rag_app.utils.utils import (
|
12 |
+
parse_list_to_dicts, format_search_results, hash_text
|
13 |
)
|
14 |
import chromadb
|
15 |
import os
|
|
|
78 |
docs = retriever.invoke(query)
|
79 |
|
80 |
# add the session id to each element in `docs`
|
81 |
+
#[i.update({"session_id":db.session_id}) for i in docs]
|
82 |
+
tmp_dict = []
|
83 |
+
for x in docs:
|
84 |
+
#x.metadata.update({"session_id":db.session_id})
|
85 |
+
case = {"url": x.metadata['source'], "session_id":db.session_id, "summary": x.page_content,"hash_id": hash_text(x.metadata['source'])}
|
86 |
+
tmp_dict.append(case)
|
87 |
+
|
88 |
+
db.add_many(tmp_dict)
|
89 |
|
90 |
for doc in docs:
|
91 |
print(doc)
|