Dixit commited on
Commit
177939a
1 Parent(s): d529835

Streamlit UI commit

Browse files
Files changed (2) hide show
  1. app.py +80 -0
  2. requirements.txt +0 -0
app.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pickle
3
+ #from Summarizer_Helper import Summary_Gen
4
+
5
+ from gpt4all import GPT4All
6
+ import textwrap
7
+
8
+ with open('examples.pkl', 'rb') as f:
9
+ example_list = pickle.load(f)
10
+
11
+ # Model initialization (assuming the model is already downloaded)
12
+ from huggingface_hub import hf_hub_download
13
+ model_path = "models"
14
+ model_name = "Llama-2-7b-MOM_Summar.Q2_K.gguf"
15
+ # hf_hub_download(repo_id="sasvata/Llama2-7b-MOM-Summary-Finetuned-GGUF", filename=model_name, local_dir=model_path, local_dir_use_symlinks=False)
16
+
17
+ print("Start the model init process")
18
+ model = model = GPT4All(model_name, model_path, allow_download = False, device="cpu")
19
+ print("Finish the model init process")
20
+
21
+ ## Function to convert plain text to markdown format
22
+ def to_markdown(text):
23
+ text = text.replace('•', ' *')
24
+ return textwrap.indent(text, '> ', predicate=lambda _: True)
25
+
26
+ # Default system prompt for generating conversation summaries
27
+ DEFAULT_SYSTEM_PROMPT = """
28
+ Below is a conversation between a human and an AI agent. Write a summary of the conversation.
29
+ """.strip()
30
+
31
+ def generate_prompt(
32
+ Transcript: str, system_prompt: str = DEFAULT_SYSTEM_PROMPT
33
+ ) -> str:
34
+ return f"""### Instruction: {system_prompt}
35
+
36
+ ### Input:
37
+ {Transcript.strip()}
38
+
39
+ ### Response:
40
+ """.strip()
41
+
42
+ # Function to generate summary with the help of fine-tuned model
43
+ def Summary_Gen(Transcript):
44
+ prompt = generate_prompt(Transcript)
45
+ summary = model.generate(prompt=prompt,max_tokens=4096)
46
+ # summary_output = to_markdown(summary)
47
+ return summary_output
48
+
49
+ # Function for text summarization
50
+ def summarize_text(text):
51
+ # Your text summarization logic here (replaced with Summary_Gen)
52
+ summarized_text = Summary_Gen(text)
53
+ return summarized_text
54
+
55
+
56
+ st.set_page_config(layout="wide", page_title="MOM-Summary-Generator📑", page_icon="📑")
57
+ st.title("Minutes Of Meeting (MOM) - Summary Generator 📑")
58
+
59
+ # Text input and output elements
60
+ option = st.selectbox(
61
+ "Choose Example",
62
+ example_list,
63
+ index=None,
64
+ placeholder="Choose Example",
65
+ )
66
+
67
+
68
+ summary_output = ""
69
+ col1, col2 = st.columns(2)
70
+
71
+ col1.title('Input')
72
+ col1.container(height=500, border=True).text_area("", option, height=1000)
73
+ if col1.button("Summarize"):
74
+ with st.spinner('Wait for it...'):
75
+ summary_output = summarize_text(option)
76
+
77
+
78
+ col2.title('Output')
79
+ col2.container(height=500, border=True).markdown(summary_output, unsafe_allow_html=True)
80
+
requirements.txt ADDED
File without changes