-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_llm.py
More file actions
38 lines (25 loc) · 1.22 KB
/
custom_llm.py
File metadata and controls
38 lines (25 loc) · 1.22 KB
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
import ollama
def summarize_questions(page_text: str, questions: list[str]):
prompt = """
You are an assistant for a teacher who has assigned students a reading task. The students were asked to generate questions based on the text, and you will receive both the text context and the students' questions.
Please summarize the questions asked by the students. If multiple questions are asked about the same topic, you can group them together.
This overview should help the teacher prepare to answer the questions in the next lesson. Especially point out which topics where unclear or difficult for the students. Do not provide answers to the questions.
Your anser should be strucutred as follows:
- "Questions": A condensed list of the students' questions. Combine similar quesions into one.
- "Problems": A list of the topics that seemed to be unclear or difficult for the students.
The reading context is as follows:
<context>
{}
</context>
The students' questions are as follows:
""".format(page_text)
for question in questions:
prompt += "\n- {}".format(question)
prompt
response = ollama.chat(model='llama3.1:8b', messages=[
{
'role': 'user',
'content': prompt,
},
])
return response['message']['content']