Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -19,17 +19,18 @@ def main():
|
|
19 |
st.set_page_config(page_title="AI Assistant", layout="wide")
|
20 |
st.title("دستیار هوش مصنوعی پیشرفته")
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
# نمایش HTML
|
23 |
with open("index.html", "r", encoding="utf-8") as file:
|
24 |
html_content = file.read()
|
25 |
st.components.v1.html(html_content, height=700, scrolling=True)
|
26 |
|
27 |
-
# مدیریت پیامهای دریافتی
|
28 |
-
if "message" in st.experimental_get_query_params():
|
29 |
-
user_input = st.experimental_get_query_params()["message"][0]
|
30 |
-
if user_input:
|
31 |
-
response = generate_response(user_input)
|
32 |
-
st.experimental_set_query_params(response=response)
|
33 |
-
|
34 |
if __name__ == "__main__":
|
35 |
main()
|
|
|
19 |
st.set_page_config(page_title="AI Assistant", layout="wide")
|
20 |
st.title("دستیار هوش مصنوعی پیشرفته")
|
21 |
|
22 |
+
# مدیریت درخواستها از طریق fetch
|
23 |
+
if st.experimental_get_query_params().get("fetch") == ["true"]:
|
24 |
+
import json
|
25 |
+
st.write("content-type: application/json")
|
26 |
+
st.write(
|
27 |
+
json.dumps({"response": generate_response(st.experimental_get_query_params()["message"][0])})
|
28 |
+
)
|
29 |
+
|
30 |
# نمایش HTML
|
31 |
with open("index.html", "r", encoding="utf-8") as file:
|
32 |
html_content = file.read()
|
33 |
st.components.v1.html(html_content, height=700, scrolling=True)
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
if __name__ == "__main__":
|
36 |
main()
|