Spaces:
Runtime error
Runtime error
strip
Browse files- app.py +2 -3
- test_sanitize.py +5 -1
app.py
CHANGED
@@ -70,7 +70,7 @@ def main():
|
|
70 |
role = target(question)
|
71 |
max_steps = 10
|
72 |
for step, _ in enumerate(range(max_steps), start=1):
|
73 |
-
with st.spinner(f"{step}/{max_steps} Asking {role}..."):
|
74 |
actor = Actor[role]
|
75 |
answer = ask(actor.model, actor.system_prompt, actor.pre_prompt, question)
|
76 |
st.write(f":blue[{actor.role} says:] {answer}")
|
@@ -79,8 +79,7 @@ def main():
|
|
79 |
|
80 |
|
81 |
def target(question):
|
82 |
-
return re.split(r'\s|,|:', question)[0]
|
83 |
-
|
84 |
|
85 |
def sanitize(question):
|
86 |
return re.sub(r"\([^)]*\)", "", question)
|
|
|
70 |
role = target(question)
|
71 |
max_steps = 10
|
72 |
for step, _ in enumerate(range(max_steps), start=1):
|
73 |
+
with st.spinner(f"({step}/{max_steps}) Asking {role}..."):
|
74 |
actor = Actor[role]
|
75 |
answer = ask(actor.model, actor.system_prompt, actor.pre_prompt, question)
|
76 |
st.write(f":blue[{actor.role} says:] {answer}")
|
|
|
79 |
|
80 |
|
81 |
def target(question):
|
82 |
+
return re.split(r'\s|,|:', question.strip())[0].strip()
|
|
|
83 |
|
84 |
def sanitize(question):
|
85 |
return re.sub(r"\([^)]*\)", "", question)
|
test_sanitize.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from app import sanitize
|
2 |
|
3 |
|
4 |
def test_sanitize():
|
@@ -10,3 +10,7 @@ def test_sanitize():
|
|
10 |
assert 'qwertyui poiuy' == sanitize('qwertyui (abcdef) poiuy')
|
11 |
|
12 |
assert '"Teacher, I heard about a fascinating story from someone who lives in the city. Can you guess who it might be?" ' == sanitize('"Teacher, I heard about a fascinating story from someone who lives in the city. Can you guess who it might be?" (I want to find out if the Teacher can make any connections between my statement and their own information.)')
|
|
|
|
|
|
|
|
|
|
1 |
+
from app import sanitize, target
|
2 |
|
3 |
|
4 |
def test_sanitize():
|
|
|
10 |
assert 'qwertyui poiuy' == sanitize('qwertyui (abcdef) poiuy')
|
11 |
|
12 |
assert '"Teacher, I heard about a fascinating story from someone who lives in the city. Can you guess who it might be?" ' == sanitize('"Teacher, I heard about a fascinating story from someone who lives in the city. Can you guess who it might be?" (I want to find out if the Teacher can make any connections between my statement and their own information.)')
|
13 |
+
|
14 |
+
def test_target():
|
15 |
+
assert 'Priest' == target("Priest, 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!")
|
16 |
+
assert 'Priest' == target(sanitize("(I'm thinking hmm) Priest, .."))
|