File size: 1,497 Bytes
6f5ce4c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from langchain.prompts import PromptTemplate

qa_template = (
"""

<|start_header_id|>system<|end_header_id|>

You are an AI assistant specialized in answering academic queries with accuracy and clarity.



### Instructions

- Read the user's question carefully.

- Provide a concise and informative answer based on available knowledge.

- If the question is unclear, ask for clarification.

- If you do not know the answer, respond with "I'm not sure."



### User Question

{question}



<|eot_id|><|start_header_id|>user<|end_header_id|>



Question: Please provide a detailed answer.

<|eot_id|><|start_header_id|>assistant<|end_header_id|>

Answer:

""")

summarization_template = (
"""

<|start_header_id|>system<|end_header_id|>

You are a highly skilled AI that specializes in summarizing academic content.



### Instructions

- Read the provided text carefully.

- Extract the most important key points while maintaining clarity.

- Summarize in a way that retains the core meaning but is concise.

- Output only the summary without additional explanations.



### Text to Summarize

{document_text}



<|eot_id|><|start_header_id|>user<|end_header_id|>



Task: Provide a concise summary.

<|eot_id|><|start_header_id|>assistant<|end_header_id|>

Summary:

""")

QA_PROMPT = PromptTemplate(
    input_variables=["question"],
    template=qa_template
)

SUMMARIZATION_PROMPT = PromptTemplate(
    input_variables=["document_text"],
    template=summarization_template
)