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

Merge Iteration 5 to main #18

Merged
merged 37 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
23f0948
fix: quiz parsing error
h9kwon Nov 23, 2023
93b99f6
feat: orientation fix, disable AI buttons to prevent unexpected summa…
minjoojeon Nov 23, 2023
7beee52
fix: empty message error, book id error, streaming annotation, preven…
h9kwon Nov 23, 2023
1abb87c
feat: pull to refresh book list
minjoojeon Nov 23, 2023
b14c39c
feat: add intermediate summary progress tracking
muffinsnip Nov 25, 2023
7228ca3
feat: add book delete request; fix: create new connection to database…
chaemin2001 Nov 25, 2023
f31f65b
refactor: add empty space on booklist bottom
minjoojeon Nov 25, 2023
8918e34
feat: add delete book in UI
h9kwon Nov 25, 2023
5146fd7
fix: file type error, summary concatenated error, button unclickable …
minjoojeon Nov 25, 2023
7eca494
fix: bookList not deleted when sign out
h9kwon Nov 27, 2023
88af884
feat: add delete book alert
minjoojeon Nov 27, 2023
63c0fc7
feat: save progress, basic ai status; refactor: unnecessary UI, chang…
h9kwon Nov 27, 2023
a4678dd
feat: handle no internet connection, refactor: delete unnecessary UI
minjoojeon Nov 27, 2023
9da73bd
fix: delayed progress upload, fix summary / quiz not stopping when ne…
h9kwon Nov 28, 2023
b5c4b9a
refactor: move network check codes to NetworkStatusRepository, add ch…
minjoojeon Nov 28, 2023
0a12d88
feat: default book cover image and book card, resize cover image, lim…
h9kwon Nov 28, 2023
bc28a0d
Refactor: delete unnecessary parameters, Fix: POST to GET
minjoojeon Nov 28, 2023
d7c9e68
feat: preserve email input when go back
h9kwon Nov 30, 2023
1f8075f
feat: add user info to settings; fix: delayed viewer style change for…
minjoojeon Nov 30, 2023
2951227
feat: save content and image as file
h9kwon Nov 30, 2023
ccfb085
feat: Viewer immersive mode, improve overall animation
minjoojeon Nov 30, 2023
31b51ea
fix: quiz crash on error; feat: add change password to user data layer
h9kwon Nov 30, 2023
7b9adcd
feat: show summary preprocessing progress when overlay displayed; fix…
minjoojeon Nov 30, 2023
88ece09
fix: remove black corner of default book cover, correctly apply font …
h9kwon Dec 2, 2023
afed96c
fix: match AI progress to UI design, unify page index / percent calcu…
minjoojeon Dec 2, 2023
4ed8897
fix: unintended new line in summary generating
h9kwon Dec 2, 2023
3889d51
feat: handle cases when summary and quiz failed during generation
minjoojeon Dec 2, 2023
c4faba4
test: BookRepository Unit tests
h9kwon Dec 2, 2023
6e641ea
Test: add settingsView test, fix current tests to match implementation
Scripter36 Dec 3, 2023
e650066
Merge branch 'main' into test/iteration5_integration
Scripter36 Dec 3, 2023
58b4235
refactor: apply proxy pattern to summary and quiz generation logic
muffinsnip Dec 3, 2023
938f329
feat: add delete user, change password endpoints, book current infere…
chaemin2001 Dec 3, 2023
043e805
test: add split list, num_inference tests
muffinsnip Dec 3, 2023
46c5b69
fix: fix typo in quiz request function call
muffinsnip Dec 3, 2023
575defe
Merge pull request #19 from snuhcs-course/feat/backend/summary_progress
Scripter36 Dec 5, 2023
2863762
fix: run ktlint on codes
Scripter36 Dec 5, 2023
d6160f3
fix: delete user function typo
muffinsnip Dec 5, 2023
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
9 changes: 9 additions & 0 deletions .idea/swpp-2023-project-team-7.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

192 changes: 192 additions & 0 deletions backend/llama/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@

