SUHAN-I commited on
Commit
512bd00
·
verified ·
1 Parent(s): 67e37b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -53
app.py CHANGED
@@ -64,6 +64,14 @@ client = Groq(api_key="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"
64
 
65
 
66
 
 
 
 
 
 
 
 
 
67
  # Sidebar Menu with topics and subtopics
68
  topics = {
69
  "Artificial Intelligence": ["Overview", "Applications", "Future Prospects"],
@@ -84,6 +92,9 @@ for topic, subtopics in topics.items():
84
  if selected_subtopic:
85
  selected_topic = topic
86
 
 
 
 
87
  # Display title based on subtopic selection
88
  if selected_subtopic:
89
  st.title(f"MEGA_BOT - {selected_subtopic}")
@@ -99,101 +110,89 @@ def generate_response(prompt):
99
  )
100
  return chat_completion.choices[0].message.content
101
 
102
- # Display response based on the selected subtopic
103
- if selected_subtopic and selected_topic:
104
- # Creating a prompt for the model based on the selected subtopic
105
- if selected_subtopic == "Overview" and selected_topic == "Artificial Intelligence":
106
- prompt = """
107
  Explain the overview of Artificial Intelligence (AI) in a detailed manner.
108
  Break down the explanation into simple, easy-to-understand points for beginners, avoiding technical jargon.
109
  Make it long and creative, and include practical examples and analogies where possible.
110
- """
111
-
112
- elif selected_subtopic == "Applications" and selected_topic == "Artificial Intelligence":
113
- prompt = """
114
  Explain the main applications of Artificial Intelligence in various industries.
115
  Break it down into point-wise, simple, and creative explanations suitable for a beginner.
116
  Include examples from everyday life to make it relatable.
117
- """
118
-
119
- elif selected_subtopic == "Future Prospects" and selected_topic == "Artificial Intelligence":
120
- prompt = """
121
  What are the future prospects of Artificial Intelligence, and how will it evolve?
122
  Provide a detailed response with creative ideas, breaking it down into simple, easy-to-understand points.
123
  Consider the potential positive and negative impacts on society.
124
- """
125
-
126
- elif selected_subtopic == "Introduction" and selected_topic == "Generative AI":
127
- prompt = """
128
  Provide an introduction to Generative AI and its core principles.
129
  Use simple, beginner-friendly language and provide creative explanations with examples.
130
  Break it down into points and keep the response long and informative.
131
- """
132
-
133
- elif selected_subtopic == "Applications" and selected_topic == "Generative AI":
134
- prompt = """
135
  Explain the key applications of Generative AI in various fields.
136
  Break the explanation into simple, easy-to-understand points, and use examples.
137
  Make the response long and creative with real-world use cases.
138
- """
139
-
140
- elif selected_subtopic == "Ethics" and selected_topic == "Generative AI":
141
- prompt = """
142
  What are the ethical concerns related to Generative AI and its usage?
143
  Provide a detailed, easy-to-understand explanation with examples.
144
  Break down the explanation into simple, point-wise sections suitable for a beginner.
145
- """
146
-
147
- elif selected_subtopic == "GPT" and selected_topic == "Specific Models":
148
- prompt = """
149
  Explain the GPT (Generative Pretrained Transformer) model and its capabilities.
150
  Break the explanation down into beginner-friendly, simple points.
151
  Use analogies and relatable examples to make it creative and easy to understand.
152
- """
153
-
154
- elif selected_subtopic == "BERT" and selected_topic == "Specific Models":
155
- prompt = """
156
  Explain the BERT (Bidirectional Encoder Representations from Transformers) model.
157
  Provide a detailed, easy-to-understand response with simple points and examples.
158
  Use creative language to explain complex concepts simply.
159
- """
160
-
161
- elif selected_subtopic == "Electra" and selected_topic == "Specific Models":
162
- prompt = """
163
  Describe the Electra model and its applications.
164
  Break the explanation into simple, easy-to-understand points, and keep it creative and beginner-friendly.
165
  Provide relatable examples where possible.
166
- """
167
-
168
- elif selected_subtopic == "Gemma2-9b-it" and selected_topic == "Specific Models":
169
- prompt = """
170
  What is the Gemma2-9b-it model, and what makes it unique?
171
  Break down the explanation into points and make it understandable for a beginner.
172
  Include simple examples and analogies to help explain the key features and capabilities.
173
- """
174
-
175
- elif selected_subtopic == "With RAG" and selected_topic == "Building Applications":
176
- prompt = """
177
  Explain how to build applications using Retrieval-Augmented Generation (RAG).
178
  Break it down into beginner-friendly points with creative examples and analogies.
179
  Provide a detailed yet simple explanation for non-technical users.
180
- """
181
-
182
- elif selected_subtopic == "Without RAG" and selected_topic == "Building Applications":
183
- prompt = """
184
  Explain how to build applications without using Retrieval-Augmented Generation (RAG).
185
  Provide a detailed, easy-to-understand explanation with creative examples.
186
  Break down the response into simple, point-wise sections for beginners.
187
- """
 
188
 
 
 
 
 
 
189
  # Generate the response based on the prompt using the Groq model
190
  response = generate_response(prompt)
191
-
192
  # Display the model's response
193
  st.write(response)
194
 
195
- else:
196
- st.write("Please select a subtopic to learn more.")
 
 
 
 
 
 
197
 
198
 
199
 
 
64
 
65
 
66
 
67
+
68
+
69
+
70
+
71
+
72
+
73
+ import streamlit as st
74
+
75
  # Sidebar Menu with topics and subtopics
76
  topics = {
77
  "Artificial Intelligence": ["Overview", "Applications", "Future Prospects"],
 
92
  if selected_subtopic:
93
  selected_topic = topic
94
 
95
+ # Checkbox to confirm user is ready to view response
96
+ show_response = st.sidebar.checkbox("Show response")
97
+
98
  # Display title based on subtopic selection
99
  if selected_subtopic:
100
  st.title(f"MEGA_BOT - {selected_subtopic}")
 
110
  )
111
  return chat_completion.choices[0].message.content
112
 
113
+ # Mapping of topic-subtopic pairs to prompts
114
+ prompts = {
115
+ ("Artificial Intelligence", "Overview"): """
 
 
116
  Explain the overview of Artificial Intelligence (AI) in a detailed manner.
117
  Break down the explanation into simple, easy-to-understand points for beginners, avoiding technical jargon.
118
  Make it long and creative, and include practical examples and analogies where possible.
119
+ """,
120
+ ("Artificial Intelligence", "Applications"): """
 
 
121
  Explain the main applications of Artificial Intelligence in various industries.
122
  Break it down into point-wise, simple, and creative explanations suitable for a beginner.
123
  Include examples from everyday life to make it relatable.
124
+ """,
125
+ ("Artificial Intelligence", "Future Prospects"): """
 
 
126
  What are the future prospects of Artificial Intelligence, and how will it evolve?
127
  Provide a detailed response with creative ideas, breaking it down into simple, easy-to-understand points.
128
  Consider the potential positive and negative impacts on society.
129
+ """,
130
+ ("Generative AI", "Introduction"): """
 
 
131
  Provide an introduction to Generative AI and its core principles.
132
  Use simple, beginner-friendly language and provide creative explanations with examples.
133
  Break it down into points and keep the response long and informative.
134
+ """,
135
+ ("Generative AI", "Applications"): """
 
 
136
  Explain the key applications of Generative AI in various fields.
137
  Break the explanation into simple, easy-to-understand points, and use examples.
138
  Make the response long and creative with real-world use cases.
139
+ """,
140
+ ("Generative AI", "Ethics"): """
 
 
141
  What are the ethical concerns related to Generative AI and its usage?
142
  Provide a detailed, easy-to-understand explanation with examples.
143
  Break down the explanation into simple, point-wise sections suitable for a beginner.
144
+ """,
145
+ ("Specific Models", "GPT"): """
 
 
146
  Explain the GPT (Generative Pretrained Transformer) model and its capabilities.
147
  Break the explanation down into beginner-friendly, simple points.
148
  Use analogies and relatable examples to make it creative and easy to understand.
149
+ """,
150
+ ("Specific Models", "BERT"): """
 
 
151
  Explain the BERT (Bidirectional Encoder Representations from Transformers) model.
152
  Provide a detailed, easy-to-understand response with simple points and examples.
153
  Use creative language to explain complex concepts simply.
154
+ """,
155
+ ("Specific Models", "Electra"): """
 
 
156
  Describe the Electra model and its applications.
157
  Break the explanation into simple, easy-to-understand points, and keep it creative and beginner-friendly.
158
  Provide relatable examples where possible.
159
+ """,
160
+ ("Specific Models", "Gemma2-9b-it"): """
 
 
161
  What is the Gemma2-9b-it model, and what makes it unique?
162
  Break down the explanation into points and make it understandable for a beginner.
163
  Include simple examples and analogies to help explain the key features and capabilities.
164
+ """,
165
+ ("Building Applications", "With RAG"): """
 
 
166
  Explain how to build applications using Retrieval-Augmented Generation (RAG).
167
  Break it down into beginner-friendly points with creative examples and analogies.
168
  Provide a detailed yet simple explanation for non-technical users.
169
+ """,
170
+ ("Building Applications", "Without RAG"): """
 
 
171
  Explain how to build applications without using Retrieval-Augmented Generation (RAG).
172
  Provide a detailed, easy-to-understand explanation with creative examples.
173
  Break down the response into simple, point-wise sections for beginners.
174
+ """
175
+ }
176
 
177
+ # Display response based on the selected subtopic only if the checkbox is checked
178
+ if selected_subtopic and selected_topic and show_response:
179
+ # Retrieve the prompt based on the selected topic and subtopic
180
+ prompt = prompts.get((selected_topic, selected_subtopic), "No prompt available for this selection.")
181
+
182
  # Generate the response based on the prompt using the Groq model
183
  response = generate_response(prompt)
184
+
185
  # Display the model's response
186
  st.write(response)
187
 
188
+ elif not show_response:
189
+ # Display a message prompting the user to check the box if it is not checked
190
+ st.write("Please select a topic and subtopic from the sidebar and check 'Show response' to see more information.")
191
+
192
+
193
+
194
+
195
+
196
 
197
 
198