Spaces:
Runtime error
Runtime error
readme, pytest
Browse files- .gitignore +2 -0
- README.md +3 -0
- app.py +6 -2
- requirements.txt +2 -0
- test_sanitize.py +10 -0
.gitignore
CHANGED
@@ -1 +1,3 @@
|
|
1 |
.idea/
|
|
|
|
|
|
1 |
.idea/
|
2 |
+
__pycache__/
|
3 |
+
|
README.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
$ uv pip install -r requirements.txt
|
2 |
+
$ streamlit run app.py
|
3 |
+
|
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
from ollama import chat
|
3 |
from loguru import logger
|
4 |
-
|
5 |
|
6 |
available_models = [
|
7 |
'openhermes',
|
@@ -65,11 +65,15 @@ def main():
|
|
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__":
|
75 |
main()
|
|
|
1 |
import streamlit as st
|
2 |
from ollama import chat
|
3 |
from loguru import logger
|
4 |
+
import re
|
5 |
|
6 |
available_models = [
|
7 |
'openhermes',
|
|
|
65 |
answer1 = ask(model1, system_prompt1, pre_prompt1, question1)
|
66 |
st.write(f":blue[Priest says:] {answer1}")
|
67 |
|
68 |
+
qp2 = sanitize(answer1)
|
69 |
|
70 |
answer2 = ask(model2, system_prompt2, pre_prompt2, qp2)
|
71 |
st.write(f":blue[Teacher says:] {answer2}")
|
72 |
|
73 |
|
74 |
+
def sanitize(question):
|
75 |
+
return re.sub(r"\([^)]*\)", "", question)
|
76 |
+
|
77 |
+
|
78 |
if __name__ == "__main__":
|
79 |
main()
|
requirements.txt
CHANGED
@@ -1,3 +1,5 @@
|
|
1 |
streamlit
|
2 |
ollama
|
|
|
|
|
3 |
|
|
|
1 |
streamlit
|
2 |
ollama
|
3 |
+
loguru
|
4 |
+
pytest
|
5 |
|
test_sanitize.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from app import sanitize
|
2 |
+
|
3 |
+
|
4 |
+
def test_sanitize():
|
5 |
+
assert '' == sanitize('')
|
6 |
+
assert 'qwertyui' == sanitize('qwertyui')
|
7 |
+
assert 'qwertyui ' == sanitize('qwertyui (abcdef)')
|
8 |
+
assert 'qwertyui poiuy' == sanitize('qwertyui (abcdef) poiuy')
|
9 |
+
|
10 |
+
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.)')
|