Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project 1: AI Chatbot for Whole Website #2253

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6ba5c48
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
bb3de22
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
4628657
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
cf395c2
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
8322350
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
cad5f3f
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
4019d8b
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
2d591c1
Merge branch 'main' into Project1_Jisan
JisanAR03 Jun 3, 2024
d15b241
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
4efc347
Merge branch 'Project1_Jisan' of github.com:JisanAR03/BLT into Projec…
JisanAR03 Jun 3, 2024
57b2d98
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
7de11cd
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
c681965
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
fc83e1e
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
eec543e
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
66ef01f
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
ccd73d6
Delete poetry.lock
JisanAR03 Jun 3, 2024
8e2526f
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
696a890
Merge branch 'Project1_Jisan' of github.com:JisanAR03/BLT into Projec…
JisanAR03 Jun 3, 2024
5514f72
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
9878415
Project 1: AI Chatbot for Whole Website BY Jisan
JisanAR03 Jun 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions blt/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
google_callback,
like_issue2,
like_issue3,
question_answer_view,
select_bid,
submit_pr,
subscribe_to_domains,
Expand Down Expand Up @@ -523,6 +524,7 @@
ContributorStatsView.as_view(today=True),
name="today-contributor-stats",
),
path("api/ask/", question_answer_view, name="ask"),
]

if settings.DEBUG:
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ pillow = "^10.2.0"
chromedriver-autoinstaller = "^0.6.4"
sentry-sdk = "^2.3.1"
bitcash = "^1.0.2"
langchain = "^0.2.1"
langchain-community = "^0.2.1"
langchain-core = "^0.2.1"
langchain-openai = "^0.1.7"
langchain-text-splitters = "^0.2.0"
faiss-cpu = "^1.8.0"
tiktoken = "^0.7.0"

[tool.poetry.group.dev.dependencies]
black = "^24.2.0"
Expand Down
98 changes: 98 additions & 0 deletions website/bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import os

from dotenv import find_dotenv, load_dotenv
from langchain.chains import ConversationalRetrievalChain
from langchain.memory import ConversationSummaryMemory
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_community.document_loaders import (
DirectoryLoader,
Docx2txtLoader,
PyPDFLoader,
TextLoader,
UnstructuredMarkdownLoader,
)
from langchain_community.vectorstores import FAISS
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI, OpenAIEmbeddings

load_dotenv(find_dotenv(), override=True)


def load_document(file_path):
name, extension = os.path.splitext(file_path)
if extension == ".pdf":
loader = PyPDFLoader(file_path)
elif extension == ".docx":
loader = Docx2txtLoader(file_path)
elif extension == ".txt":
loader = TextLoader(file_path)
elif extension == ".md":
loader = UnstructuredMarkdownLoader(file_path)
else:
raise ValueError("Unsupported file format: " + extension)
data = loader.load()
return data


def load_directory(dir_path):
loader = DirectoryLoader(dir_path)
data = loader.load()
return data


def split_document(chunk_size, chunk_overlap, document):
text_splitter = RecursiveCharacterTextSplitter(
chunk_size=chunk_size,
chunk_overlap=chunk_overlap,
length_function=len,
)
docs = text_splitter.split_documents(document)
return docs


def embed_documents_and_save(embedDocs, db_dir="", db_name="faiss_index"):
if not os.path.exists(db_dir):
os.makedirs(db_dir)

db_path = os.path.join(db_dir, db_name)
embeddings = OpenAIEmbeddings(model="text-embedding-3-small")

if os.path.exists(db_path):
db = FAISS.load_local(db_path, embeddings, allow_dangerous_deserialization=True)
db.add_documents(embedDocs)
else:
db = FAISS.from_documents(embedDocs, embeddings)

db.save_local(db_path)
return db


def load_vector_store(db_path):
embeddings = OpenAIEmbeddings(model="text-embedding-3-small")
if not os.path.exists(db_path):
raise FileNotFoundError(f"FAISS index directory does not exist: {db_path}")
db = FAISS.load_local(db_path, embeddings, allow_dangerous_deserialization=True)
return db


