Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from groq import Groq
|
| 3 |
+
import streamlit as st
|
| 4 |
+
|
| 5 |
+
client = Groq(
|
| 6 |
+
api_key=os.environ.get("GROQ_API_KEY"),
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
st.write('Background analysis')
|
| 10 |
+
gl = st.text_area("Goal and assumptions",
|
| 11 |
+
placeholder="""What is the assumption to verify, what do you want to know,
|
| 12 |
+
the goal and mission of this polling""")
|
| 13 |
+
bg = st.text_area("Background information",
|
| 14 |
+
placeholder="""What is the polling about, what we should know to better
|
| 15 |
+
help you design the questions""")
|
| 16 |
+
|
| 17 |
+
if 'ft' in st.session_state or st.button('Next step'):
|
| 18 |
+
if 'ft' not in st.session_state:
|
| 19 |
+
messages = [
|
| 20 |
+
{
|
| 21 |
+
"role": "user",
|
| 22 |
+
"content": f"""Generate possible factors related to the goal
|
| 23 |
+
based on the information provided. List the factors in markdown list.\n\n
|
| 24 |
+
goals:\n\n{gl}\n\n
|
| 25 |
+
background:\n\n{bg}\n\n""",
|
| 26 |
+
}
|
| 27 |
+
]
|
| 28 |
+
|
| 29 |
+
chat_completion = client.chat.completions.create(
|
| 30 |
+
messages=messages,
|
| 31 |
+
model="llama3-8b-8192",
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
ft = st.text_area("Factors to be considered in questions",
|
| 35 |
+
chat_completion.choices[0].message.content)
|
| 36 |
+
st.session_state['ft'] = ft
|
| 37 |
+
st.write('Edit above factors, add or remove if needed')
|
| 38 |
+
|
| 39 |
+
if st.button('Generate questions'):
|
| 40 |
+
pass # for each factor generate 5 questions
|
| 41 |
+
# suggest the number of sample to collect for the polling = 7 * total question number
|
| 42 |
+
# dump questions into excel and allow download
|