Spaces:
Sleeping
Sleeping
update again
Browse files
app.py
CHANGED
@@ -56,22 +56,42 @@ def load_model():
|
|
56 |
return model, llm, index
|
57 |
|
58 |
|
59 |
-
st.title("Please ask your question on Lithuanian rules for foreigners.")
|
60 |
model,llm, index = load_model()
|
61 |
|
62 |
-
question = st.text_input("Enter your question:")
|
63 |
|
64 |
-
if question != "":
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
st.header("Answer:")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
return model, llm, index
|
57 |
|
58 |
|
59 |
+
# st.title("Please ask your question on Lithuanian rules for foreigners.")
|
60 |
model,llm, index = load_model()
|
61 |
|
62 |
+
# question = st.text_input("Enter your question:")
|
63 |
|
64 |
+
# if question != "":
|
65 |
+
# query = model.create_embedding(question)
|
66 |
+
# st.write(query)
|
67 |
+
# q = query['data'][0]['embedding']
|
68 |
|
69 |
+
# response = index.query(
|
70 |
+
# vector=q,
|
71 |
+
# top_k=1,
|
72 |
+
# include_metadata = True,
|
73 |
+
# namespace = "ns1"
|
74 |
+
# )
|
75 |
+
# response_t = response['matches'][0]['metadata']['text']
|
76 |
+
# st.write(response_t)
|
77 |
+
st.header("Answer:")
|
78 |
+
def handle_question():
|
79 |
+
question = st.text_input("Enter your question:")
|
80 |
+
if question != "":
|
81 |
+
# ... (Your query and response logic)
|
82 |
+
query = model.create_embedding(question)
|
83 |
+
# st.write(query)
|
84 |
+
q = query['data'][0]['embedding']
|
85 |
+
|
86 |
+
response = index.query(
|
87 |
+
vector=q,
|
88 |
+
top_k=1,
|
89 |
+
include_metadata = True,
|
90 |
+
namespace = "ns1"
|
91 |
+
)
|
92 |
+
response_t = response['matches'][0]['metadata']['text']
|
93 |
+
st.write(response_t)
|
94 |
+
|
95 |
+
# Use a button to trigger handling of the question
|
96 |
+
if st.button("Submit Question"):
|
97 |
+
handle_question()
|