-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgenerate_mom.py
64 lines (42 loc) · 1.57 KB
/
generate_mom.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
54
55
56
57
58
59
60
61
62
import sys
from langchain import OpenAI, PromptTemplate, LLMChain
import multiprocessing
from langchain.text_splitter import RecursiveCharacterTextSplitter
text_splitter = RecursiveCharacterTextSplitter()
# get transcript file key from args
file_key = sys.argv[1]
# get transcript text
text = open(file_key, "r").read()
llm = OpenAI(temperature=0, model_name="gpt-3.5-turbo")
texts = text_splitter.split_text(text)
from langchain.docstore.document import Document
prompt = PromptTemplate(
input_variables=['context'],
template="Identify the keypoints for meeting minutes in the following: {context} \n\n Key points:\n-",
)
docs = [Document(page_content=t) for t in texts]
key_points = []
def get_key_points(doc):
chain = LLMChain(llm=llm, prompt=prompt, verbose=1)
res = chain.run(doc.page_content)
return res
if __name__ == "__main__":
with multiprocessing.Pool(processes=8) as pool:
key_points = pool.starmap(
get_key_points, zip(docs)
)
pool.close()
pool.join()
print(key_points)
prompt_mom = PromptTemplate(
input_variables=['key_points'],
template="Below are the pointers for a meeting. Generate a meeting minutes include section for key things discussed and action items accordingly.\n{key_points}.",
)
chain = LLMChain(llm=llm, prompt=prompt_mom, verbose=1)
mom = chain.run(''.join(key_points))
print(mom)
# save mom to file
file_name = file_key.split("/")[-1].split(".")[0]
with open(f"{file_name}_mom.txt", "w") as f:
f.write(mom)
f.close()