Skip to content

Commit

Permalink
Bugfix/index and parenthesis bug fixes (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
yassinsws authored Jul 11, 2024
1 parent 80c183f commit ace007c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion app/pipeline/chat/exercise_chat_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ def _add_relevant_chunks_to_prompt(self, retrieved_lecture_chunks: List[dict]):
)
txt += lct

self.prompt += SystemMessagePromptTemplate.from_template(txt)
self.prompt += SystemMessagePromptTemplate.from_template(
txt.replace("{", "{{").replace("}", "}}")
)

def should_execute_lecture_pipeline(self, course_id: int) -> bool:
"""
Expand Down
2 changes: 1 addition & 1 deletion app/pipeline/prompts/reranker_prompt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Respond with the numbers of the paragraphs you should consult to answer the ques
The relevance score is a number from 1 to 10 based on how relevant the paragraphs are to answer the question.
Do not include any paragraphs that are not relevant to the question.
Without any comment, return the result in the following JSON format, it is important to avoid giving
unnecessary information, only the number of the paragraph if it's really necessary for answering the student's question
unnecessary information, only the number of the paragraph if it's necessary for answering the student's question
otherwise leave the array empty.
{{"selected_paragraphs": [<number1>, <number2>, ...]}}

Expand Down
5 changes: 3 additions & 2 deletions app/retrieval/lecture_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ def __call__(
selected_chunks_index = self.reranker_pipeline(
paragraphs=merged_chunks, query=student_query, chat_history=chat_history
)
return [merged_chunks[int(i)] for i in selected_chunks_index]
if selected_chunks_index:
return [merged_chunks[int(i)] for i in selected_chunks_index]
return []

@traceable(name="Basic Lecture Retrieval")
Expand Down Expand Up @@ -467,7 +468,7 @@ def run_parallel_rewrite_tasks(
response_future = executor.submit(
self.search_in_db,
query=rewritten_query,
hybrid_factor=0.7,
hybrid_factor=0.9,
result_limit=result_limit,
course_id=course_id,
base_url=base_url,
Expand Down
4 changes: 2 additions & 2 deletions app/web/status/status_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def error(self, message: str, exception=None):
"""
self.stage.state = StageStateEnum.ERROR
self.stage.message = message
self.stage.result = None
self.status.result = None
self.stage.suggestions = None
# Set all subsequent stages to SKIPPED if an error occurs
rest_of_index = (
Expand Down Expand Up @@ -157,7 +157,7 @@ def skip(self, message: Optional[str] = None, start_next_stage: bool = True):
"""
self.stage.state = StageStateEnum.SKIPPED
self.stage.message = message
self.stage.result = None
self.status.result = None
self.stage.suggestions = None
next_stage = self.get_next_stage()
if next_stage is not None:
Expand Down

0 comments on commit ace007c

Please sign in to comment.