Spaces:
Sleeping
Sleeping
Delete Summarizer.py
Browse files- Summarizer.py +0 -26
Summarizer.py
DELETED
|
@@ -1,26 +0,0 @@
|
|
| 1 |
-
from langchain.chains.combine_documents import create_stuff_documents_chain
|
| 2 |
-
from langchain_core.prompts import ChatPromptTemplate
|
| 3 |
-
|
| 4 |
-
def get_summary_prompt():
|
| 5 |
-
"""Get the prompt template for document summarization"""
|
| 6 |
-
return ChatPromptTemplate.from_template("""
|
| 7 |
-
You are a helpful assistant. Summarize the following document clearly and accurately:
|
| 8 |
-
<context>
|
| 9 |
-
{context}
|
| 10 |
-
</context>
|
| 11 |
-
""")
|
| 12 |
-
|
| 13 |
-
def summarize_document(llm, documents):
|
| 14 |
-
"""
|
| 15 |
-
Summarize the uploaded document(s)
|
| 16 |
-
|
| 17 |
-
Args:
|
| 18 |
-
llm: Language model instance
|
| 19 |
-
documents: List of document chunks
|
| 20 |
-
|
| 21 |
-
Returns:
|
| 22 |
-
str: Document summary
|
| 23 |
-
"""
|
| 24 |
-
summary_prompt = get_summary_prompt()
|
| 25 |
-
chain = create_stuff_documents_chain(llm, summary_prompt)
|
| 26 |
-
return chain.invoke({"context": documents})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|