GPT_SYSTEM_QUIZ_PROMPT_FROM_INTERMEDIATE = '''
You will be presented with a series of bullet points summarizing key elements
of a story. Your task is to generate questions that are crucial for understanding
the overall plot and essential aspects of the story. Generate a minimum of 2
and a maximum of 10 questions, ensuring that the questions you choose to create
are deeply rooted in the comprehension and analysis of the story's plot,
characters, and themes.

Read the bullet points carefully:
Take time to understand the main ideas, themes, and plot developments
highlighted in the bullet points.

Generate Questions:
First, write number of questions you want to generate.
Then, create questions that dig into the essential aspects necessary for
understanding the story's overall plot. The questions should encourage
exploration of the story's key elements such as character motivations,
plot development, conflicts, and resolutions. Avoid asking overly detailed
questions that do not contribute significantly to the understanding of the
story’s main plot or themes.

Number of Questions:
Generate at least 2 questions that target the most critical aspects of the story.
You may generate up to 10 questions if they are all deemed essential for a
deeper understanding of the story.

Question Format:
Ensure that the questions are open-ended to promote deeper thinking and analysis.
Format the questions clearly and concisely. Be sure to provide the answers as well.

Format:
Number of Questions: <number of questions>
1Q: <question 1>
1A: <answer 1>
2Q: <question 2>
2A: <answer 2>
'''

GPT_SYSTEM_QUIZ_PROMPT_FROM_RAW = '''
You will be presented with an excerpt from a story. Your task is to generate
questions that are crucial for understanding the overall plot and essential
aspects of the story. Generate a minimum of 2 and a maximum of 10 questions,
ensuring that the questions you choose to create are deeply rooted in the
comprehension and analysis of the story's plot, characters, and themes.

Read the bullet points carefully:
Take time to understand the main ideas, themes, and plot developments
highlighted in the bullet points.

Generate Questions:
First, write the number of questions you want to generate.
Then, create questions that dig into the essential aspects necessary for
understanding the story's overall plot. The questions should encourage
exploration of the story's key elements such as character motivations,
plot development, conflicts, and resolutions. Avoid asking overly detailed
questions that do not contribute significantly to the understanding of the
story’s main plot or themes.

Number of Questions:
Generate at least 2 questions that target the most critical aspects of the story.
You may generate up to 10 questions if they are all deemed essential for a
deeper understanding of the story.

Question Format:
Ensure that the questions are open-ended to promote deeper thinking and analysis.
Format the questions clearly and concisely. Be sure to provide the answers as well.

Format:
Number of Questions: <number of questions>
1Q: <question 1>
1A: <answer 1>
2Q: <question 2>
2A: <answer 2>
'''

GPT_SYSTEM_SUMMARY_PROMPT_FROM_INTERMEDIATE = '''
Prompt Instructions:
You will be provided with several bullet points that outline key aspects
of a story. Your task is to synthesize these points into a coherent and
concise summary that captures the most crucial elements necessary for
understanding the story’s overall plot. Your summary should make it easy
for a reader to grasp the main ideas, themes, and developments within the
story.

Read the bullet points carefully:
Carefully analyze each bullet point to understand the fundamental
components of the story, such as the main events, character motivations,
conflicts, and resolutions.

Crafting the Summary:
Your summary should be well-organized, flowing seamlessly from one point to the
next to create a cohesive understanding of the story. Focus on conveying the
key elements that are central to the story’s plot and overall message.
Avoid including overly detailed or minor points that do not significantly
contribute to understanding the core plot.

Length and Detail:
Aim for a summary that is concise yet comprehensive enough to convey the
essential plot points. Ensure that the summary is not overly lengthy or
cluttered with less pertinent details.

Final Touches:
Review your summary to ensure that it accurately represents the main ideas
and themes presented in the bullet points. Ensure that the language used is
clear and easily understandable.
'''

