Really-amin commited on
Commit
dd5083c
·
verified ·
1 Parent(s): c1ef16d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -18
app.py CHANGED
@@ -14,8 +14,6 @@ model = load_model()
14
  # اپلیکیشن Streamlit
15
  def main():
16
  st.set_page_config(page_title="دستیار هوش مصنوعی", layout="wide")
17
-
18
- # عنوان برنامه
19
  st.title("دستیار هوش مصنوعی پیشرفته")
20
 
21
  # نمایش فایل HTML
@@ -23,22 +21,14 @@ def main():
23
  html_content = html_file.read()
24
  st.components.v1.html(html_content, height=800, scrolling=True)
25
 
26
- # مدیریت پیام‌های دریافتی از جاوااسکریپت
27
- if "messages" not in st.session_state:
28
- st.session_state["messages"] = []
29
-
30
- message = st.text_input("پیام ورودی از جاوااسکریپت:")
31
- if message:
32
- st.session_state["messages"].append({"user": message})
33
- response = model(message, max_length=50, num_return_sequences=1)[0]["generated_text"]
34
- st.session_state["messages"].append({"assistant": response})
35
-
36
- # نمایش پیام‌ها
37
- for msg in st.session_state["messages"]:
38
- if "user" in msg:
39
- st.write(f"شما: {msg['user']}")
40
- elif "assistant" in msg:
41
- st.write(f"دستیار: {msg['assistant']}")
42
 
43
  if __name__ == "__main__":
44
  main()
 
14
  # اپلیکیشن Streamlit
15
  def main():
16
  st.set_page_config(page_title="دستیار هوش مصنوعی", layout="wide")
 
 
17
  st.title("دستیار هوش مصنوعی پیشرفته")
18
 
19
  # نمایش فایل HTML
 
21
  html_content = html_file.read()
22
  st.components.v1.html(html_content, height=800, scrolling=True)
23
 
24
+ # مدیریت درخواست‌های API
25
+ st.subheader("مدیریت درخواست‌ها")
26
+ input_data = st.text_input("پیام دریافتی (برای تست):", "")
27
+ if st.button("تست"):
28
+ if input_data.strip():
29
+ st.write("پیام دریافتی:", input_data)
30
+ response = model(input_data, max_length=50, num_return_sequences=1)
31
+ st.write("پاسخ مدل:", response[0]["generated_text"])
 
 
 
 
 
 
 
 
32
 
33
  if __name__ == "__main__":
34
  main()