def conversation_chain(vector_store):
prompt = ChatPromptTemplate.from_messages(
(
"human",
"You are an assistant specifically designed for answering questions about the OWASP Bug Logging Tool (BLT) application. Use the following pieces of retrieved context to answer the question. If the user's question is not related to the BLT application or if the context does not provide enough information to answer the question, respond with 'Please ask a query related to the BLT Application.' Ensure your response is concise and does not exceed three sentences.\nQuestion: {question}\nContext: {context}\nAnswer:",
)
)
llm = ChatOpenAI(model_name="gpt-3.5-turbo-0125", temperature=0.5)
retriever = vector_store.as_retriever(search_type="similarity", search_kwargs={"k": 3})
memory = ConversationSummaryMemory(
llm=llm, return_messages=True, memory_key="chat_history", max_token_limit=1000
)

crc = ConversationalRetrievalChain.from_llm(
llm=llm,
retriever=retriever,
memory=memory,
chain_type="stuff",
combine_docs_chain_kwargs={"prompt": prompt},
)
return crc, memory
76 changes: 76 additions & 0 deletions website/documents/BltAboutUs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
### Detailed Description of the "About Us" UI Component and the url path is "https://blt.owasp.org/about/" for the OWASP Bug Logging Tool (BLT) Application

#### 1. Component Overview
The "About Us" UI component in the OWASP Bug Logging Tool (BLT) application provides users with comprehensive information about the BLT project, its purpose, functionalities, and how it benefits users. This section aims to inform users about the initiative's goals, how it operates, and the incentives for participating in bug reporting.

#### 2. User Interaction
Users interact with the About Us component through the following steps:
1. **Accessing the Component**: Users navigate to the "About Us" section via the sidebar menu.
2. **Reading Information**: Users read through the detailed information provided to understand the BLT initiative, its goals, and how they can participate.
3. **Navigating Links**: Users may click on embedded links to access related pages or external resources for more detailed information.

#### 3. Key Elements
- **Navigation Sidebar**: Contains links to various sections of the BLT application, including Issues, Companies, Scoreboard, Users, Teams, Bug Bounties, and more.
- **About BLT Section**: Provides a detailed description of the BLT project, emphasizing its open-source nature, non-commercial goals, and community-driven approach.
- **User Benefits**: Describes the incentives for users, including points, money from sponsored bug hunts, leaderboard recognition, and tips for finding bugs.
- **How It Works**: Provides step-by-step instructions for testers on how to participate, including creating a user account, describing bugs, attaching screenshots, and submitting information.
- **Organization Benefits**: Explains the advantages for organizations in maintaining a bug-free website and how they can participate in the bug bounty program.
- **Additional Information**: Includes links to terms and conditions, privacy policy, and other relevant documentation.

#### 4. Visual Design
- **Layout**: The layout features a left sidebar for navigation and a main content area displaying the detailed information. The text is organized into sections with clear headings for easy reading.
- **Color Scheme**: The design uses a consistent color scheme with red, white, and grey tones, matching the overall BLT branding. Red is used for headings and links to draw attention.
- **Typography**: Modern, readable fonts are used for headings, body text, and links, ensuring clarity and ease of reading.
- **Visual Cues**: Headings and sections are clearly delineated, and links are highlighted to indicate interactivity.

#### 5. Accessibility Features
- **Keyboard Navigation**: All interactive elements can be accessed and operated via keyboard shortcuts, allowing users with mobility impairments to navigate and use the component.
- **Screen Reader Compatibility**: The text and links are labeled clearly to be compatible with screen readers, aiding visually impaired users in understanding and interacting with the component.
- **High Contrast**: Text and interactive elements have high contrast against the background, making it easier for users with visual impairments to read the content.
- **Descriptive Labels**: All interactive elements have clear and descriptive labels to ensure users understand their purpose and functionality.

#### 6. Error Handling
The About Us component includes mechanisms to handle errors and provide feedback to users:
- **Error Messages**: If an error occurs while loading the information or navigating links, clear and concise error messages are displayed to inform the user and provide steps to resolve the issue.
- **Fallback Content**: If the main content fails to load, the page provides fallback messages or placeholders, ensuring that the user experience is not significantly disrupted.
- **Input Validation**: Ensures that users enter valid input before submitting queries or interactions.

#### 7. Performance
The component is designed with several features to enhance performance and user experience:
- **Optimized Loading**: The page is optimized to load quickly, allowing users to access the information without delay.
- **Responsive Design**: The layout is fully responsive, adapting to different screen sizes and devices to ensure a consistent and accessible experience across desktops, tablets, and mobile devices.
- **Efficient Data Retrieval**: Uses efficient data retrieval techniques to fetch and display information quickly, minimizing wait times and enhancing user satisfaction.
- **Scalability**: The component is designed to handle a large amount of textual information, maintaining performance and user experience even with extensive content.



