diff --git a/backend/HIndices.py b/backend/HIndices.py index 4c97b9e..6419a1f 100644 --- a/backend/HIndices.py +++ b/backend/HIndices.py @@ -14,7 +14,7 @@ import numpy as np from sqlalchemy.orm import Session from fastapi import Depends, WebSocket -from langchain_core.prompts import PromptTemplate +from prompts import report_prompt import os from dotenv import load_dotenv @@ -93,37 +93,6 @@ class HIndices: # self.detailed_store_size = len(self.detailed_store.get()['documents']) def summarize_file_doc(self, page_no, doc, search_space): - - report_template = """ - You are an eagle-eyed researcher, skilled at summarizing lengthy documents with precision and clarity. - - I would like you to assist me in summarizing the following text. Please create a comprehensive summary that captures the main ideas, key details, and essential arguments presented in the text. Your summary should adhere to the following guidelines: - - Length and Depth: Provide a detailed summary that is approximately [insert desired word count or length, e.g., 300-500 words]. Ensure that it is thorough enough to convey the core message without losing important nuances. - - Structure: Organize the summary logically. Use clear headings and subheadings to delineate different sections or themes within the text. This will help in understanding the flow of ideas. - - Key Points: Highlight the main arguments and supporting details. Include any relevant examples or data that reinforce the key points made in the original text. - - Clarity and Conciseness: While the summary should be detailed, it should also be clear and concise. Avoid unnecessary jargon or overly complex language to ensure that the summary is accessible to a broad audience. - - Objective Tone: Maintain an objective and neutral tone throughout the summary. Avoid personal opinions or interpretations; instead, focus on accurately reflecting the author's intended message. - - Conclusion: End the summary with a brief conclusion that encapsulates the overall significance of the text and its implications. - - Please summarize the following text: - {document} - - - ================== - Detailed Summary: - """ - - - report_prompt = PromptTemplate( - input_variables=["document"], - template=report_template - ) # Create an LLMChain for sub-query decomposition report_chain = report_prompt | self.llm @@ -167,35 +136,6 @@ class HIndices: ) def summarize_webpage_doc(self, page_no, doc, search_space): - report_template = """ - You are an eagle-eyed researcher, skilled at summarizing lengthy documents with precision and clarity. - I would like you to assist me in summarizing the following text. Please create a comprehensive summary that captures the main ideas, key details, and essential arguments presented in the text. Your summary should adhere to the following guidelines: - - Length and Depth: Provide a detailed summary that is approximately [insert desired word count or length, e.g., 300-500 words]. Ensure that it is thorough enough to convey the core message without losing important nuances. - - Structure: Organize the summary logically. Use clear headings and subheadings to delineate different sections or themes within the text. This will help in understanding the flow of ideas. - - Key Points: Highlight the main arguments and supporting details. Include any relevant examples or data that reinforce the key points made in the original text. - - Clarity and Conciseness: While the summary should be detailed, it should also be clear and concise. Avoid unnecessary jargon or overly complex language to ensure that the summary is accessible to a broad audience. - - Objective Tone: Maintain an objective and neutral tone throughout the summary. Avoid personal opinions or interpretations; instead, focus on accurately reflecting the author's intended message. - - Conclusion: End the summary with a brief conclusion that encapsulates the overall significance of the text and its implications. - - Please summarize the following text: - {document} - - - ================== - Detailed Summary: - """ - - - report_prompt = PromptTemplate( - input_variables=["document"], - template=report_template - ) # Create an LLMChain for sub-query decomposition report_chain = report_prompt | self.llm diff --git a/backend/prompts.py b/backend/prompts.py index bc4099a..65c49ca 100644 --- a/backend/prompts.py +++ b/backend/prompts.py @@ -1,6 +1,36 @@ # Need to move new prompts to here will move after testing some more -# from langchain_core.prompts.prompt import PromptTemplate +from langchain_core.prompts.prompt import PromptTemplate from datetime import datetime, timezone -DATE_TODAY = "Today's date is " + datetime.now(timezone.utc).astimezone().isoformat() + '\n' \ No newline at end of file +DATE_TODAY = "Today's date is " + datetime.now(timezone.utc).astimezone().isoformat() + '\n' + + +report_template = """ +You are an eagle-eyed researcher, skilled at summarizing lengthy documents with precision and clarity. +I would like you to assist me in summarizing the following text. Please create a comprehensive summary that captures the main ideas, key details, and essential arguments presented in the text. Your summary should adhere to the following guidelines: + +Length and Depth: Provide a detailed summary that is approximately [insert desired word count or length, e.g., 300-500 words]. Ensure that it is thorough enough to convey the core message without losing important nuances. + +Structure: Organize the summary logically. Use clear headings and subheadings to delineate different sections or themes within the text. This will help in understanding the flow of ideas. + +Key Points: Highlight the main arguments and supporting details. Include any relevant examples or data that reinforce the key points made in the original text. + +Clarity and Conciseness: While the summary should be detailed, it should also be clear and concise. Avoid unnecessary jargon or overly complex language to ensure that the summary is accessible to a broad audience. + +Objective Tone: Maintain an objective and neutral tone throughout the summary. Avoid personal opinions or interpretations; instead, focus on accurately reflecting the author's intended message. + +Conclusion: End the summary with a brief conclusion that encapsulates the overall significance of the text and its implications. + +Please summarize the following text: + + +{document} + +""" + + +report_prompt = PromptTemplate( + input_variables=["document"], + template=report_template +) \ No newline at end of file diff --git a/backend/requirements.txt b/backend/requirements.txt index 6a00fc2..598613e 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -18,8 +18,6 @@ langchain_chroma flashrank psycopg2 unstructured-client -python-libmagic -poppler-utils langchain-unstructured langgraph gpt_researcher