diff --git a/app/main.py b/app/main.py index 30b8d1c..8d0b38e 100644 --- a/app/main.py +++ b/app/main.py @@ -2,7 +2,7 @@ import streamlit as st import time from src import FileProcessor, Summarizer -from config.settings import settings +from config.settings import settings, quality, length def main(): if 'tests_run' not in st.session_state: @@ -15,6 +15,25 @@ def main(): st.session_state.tests_run = True st.title("Kaka - AI powered document summary") + sumLenght = st.radio( + "Summary length", + ["long", "mid", "short"], + captions = [ + "approximately 2/3 of the original", + "approximately 1/2 of the original", + "approximately 1/3 of the original" + ], + ) + sumQuality = st.radio( + "Summary length", + ["excellent", "good", "crapy"], + captions = [ + "high coherence, accurate, well-structured", + "average quality, some simplifications allowed", + "intentionally lower quality, possibly missing key points or slightly incoherent" + ], + ) + fileProcessor = FileProcessor() fileProcessor.upload_file() @@ -31,7 +50,7 @@ def main(): if st.session_state.submitted: summarizzler = Summarizer(settings) - result = summarizzler.summarize(fileProcessor.get_content()) + result = summarizzler.summarize(fileProcessor.get_content(), length[sumLenght], quality[sumQuality]) with st.spinner("Summarizing your doc...."): time.sleep(1) st.success("Your summary is ready:") diff --git a/app/src/summarizer.py b/app/src/summarizer.py index a827912..ab68e24 100644 --- a/app/src/summarizer.py +++ b/app/src/summarizer.py @@ -11,14 +11,18 @@ def __init__(self, config: Settings): api_key=self.api_key, ) - def summarize(self, text: str) -> str: + def summarize(self, text: str, sumLen: str, sumQuality: str) -> str: try: completion = self.client.chat.completions.create( model = self.model, messages=[ { "role": "user", - "content": f"Summarize this text:\n\n{text}" + "content": f""" + Summarize the following text in the same language. + Length of the summary:{sumLen} + Quality of the summary:{sumQuality} + Text to summarize:\n\n{text}""" } ] ) diff --git a/config/settings.py b/config/settings.py index 2ca3aa8..ac61515 100644 --- a/config/settings.py +++ b/config/settings.py @@ -9,4 +9,16 @@ def __init__(self): self.BASE_URL = os.getenv("BASE_URL", "") self.MODEL = os.getenv("MODEL", "") -settings = Settings() \ No newline at end of file +settings = Settings() + +quality = { + 'excellent':'approximately 2/3 of the original', + 'good':'approximately 1/2 of the original', + 'crapy':'approximately 1/3 of the original', +} + +length = { + 'long':'high coherence, accurate, well-structured', + 'mid':'average quality, some simplifications allowed', + 'short':'intentionally lower quality, possibly missing key points or slightly incoherent', +} \ No newline at end of file