About us Page content :
About BLT
BLT is 100% free to use, Open Source and a non-commercial, not for profit initiative. All prize money goes directly to the bug hunter.
Software code allows us to buy a gift for Mom or Dad on amazon.com in 7 seconds, watch our favorite “House of Cards” episode on Netflix or read Yelp reviews about a new restaurant.

When we can’t access the information we’re looking for on the internet within seconds, we are not happy.

This is where you come into the picture.

BLT wants you to identify the software (and hardware) bugs that delay downloads, freeze screens, create payloads that deliver malware to websites and generate other issues.

What’s in it for you?
Points.
Money if you join a BLT Sponsored Bug Hunt.
Jackpot money listed on the Leaderboard.
Money if someone tips you for finding a bug through the tip button.
Experience to add to your résumé or portfolio.
How it Works
Testers
Create a User Account to log into BLT.
Describe the software or hardware bug you found.
Attach a screenshot of the bug.
Submit the information.
Win money through company-sponsored Bug Bounties, tips or the Grand Prize/Jackpot.We may also have "heists" where each bug is worth a specific amount based on what the company sets.
If you participate in BLT’s sponsored Bug Bounties, you could win prize money known as tips.
Organizations
We want everyone to love your website.
You want to keep your customers happy by giving them a consistent bug-free user experience. BLT offers monthly Bug Bounties through 4 different subscription plans to help you achieve this.

BLT is 100% free to use, Open Source and a non-commercial, not for profit initiative.
43 changes: 43 additions & 0 deletions website/documents/BltBLTV.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
### Detailed Description of the "BLTV" UI Component and the url path is "https://blt.owasp.org/bltv/" for the OWASP Bug Logging Tool (BLT) Application

#### 1. Component Overview
The "BLTV" UI component in the OWASP Bug Logging Tool (BLT) application is designed to provide users with access to video tutorials and informational content related to bug reporting, tool setup, and integration with other platforms. The primary functionalities include streaming video content, navigating through different video tutorials, and accessing detailed guides on using the BLT application and related tools.

#### 2. User Interaction
Users interact with the BLTV component through the following steps:
1. **Browsing Videos**: Users can browse through the list of available video tutorials displayed on the page.
2. **Playing Videos**: By clicking on a video thumbnail or title, users can play the video directly on the page.
3. **Navigating Videos**: Users can navigate between different video tutorials using the navigation options provided on the page.
4. **Viewing Details**: Users can view additional details about each video tutorial, such as the title, description, and the name of the presenter.

#### 3. Key Elements
- **Video Thumbnails**: Each video is represented by a thumbnail image, which provides a visual preview of the content.
- **Video Titles**: The title of each video is displayed below the thumbnail, providing a brief description of the content.
- **Play Button**: A prominent play button on each thumbnail allows users to start the video.
- **Navigation Sidebar**: The left sidebar contains navigation links to other sections of the BLT application, such as Issues, Companies, Scoreboard, Users, Teams, Bug Bounties, etc.
- **Search Bar**: Positioned at the top of the page, the search bar allows users to find specific video tutorials by entering relevant keywords.

#### 4. Visual Design
- **Layout**: The layout is grid-based, with video thumbnails arranged in rows for easy browsing. The navigation sidebar is positioned on the left, while the main content area displays the video thumbnails and titles.
- **Color Scheme**: The design uses a consistent color scheme with red, white, and grey tones, matching the overall BLT branding. Red is used for the play button and headings to draw attention.
- **Typography**: Modern, readable fonts are used for video titles, navigation links, and other text elements, ensuring clarity and ease of reading.
- **Visual Cues**: Interactive elements such as video thumbnails and play buttons have hover effects to indicate interactivity.

#### 5. Accessibility Features
- **Keyboard Navigation**: All interactive elements can be accessed and operated via keyboard shortcuts, allowing users with mobility impairments to navigate and use the video tutorials.
- **Screen Reader Compatibility**: The video thumbnails, titles, and play buttons are labeled clearly to be compatible with screen readers, aiding visually impaired users in understanding and interacting with the component.
- **High Contrast**: Text and interactive elements have high contrast against the background, making it easier for users with visual impairments to read the content.
- **Descriptive Labels**: All interactive elements have clear and descriptive labels to ensure users understand their purpose and functionality.

