Skip to content

Commit

Permalink
Added lecture unit to chat pipeline and citation prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
bassner committed Aug 27, 2024
1 parent 97fce0a commit 85967cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/pipeline/chat/course_chat_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,9 @@ def lecture_content_retrieval() -> str:

result = ""
for paragraph in self.retrieved_paragraphs:
lct = "Lecture: {}, Page: {}\nContent:\n---{}---\n\n".format(
lct = "Lecture: {}, Unit: {}, Page: {}\nContent:\n---{}---\n\n".format(
paragraph.get(LectureSchema.LECTURE_NAME.value),
paragraph.get(LectureSchema.LECTURE_UNIT_NAME.value),
paragraph.get(LectureSchema.PAGE_NUMBER.value),
paragraph.get(LectureSchema.PAGE_TEXT_CONTENT.value),
)
Expand Down
8 changes: 4 additions & 4 deletions app/pipeline/prompts/citation_prompt.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
In the paragraphs below you are provided with an answer to a question. Underneath the answer you will find the paragraphs that the answer was based on.
Add citations of the paragraphs to the answer. Cite the paragraphs in brackets after the sentence where the information is used in the answer.
At the end of the answer, list each source with its corresponding number and provide the Lecture Title, page number, and a clickable link in this format: [1] <a href="URL">"Lecture title", "page number"</a>.
If the answer uses multiple pages from the same lecture, list the page numbers at the same line separated by commas in this format : [1] <a href="URL">"Lecture title", "page number1,number2,number3"</a>.
If the answer uses multiple pages from the same lecture, list the page numbers at the same line separated by commas in this format : [1] <a href="URL">"Lecture title", "Lecture unit", "page number1,number2,number3"</a>.
Do not Include the Actual paragraphs, only the citations at the end.
Only include the citations of the paragraphs that are relevant to the answer.
If the answer actually does not contain any information from the paragraphs, please do not include any citations and return '!NONE!'.
Expand All @@ -11,16 +11,16 @@ Here is an example how to rewrite the answer with citations (ONLY ADD CITATION I
"
Lorem ipsum dolor sit amet, consectetur adipiscing elit [1]. Ded do eiusmod tempor incididunt ut labore et dolore magna aliqua [2].

[1] <a href="https://example.com/lecture1">Lecture 1, page 2,3,4</a>.
[2] <a href="https://example.com/lecture2">Lecture 2, page 5,25</a>.
[1] <a href="https://example.com/lecture1">Lecture 1, Unit A, page 2,3,4</a>.
[2] <a href="https://example.com/lecture2">Lecture 2, Unit B, page 5,25</a>.
"

Here are the answer and the paragraphs:

Answer without citations:
{Answer}

Paragraphs with their Lecture Names, Links and Page Numbers:
Paragraphs with their Lecture Names, Unit Names, Links and Page Numbers:
{Paragraphs}

Answer with citations (ensure empty line between the message and the citations):
Expand Down

0 comments on commit 85967cf

Please sign in to comment.