Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,30 +4,30 @@ model_id = "knkarthick/MEETING_SUMMARY"
|
|
4 |
|
5 |
generator = pipeline(task="text2text-generation", model=model_id)
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
23 |
-
|
24 |
-
|
25 |
|
26 |
-
|
27 |
|
28 |
def launch(input):
|
29 |
-
|
30 |
-
|
31 |
return generator(input)[0]["generated_text"]
|
32 |
|
33 |
iface = gr.Interface(launch, inputs="text", outputs="text")
|
|
|
4 |
|
5 |
generator = pipeline(task="text2text-generation", model=model_id)
|
6 |
|
7 |
+
def split_paragraph(paragraph, max_chunk_size=1024):
|
8 |
+
words = paragraph.split()
|
9 |
+
chunks = []
|
10 |
+
current_chunk = []
|
11 |
+
current_chunk_size = 0
|
12 |
|
13 |
+
for word in words:
|
14 |
+
word_len = len(word) + 1 # Add 1 for the space
|
15 |
+
if current_chunk_size + word_len <= max_chunk_size:
|
16 |
+
current_chunk.append(word)
|
17 |
+
current_chunk_size += word_len
|
18 |
+
else:
|
19 |
+
chunks.append(' '.join(current_chunk))
|
20 |
+
current_chunk = [word]
|
21 |
+
current_chunk_size = word_len
|
22 |
|
23 |
+
if current_chunk:
|
24 |
+
chunks.append(' '.join(current_chunk))
|
25 |
|
26 |
+
return chunks
|
27 |
|
28 |
def launch(input):
|
29 |
+
if len(input) > 1024:
|
30 |
+
return " ".join([res["generated_text"] for res in generator(split_paragraph(input))])
|
31 |
return generator(input)[0]["generated_text"]
|
32 |
|
33 |
iface = gr.Interface(launch, inputs="text", outputs="text")
|