Spaces:
Runtime error
Runtime error
teacher replies
Browse files
app.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
from ollama import chat
|
|
|
|
|
3 |
|
4 |
available_models = [
|
5 |
'openhermes',
|
@@ -13,16 +15,18 @@ available_models = [
|
|
13 |
|
14 |
|
15 |
def ask(model, system_prompt, pre_prompt, question):
|
16 |
-
|
17 |
{
|
18 |
'role': 'system',
|
19 |
-
'content': f"{system_prompt}
|
20 |
},
|
21 |
{
|
22 |
'role': 'user',
|
23 |
-
'content': f
|
24 |
},
|
25 |
-
]
|
|
|
|
|
26 |
return response['message']['content']
|
27 |
|
28 |
|
@@ -31,8 +35,8 @@ def main():
|
|
31 |
sp2 = """There are 3 people standing in a circle: the Priest, the Teacher (that's you) and the Kid."""
|
32 |
sp3 = """There are 3 people standing in a circle: the Priest, the Teacher and the Kid (that's you)."""
|
33 |
|
34 |
-
pp1 = pp2 = pp3 = "Ask the other two by always starting your sentence with their role.
|
35 |
-
qp1 = qp2 = qp3 = "Your task is to figure out their names and where they live. Do not ask directly, they must not realize what information you are after!"
|
36 |
|
37 |
st.set_page_config(layout="wide")
|
38 |
col1, col2, col3 = st.columns(3)
|
@@ -48,18 +52,23 @@ def main():
|
|
48 |
model2 = st.selectbox(key="model2", label="model", options=available_models)
|
49 |
system_prompt2 = st.text_area(key="sp2", label="system-prompt", value=sp2)
|
50 |
pre_prompt2 = st.text_area(key="pp2", label="pre-prompt", value=pp2)
|
51 |
-
question2 = st.text_area(key="q2", label="question", value=qp2)
|
52 |
|
53 |
with col3:
|
54 |
st.title("the Kid")
|
55 |
model3 = st.selectbox(key="model3", label="model", options=available_models)
|
56 |
system_prompt3 = st.text_area(key="sp3", label="system-prompt", value=sp3)
|
57 |
pre_prompt3 = st.text_area(key="pp3", label="pre-prompt", value=pp3)
|
58 |
-
question3 = st.text_area(key="q3", label="question", value=qp3)
|
59 |
|
60 |
with st.spinner("Thinking..."):
|
61 |
answer1 = ask(model1, system_prompt1, pre_prompt1, question1)
|
62 |
-
st.write(answer1)
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
|
65 |
if __name__ == "__main__":
|
|
|
1 |
import streamlit as st
|
2 |
from ollama import chat
|
3 |
+
from loguru import logger
|
4 |
+
|
5 |
|
6 |
available_models = [
|
7 |
'openhermes',
|
|
|
15 |
|
16 |
|
17 |
def ask(model, system_prompt, pre_prompt, question):
|
18 |
+
messages = [
|
19 |
{
|
20 |
'role': 'system',
|
21 |
+
'content': f"{system_prompt} {pre_prompt}",
|
22 |
},
|
23 |
{
|
24 |
'role': 'user',
|
25 |
+
'content': f"{question}",
|
26 |
},
|
27 |
+
]
|
28 |
+
logger.debug(f"<< {model} << {messages}")
|
29 |
+
response = chat(model=model, messages=messages)
|
30 |
return response['message']['content']
|
31 |
|
32 |
|
|
|
35 |
sp2 = """There are 3 people standing in a circle: the Priest, the Teacher (that's you) and the Kid."""
|
36 |
sp3 = """There are 3 people standing in a circle: the Priest, the Teacher and the Kid (that's you)."""
|
37 |
|
38 |
+
pp1 = pp2 = pp3 = "Ask the other two by always starting your sentence with their role. Share your inner thoughts inside parentheses."
|
39 |
+
qp1 = qp2 = qp3 = "Your task is to figure out their names and where they live. Do not ask directly, they must not realize what information you are after! SAY ONLY ONE SINGLE SENTENCE!"
|
40 |
|
41 |
st.set_page_config(layout="wide")
|
42 |
col1, col2, col3 = st.columns(3)
|
|
|
52 |
model2 = st.selectbox(key="model2", label="model", options=available_models)
|
53 |
system_prompt2 = st.text_area(key="sp2", label="system-prompt", value=sp2)
|
54 |
pre_prompt2 = st.text_area(key="pp2", label="pre-prompt", value=pp2)
|
55 |
+
# question2 = st.text_area(key="q2", label="question", value=qp2)
|
56 |
|
57 |
with col3:
|
58 |
st.title("the Kid")
|
59 |
model3 = st.selectbox(key="model3", label="model", options=available_models)
|
60 |
system_prompt3 = st.text_area(key="sp3", label="system-prompt", value=sp3)
|
61 |
pre_prompt3 = st.text_area(key="pp3", label="pre-prompt", value=pp3)
|
62 |
+
# question3 = st.text_area(key="q3", label="question", value=qp3)
|
63 |
|
64 |
with st.spinner("Thinking..."):
|
65 |
answer1 = ask(model1, system_prompt1, pre_prompt1, question1)
|
66 |
+
st.write(f":blue[Priest says:] {answer1}")
|
67 |
+
|
68 |
+
qp2 = answer1
|
69 |
+
|
70 |
+
answer2 = ask(model2, system_prompt2, pre_prompt2, qp2)
|
71 |
+
st.write(f":blue[Teacher says:] {answer2}")
|
72 |
|
73 |
|
74 |
if __name__ == "__main__":
|
shot1.png
ADDED