PollDemo / app.py
npc0's picture
Create app.py
fc35dc8 verified
raw
history blame
1.57 kB
import os
from groq import Groq
import streamlit as st
client = Groq(
api_key=os.environ.get("GROQ_API_KEY"),
)
st.write('Background analysis')
gl = st.text_area("Goal and assumptions",
placeholder="""What is the assumption to verify, what do you want to know,
the goal and mission of this polling""")
bg = st.text_area("Background information",
placeholder="""What is the polling about, what we should know to better
help you design the questions""")
if 'ft' in st.session_state or st.button('Next step'):
if 'ft' not in st.session_state:
messages = [
{
"role": "user",
"content": f"""Generate possible factors related to the goal
based on the information provided. List the factors in markdown list.\n\n
goals:\n\n{gl}\n\n
background:\n\n{bg}\n\n""",
}
]
chat_completion = client.chat.completions.create(
messages=messages,
model="llama3-8b-8192",
)
ft = st.text_area("Factors to be considered in questions",
chat_completion.choices[0].message.content)
st.session_state['ft'] = ft
st.write('Edit above factors, add or remove if needed')
if st.button('Generate questions'):
pass # for each factor generate 5 questions
# suggest the number of sample to collect for the polling = 7 * total question number
# dump questions into excel and allow download