GPT_SYSTEM_SUMMARY_PROMPT_FROM_RAW = '''
Prompt Instructions:
You will be provided with a part of a larger text.
Your task is to synthesize the text into a coherent and concise summary
that captures the most crucial elements necessary for understanding the text’s
overall message. Your summary should make it easy for a reader to grasp the
main ideas, themes, and developments within the text.

Crafting the Summary:
Your summary should be well-organized, flowing seamlessly from one point
to the next to create a cohesive understanding of the story.
Focus on conveying the key elements that are central to the story’s plot
and overall message. Avoid including overly detailed or minor points that do
not significantly contribute to understanding the core plot.

Length and Detail:
Aim for a summary that is concise yet comprehensive enough to convey the
essential plot points. Ensure that the summary is not overly lengthy or
cluttered with less pertinent details.

Final Touches:
Review your summary to ensure that it accurately represents the main ideas
and themes presented in the bullet points. Ensure that the language used is
clear and easily understandable.
'''

GPT_TEXT_TO_INTERMEDIATE_SYSTEM_PROMPT = '''
"Hello, ChatGPT. I have a passage from a novel that I need help with.
It's quite long and detailed, and I'm looking to create a summary of the larger text it's a part of.
Can you assist me by identifying and extracting the most crucial bullet points from this passage?
These points should capture key events, character developments, themes, or any significant literary elements that are essential to the overall narrative and its context in the larger story.
Only provide bulletpoints, and do not say anything else. If there isn't enough information
to extract bullet points, just say "No bullet points".
Thank you!"
'''

GPT_INTERMEDIATE_TO_INTERMEDAITE_SYSTEM_SUMMARY_PROMPT = '''
You will be provided with several bullet points that outline key aspects of a story. Your
task is to generate a new set of bullet points that capture the most crucial elements
necessary for understanding the story’s overall plot. Note that these bullet points will
later be used to generate a general, coherent summary of the story. Your bullet points
should contain the most essential elements of the story, such as the main events, character
motivations, conflicts, and resolutions.

Read the bullet points carefully:
Carefully analyze each bullet point to understand the fundamental components of the story,
such as the main events, character motivations, conflicts, and resolutions.

Reply with only the bullet points.
'''

GPT_INTERMEDAITE_TO_FINAL_SYSTEM_SUMMARY_PROMPT = '''
You will be provided with several bullet points that outline key aspects of a story. Your task is to synthesize these points into a coherent and concise summary that captures the most crucial elements necessary for understanding the story’s overall plot. Your summary should make it easy for a reader to grasp the main ideas, themes, and developments within the story.
Read the bullet points carefully: Carefully analyze each bullet point to understand the fundamental components of the story, such as the main events, character motivations, conflicts, and resolutions.

Your summary should be well-organized, flowing seamlessly from one point to the next to create a cohesive understanding of the story.
Focus on conveying the key elements that are central to the story’s plot and overall message.
Avoid including overly detailed or minor points that do not significantly contribute to understanding the core plot.

Aim for a summary that is concise yet comprehensive enough to convey the essential plot points.
Ensure that the summary is not overly lengthy or cluttered with less pertinent details.

Review your summary to ensure that it accurately represents the main ideas and themes presented in the bullet points.
Ensure that the language used is clear and easily understandable.
'''

PROMPT_TEMPLATE_INTERMEDIATE_FRONT = f'''[INST]<<SYS>>
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible,
while being safe. You will be given a short passage from a larger, more complex novel. Your job
is to extract the essential facts from the given passage to later be used for providing a
comprehensive summary to let users understand the entire plot of the larger, complex novel.
Therefore, when given a passage, reply only with the bullet points that you think are the most
important points. Make sure to reply with only the bullet points.
'''
PROMPT_TEMPLATE_INTERMEDIATE_BACK= '''<</SYS>>[/INST]'''


PROMPT_TEMPLATE_FINAL_FRONT = f'''[INST]<<SYS>>
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible,
while being safe. You will be given a list of bullet points that reflect the key facts of an
entire, complex novel. With these bullet points, provide an insightful summary such that the
user can get a good idea about the plot of the entire story.
'''
PROMPT_TEMPLATE_FINAL_BACK = '''<</SYS>>[/INST]'''
Loading
Loading