forked from GetStream/meeting-summary-ollama-gemma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
53 lines (45 loc) · 1.92 KB
/
main.py
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
import json
import ollama
import requests
def load_conversation_data():
with open("meeting_transcript.json") as f:
json_file = json.load(f)
extraction = lambda x: f"{x['speaker']}: {x['text']}"
conversation = list(map(extraction, json_file))
conversation_string = "\n".join(conversation)
return conversation_string
def meeting_summary():
conversation_string = load_conversation_data()
response = ollama.chat(model='gemma:2b', messages=[
{
'role': 'system',
'content': 'Your goal is to summarize the text that is given to you in roughly 300 words. It is from a meeting between one or more people. Only output the summary without any additional text. Focus on providing a summary in freeform text with a summary of what people said and the action items coming out of it.'
},
{
'role': 'user',
'content': conversation_string,
},
])
return response['message']['content']
def meeting_summary_rest():
conversation_string = load_conversation_data()
prompt = """Your goal is to summarize the text that is given to you
in roughly 300 words. It is from a meeting between one or more people.
Only output the summary without any additional text.
Focus on providing a summary in freeform text with a summary of what
people said and the action items coming out of it."""
OLLAMA_ENDPOINT = "http://localhost:11434/api/generate"
OLLAMA_PROMPT = f"{prompt}: {conversation_string}"
OLLAMA_DATA = {
"model": "gemma:2b",
"prompt": OLLAMA_PROMPT,
"stream": False,
"keep_alive": "1m",
}
response = requests.post(OLLAMA_ENDPOINT, json=OLLAMA_DATA)
return response.json()["response"]
print("Summary using the library:")
print(meeting_summary())
print("---------------------------")
print("Summary using the REST API:")
print(meeting_summary_rest())