Skip to content

Commit

Permalink
(feat)
Browse files Browse the repository at this point in the history
- added the function to now submit feedback back to mongoDB
- corrected the sys path to now include common as a package, workaround , kind of like a pseudopackage

Signed-off-by: Kannav02 <[email protected]>
  • Loading branch information
Kannav02 committed Nov 26, 2024
1 parent 98d973c commit eb6f81a
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions frontend/utils/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
from dotenv import load_dotenv
import os
from typing import Optional, Any
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
from common.mongoClient import submit_feedback

load_dotenv()

Expand Down Expand Up @@ -57,6 +60,43 @@ def format_context(context: list[str]) -> str:
return "\n".join(context)


def submit_feedback_to_mongoDB(
question: str,
answer: str,
sources: list[str],
context: list[str],
issue: str,
version: str,
) -> None:
"""
Submit feedback to a specific MongoDB database.
Args:
- question (str): The question for which feedback is being submitted.
- answer (str): The generated answer to the question.
- sources (list[str]): Source data used for the answer.
- context (list[str]): Additional context from the RAG.
- issue (str): Details about the issue.
- version (str): Version information.
Returns:
- None
"""
try:
result = submit_feedback(
question=question,
answer=answer,
sources=sources,
context=context,
issue=issue,
version=version,
)
if not result:
st.sidebar.error("Failed to submit feedback to MongoDB")
except Exception as e:
st.sidebar.error(f"Error submitting feedback to MongoDB: {e}")


def submit_feedback_to_google_sheet(
question: str,
answer: str,
Expand Down Expand Up @@ -191,6 +231,14 @@ def show_feedback_form(
issue=feedback,
version=os.getenv("RAG_VERSION", get_git_commit_hash()),
)
submit_feedback_to_mongoDB(
question=selected_question,
answer=gen_ans,
sources=sources, # Now passing as list
context=context, # Now passing as list
issue=feedback,
version=os.getenv("RAG_VERSION", get_git_commit_hash()),
)

st.session_state.submitted = True

Expand Down

0 comments on commit eb6f81a

Please sign in to comment.