File size: 1,571 Bytes
fc35dc8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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