#### 6. Error Handling
The BLTV component includes mechanisms to handle errors and provide feedback to users:
- **Error Messages**: If an error occurs while loading the video tutorials or playing a video, clear and concise error messages are displayed to inform the user and provide steps to resolve the issue.
- **Fallback Content**: If a video fails to load, the page provides fallback messages or placeholders, ensuring that the user experience is not significantly disrupted.
- **Input Validation**: Ensures that users enter valid search terms before submitting a query in the search bar.

#### 7. Performance
The component is designed with several features to enhance performance and user experience:
- **Optimized Loading**: The page is optimized to load quickly, allowing users to browse and play videos without delay.
- **Responsive Design**: The layout is fully responsive, adapting to different screen sizes and devices to ensure a consistent and accessible experience across desktops, tablets, and mobile devices.
- **Lazy Loading**: Video thumbnails and other media elements are loaded as needed, reducing initial load times and improving overall performance.
- **Efficient Data Retrieval**: Uses efficient data retrieval techniques to fetch and display video tutorials quickly, minimizing wait times and enhancing user satisfaction.
44 changes: 44 additions & 0 deletions website/documents/BltChangePassword.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
### Detailed Description of the "Change Password" UI Component

#### 1. **Component Overview**
The "Change Password" UI component is designed to allow users to securely update their account passwords. This functionality is crucial for maintaining account security and ensuring users can manage their credentials. The primary functionalities include entering the current password, setting a new password, and confirming the new password.

#### 2. **User Interaction**
Users interact with this component by following these steps:
1. **Accessing the Page**: Users navigate to the "Change Password" page via a menu option, typically found under account settings or a similar section.
2. **Entering Current Password**: Users input their current password in the first input field.
3. **Setting New Password**: Users enter their desired new password in the second input field.
4. **Confirming New Password**: Users re-enter the new password in the third input field to confirm it.
5. **Submitting the Form**: Users click the "Change Password" button to submit the form. If all inputs are valid, the password is updated.

#### 3. **Key Elements**
- **Current Password Field**: An input field labeled "Old Password" where users enter their existing password.
- **New Password Field**: An input field labeled "New Password" for users to enter their new desired password.
- **Confirm Password Field**: An input field labeled "Confirm Password" to re-enter the new password for confirmation.
- **Change Password Button**: A green button labeled "Change Password" which users click to submit the form and update their password.
- **Visual Icons**: Lock icons adjacent to each password field, visually indicating security.

#### 4. **Visual Design**
The layout is simple and focused, ensuring users can easily update their passwords without distraction. Key design aspects include:
- **Color Scheme**: Neutral background with contrasting elements to highlight the form fields and buttons. The button is in green to signify a positive action.
- **Typography**: Clear, readable fonts are used. Labels are concise, and input fields are large enough to accommodate various screen sizes.
- **Visual Cues**: Lock icons next to the password fields indicate security. The green button stands out, guiding users to the submission action.

#### 5. **Accessibility Features**
- **Labels and Icons**: Each input field is clearly labeled, and icons are used to provide additional visual context.
- **Keyboard Navigation**: The form is fully navigable using the keyboard, allowing users to tab through fields and submit the form without a mouse.
- **Color Contrast**: The color scheme is designed to provide sufficient contrast, making it accessible to users with visual impairments.
- **Screen Reader Compatibility**: Labels and input fields are compatible with screen readers, ensuring visually impaired users can update their passwords.

#### 6. **Error Handling**
- **Validation**: Before submission, the form checks that all fields are filled out and that the new passwords match.
- **Error Messages**: If validation fails, clear error messages are displayed next to the relevant fields, informing users of what needs to be corrected (e.g., "Passwords do not match", "Current password is incorrect").
- **Feedback**: Upon successful password change, a confirmation message is displayed. If an error occurs during the process, an appropriate error message is shown, prompting the user to try again.

#### 7. **Performance**
- **Real-Time Validation**: As users input data, real-time validation ensures that errors are caught early, providing immediate feedback.
- **Efficient Loading**: The form and its elements are designed to load quickly, even on slower connections, enhancing the user experience.
- **Minimal Distractions**: The focused design ensures users can complete the task quickly without unnecessary distractions or elements.

#### URL Mention
This detailed information pertains to the "Change Password" page of the BugLog tool, accessible at: [https://blt.owasp.org/accounts/password/change/](https://blt.owasp.org/accounts/password/change/).
Loading
Loading