Spaces:
Paused
Paused
Commit
·
feabab6
1
Parent(s):
bca0f23
Use black and logging
Browse files- app.py +4 -4
- test_answers.py +2 -0
- utils.py +5 -2
app.py
CHANGED
|
@@ -6,21 +6,21 @@ authenticator = stauth.Authenticate(
|
|
| 6 |
eval(st.secrets["creds"]),
|
| 7 |
st.secrets["name"],
|
| 8 |
st.secrets["key"],
|
| 9 |
-
int(st.secrets["expiry_days"])
|
| 10 |
)
|
| 11 |
|
| 12 |
st.title("Le risposte alle tue domande personali")
|
| 13 |
|
| 14 |
-
name, authentication_status, username = authenticator.login(
|
| 15 |
|
| 16 |
if authentication_status:
|
| 17 |
|
| 18 |
input = st.text_input("Scrivi una domanda in italiano e comparirà la risposta!")
|
| 19 |
|
| 20 |
if input:
|
| 21 |
-
|
| 22 |
response = get_answer(input)
|
| 23 |
st.write(response)
|
| 24 |
|
| 25 |
elif authentication_status == False:
|
| 26 |
-
st.error(
|
|
|
|
| 6 |
eval(st.secrets["creds"]),
|
| 7 |
st.secrets["name"],
|
| 8 |
st.secrets["key"],
|
| 9 |
+
int(st.secrets["expiry_days"]),
|
| 10 |
)
|
| 11 |
|
| 12 |
st.title("Le risposte alle tue domande personali")
|
| 13 |
|
| 14 |
+
name, authentication_status, username = authenticator.login("Login", "main")
|
| 15 |
|
| 16 |
if authentication_status:
|
| 17 |
|
| 18 |
input = st.text_input("Scrivi una domanda in italiano e comparirà la risposta!")
|
| 19 |
|
| 20 |
if input:
|
| 21 |
+
|
| 22 |
response = get_answer(input)
|
| 23 |
st.write(response)
|
| 24 |
|
| 25 |
elif authentication_status == False:
|
| 26 |
+
st.error("Username/password non sono corretti.")
|
test_answers.py
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
from utils import get_answer
|
| 2 |
|
|
|
|
| 3 |
def test_name():
|
| 4 |
q = "Come mi chiamo?"
|
| 5 |
a = get_answer(q)
|
| 6 |
assert "Giuseppe Fiocco" in a
|
| 7 |
|
|
|
|
| 8 |
def test_birthplace():
|
| 9 |
q = "Dove sono nato?"
|
| 10 |
a = get_answer(q)
|
|
|
|
| 1 |
from utils import get_answer
|
| 2 |
|
| 3 |
+
|
| 4 |
def test_name():
|
| 5 |
q = "Come mi chiamo?"
|
| 6 |
a = get_answer(q)
|
| 7 |
assert "Giuseppe Fiocco" in a
|
| 8 |
|
| 9 |
+
|
| 10 |
def test_birthplace():
|
| 11 |
q = "Dove sono nato?"
|
| 12 |
a = get_answer(q)
|
utils.py
CHANGED
|
@@ -4,6 +4,9 @@ import random
|
|
| 4 |
|
| 5 |
import streamlit as st
|
| 6 |
import openai
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
def get_prompt():
|
|
@@ -50,6 +53,6 @@ def get_answer(input):
|
|
| 50 |
|
| 51 |
ans = response["choices"][0]["text"].replace("Risposta:", "").strip()
|
| 52 |
|
| 53 |
-
|
| 54 |
|
| 55 |
-
return ans
|
|
|
|
| 4 |
|
| 5 |
import streamlit as st
|
| 6 |
import openai
|
| 7 |
+
import logging
|
| 8 |
+
|
| 9 |
+
logger = logging.getLogger(__name__)
|
| 10 |
|
| 11 |
|
| 12 |
def get_prompt():
|
|
|
|
| 53 |
|
| 54 |
ans = response["choices"][0]["text"].replace("Risposta:", "").strip()
|
| 55 |
|
| 56 |
+
logger.info(f"Q: {input} - A: {ans}")
|
| 57 |
|
| 58 |
+
return ans
|