chrisvnz Shad0ws commited on
Commit
a1539e3
·
0 Parent(s):

Duplicate from Shad0ws/Meeting-Summarizer

Browse files

Co-authored-by: Shahnab Ahmed <[email protected]>

Files changed (4) hide show
  1. .gitattributes +34 -0
  2. README.md +14 -0
  3. app.py +103 -0
  4. requirements.txt +2 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Meeting Summarizer
3
+ emoji: 🏢
4
+ colorFrom: yellow
5
+ colorTo: purple
6
+ sdk: gradio
7
+ sdk_version: 3.20.1
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ duplicated_from: Shad0ws/Meeting-Summarizer
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import openai
3
+ import tiktoken
4
+ from multiprocessing.pool import ThreadPool
5
+
6
+ enc = tiktoken.get_encoding("cl100k_base")
7
+
8
+ MODES = {
9
+ "Short summary": "Succintly summarize the following meeting transcript in a single paragraph.",
10
+ "Detailed summary": "Summarize the following meeting transcript. The summary should include all the important points discussed in the meeting.",
11
+ "Action points": "Summarize the following meeting transcript in form of action points.",
12
+ "Further actions": "Who and what should be done next? Summarize the following meeting transcript in form of action points.",
13
+ "Custom": "",
14
+ }
15
+
16
+ SUMMARY_PROMPT = "Summarize the following meeting in very great detail. The summary should include all the important points discussed in the meeting."
17
+
18
+ def summarize_part(text, api_key):
19
+ response = openai.ChatCompletion.create(
20
+ model="gpt-3.5-turbo",
21
+ messages=[
22
+ { "role": "system", "content": f"You are a meeting organizer. You want to summarize a meeting. You are given the following transcript of the meeting. {SUMMARY_PROMPT}" },
23
+ { "role": "user", "content": text },
24
+ ],
25
+ api_key=api_key,
26
+ )
27
+ return response["choices"][0]["message"]["content"]
28
+
29
+ def shorten_text(text, api_key):
30
+ # Split into chunks so that each chunk is less than 3000 words (not characters!)
31
+ # Overlap by halves.
32
+ chunks = []
33
+ words = text.split()
34
+ for i in range(0, len(words), 1500):
35
+ chunk = ""
36
+ while len(enc.encode(chunk)) < 4000 and i < len(words):
37
+ chunk += words[i] + " "
38
+ i += 1
39
+ chunks.append(chunk)
40
+
41
+ with ThreadPool(4) as pool:
42
+ shortened = pool.starmap(summarize_part, zip(chunks, [api_key]*len(chunks)))
43
+
44
+ return "".join(shortened)
45
+
46
+ def modify_text(text, api_key, command, custom_command=None):
47
+ if command == "Custom":
48
+ prompt = custom_command
49
+ else:
50
+ prompt = MODES[command]
51
+
52
+ if len(enc.encode(text)) < 4096:
53
+ response = openai.ChatCompletion.create(
54
+ model="gpt-3.5-turbo",
55
+ messages=[
56
+ { "role": "system", "content": f"You are a meeting organizer. You want to summarize a meeting. You are given the following transcript of the meeting. {prompt}" },
57
+ { "role": "user", "content": text },
58
+ ],
59
+ api_key=api_key,
60
+ )
61
+ return response["choices"][0]["message"]["content"]
62
+ else:
63
+ prompt = prompt.replace("meeting transcript", "meeting parts")
64
+ shortened = text
65
+ while len(enc.encode(shortened)) > 4096:
66
+ shortened = shorten_text(shortened, api_key)
67
+ response = openai.ChatCompletion.create(
68
+ model="gpt-3.5-turbo",
69
+ messages=[
70
+ { "role": "system", "content": f"You are a meeting organizer. You want to summarize a meeting. You are given the following summary of the meeting parts. {prompt}" },
71
+ { "role": "user", "content": shortened },
72
+ ],
73
+ api_key=api_key,
74
+ )
75
+ return response["choices"][0]["message"]["content"]
76
+
77
+ with gr.Blocks() as demo:
78
+ gr.Markdown("# Meeting Summarizer")
79
+ gr.Markdown("#### Short Summary | Detailed Summary | Action points | Further Actions | Custom Command")
80
+ gr.Markdown("###### Turbo-charged by GPT-3.5-turbo")
81
+ with gr.Row():
82
+ with gr.Column():
83
+ api_key = gr.Textbox(lines=1,type='password', label="OpenAI API Key")
84
+ input_text = gr.Textbox(lines=15, label="Meeting Transcript")
85
+ with gr.Column():
86
+ command = gr.Dropdown(list(MODES.keys()), label="Command", value="Short summary")
87
+ custom_command = gr.Textbox(lines=2, label="Custom command", visible=False, value="Summarize the following meeting transcript in a single paragraph. The summary should include all the important points discussed in the meeting.")
88
+ output_text = gr.Textbox(lines=10, label="Summary")
89
+
90
+
91
+ def show_command(command):
92
+ if command == "Custom":
93
+ return {custom_command: gr.update(visible=True)}
94
+ else:
95
+ return {custom_command: gr.update(visible=False)}
96
+
97
+ command.change(show_command, command, custom_command)
98
+
99
+ button = gr.Button(label="Process")
100
+ button.click(modify_text, [input_text, api_key, command, custom_command], output_text)
101
+
102
+ demo.title = "Meeting Summarizer-Demo"
103
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ openai
2
+ tiktoken==0.3.0