Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #225 from DrAlzahraniProjects/final-fixes
Browse files Browse the repository at this point in the history
Final fixes
  • Loading branch information
smrchanda877 authored Dec 7, 2024
2 parents 983489d + d5ba78f commit e1d8a78
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# IT Support Chatbot
# ITS Support Chatbot

This repository contains the IT Support Chatbot project developed by **CSUSB Fall 2024 CSE6550 Team 1**. The chatbot is designed to assist users with IT-related queries and support.
This repository contains the ITS Support Chatbot project developed by **CSUSB Fall 2024 CSE6550 Team 1**. The chatbot is designed to assist users with IT-related queries and support.

## Table of Contents

Expand Down Expand Up @@ -140,7 +140,7 @@ The `setup.py` script automates Docker process. If this does not work view the *
## Accessing the Application

### Accessing locally through Docker
Once the Docker container is running, you can access the IT Support Chatbot through your browser at:
Once the Docker container is running, you can access the ITS Support Chatbot through your browser at:

[http://localhost:5001/team1](http://localhost:5001/team1) or [http://127.0.0.1:5001/team1](http://127.0.0.1:5001/team1)

Expand Down
15 changes: 9 additions & 6 deletions backend/RAG.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def is_filtered_query(query):
r"\b(hi|hello|hey|hiya|howdy|greetings|yo)\b", # Common greetings
r"who (are|r) you\??", # Identity questions
r"what('?s| is) your name\??", # Name questions
r"what('?s| is) your role\??", # Role questions
r"(hi|hello|hey|yo),? (who are you|what('?s| is) your name)\??", # Greeting + identity
r"(hi|hello|hey|yo),? (what do you do|what can you do)\??", # Greeting + capability
r"good (morning|afternoon|evening),? (who are you|what('?s| is) your role)\??", # Polite intros
Expand Down Expand Up @@ -104,8 +105,8 @@ def query_rag(query):
# Check if the query is a filtered query and it is the first or second message
if is_filtered_query(query):
if CORPUS_SOURCE == 'https://www.csusb.edu/its':
return f"Hi there! I am an ITS Support Chatbot {CORPUS_SOURCE}. I can help you with your ITS related queries. How can I assist you today?", "Unknown"
return f"Hi there! I'm an AI assistant powered by {CORPUS_SOURCE}. I'm here to help with any questions you might have. How can I assist you today?", "Unknown"
return f"Hi there! I am an <a href={CORPUS_SOURCE}>ITS Support Chatbot</a>. I can help you with your ITS related queries. How can I assist you today?", "Unknown"
return f"Hi there! I'm an AI assistant powered by <a href={CORPUS_SOURCE}>link</a>. I'm here to help with any questions you might have. How can I assist you today?", "Unknown"

# Define the model
#chat_model = ChatMistralAI(model='open-mistral-7b', temperature = 0.2)
Expand All @@ -126,7 +127,9 @@ def query_rag(query):

if not retrieved_documents:
print("No Relevant Documents Retrieved, so sending default response")
return f"I don't have enough information to answer this question. I'm an AI assistant powered by <a href={CORPUS_SOURCE}>CSUSB ITS Knowledge Base</a>. \nI can only answer questions based on this information. Please ask another question.", "Unknown"
if CORPUS_SOURCE == 'https://www.csusb.edu/its':
return f"I don't have enough information to answer this question. I'm an AI assistant powered by <a href={CORPUS_SOURCE}>CSUSB ITS Knowledge Base</a>. \nI can only answer questions based on this information. Please ask another question.", "Unknown"
return f"I don't have enough information to answer this question. I'm an AI assistant powered by <a href={CORPUS_SOURCE}>link</a>. \nI can only answer questions based on this information. Please ask another question.", "Unknown"

# Extract metadata from the most relevant document
most_relevant_document = retrieved_documents[0]
Expand All @@ -142,10 +145,10 @@ def query_rag(query):
})

# Add the source to the response if available
# if isinstance(source, str) and source != "Unknown":
# response += f"\n\nSource: [{title}]({source})"
if response.lower().strip() == "the context does not contain enough information to answer this question.":
return f"I don't have enough information to answer this question. I'm an AI assistant powered by <a href={CORPUS_SOURCE}>CSUSB ITS Knowledge Base</a>. \nI can only answer questions based on this information. Please ask another question.", "Unknown"
if CORPUS_SOURCE == 'https://www.csusb.edu/its':
return f"I don't have enough information to answer this question. I'm an AI assistant powered by <a href={CORPUS_SOURCE}>CSUSB ITS Knowledge Base</a>. \nI can only answer questions based on this information. Please ask another question.", "Unknown"
return f"I don't have enough information to answer this question. I'm an AI assistant powered by <a href={CORPUS_SOURCE}>link</a>. \nI can only answer questions based on this information. Please ask another question.", "Unknown"
formatted_response = format_source(response, source, title)
print("Response Generated", formatted_response)
# print("Response Generated")
Expand Down

0 comments on commit e1d8a78

Please sign in to comment.