Spaces:
Runtime error
Runtime error
kjozsa
commited on
Commit
•
26ce77e
0
Parent(s):
roleplaying
Browse files- .gitignore +1 -0
- app.py +51 -0
- requirements.txt +3 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.idea/
|
app.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from ollama import chat
|
3 |
+
|
4 |
+
available_models = [
|
5 |
+
'openhermes',
|
6 |
+
'deepseek-coder',
|
7 |
+
'deepseek-coder:6.7b',
|
8 |
+
'falcon:7b',
|
9 |
+
'mistral:7b',
|
10 |
+
'phi',
|
11 |
+
'starling-lm'
|
12 |
+
]
|
13 |
+
|
14 |
+
|
15 |
+
def ask(model, system_prompt, pre_prompt, question):
|
16 |
+
response = chat(model=model, messages=[
|
17 |
+
{
|
18 |
+
'role': 'system',
|
19 |
+
'content': system_prompt,
|
20 |
+
},
|
21 |
+
{
|
22 |
+
'role': 'user',
|
23 |
+
'content': f'${pre_prompt}${question}',
|
24 |
+
},
|
25 |
+
])
|
26 |
+
return response['message']['content']
|
27 |
+
|
28 |
+
|
29 |
+
def main():
|
30 |
+
sp = """There are 3 people standing in a circle: you (the Priest), a Teacher and a Kid. You can ask the other two by starting your sentence with their role.
|
31 |
+
You act only as the Priest and wait for the others to answer. Always share your inner thoughts inside parentheses."""
|
32 |
+
pp = "Your task is to figure out their names and where they live. Do not reveal your intentions, they must not realize what information you need!"
|
33 |
+
qp = "Talk to the other two people, accomplishing your task."
|
34 |
+
|
35 |
+
st.set_page_config(layout="wide")
|
36 |
+
st.title("role playing experiments")
|
37 |
+
col1, col2, col3 = st.columns(3)
|
38 |
+
with col1:
|
39 |
+
st.title("the Teacher")
|
40 |
+
model = st.selectbox("model", available_models)
|
41 |
+
system_prompt = st.text_area("system-prompt", value=sp)
|
42 |
+
pre_prompt = st.text_area("pre-prompt", value=pp)
|
43 |
+
question = st.text_area("question", value=qp)
|
44 |
+
|
45 |
+
with st.spinner("Thinking..."):
|
46 |
+
answer = ask(model, system_prompt, pre_prompt, question)
|
47 |
+
st.write(answer)
|
48 |
+
|
49 |
+
|
50 |
+
if __name__ == "__main__":
|
51 |
+
main()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
ollama
|
3 |
+
|