Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
from langchain.chat_models import ChatOpenAI
|
3 |
from langchain.schema import HumanMessage
|
@@ -42,19 +43,18 @@ def generate_report(operation_data, max_tokens, temperature, top_p):
|
|
42 |
✅ این گزارش بر اساس اطلاعات خام ارائهشده تولید شده و ممکن است برخی جزئیات در دسترس نبوده باشند.
|
43 |
"""
|
44 |
|
45 |
-
|
46 |
messages = [
|
47 |
HumanMessage(content=f"{system_prompt}\n\n{operation_data}")
|
48 |
]
|
49 |
|
50 |
-
# ارسال پیام به مدل و گرفتن پاسخ
|
51 |
response = llm(messages)
|
52 |
|
53 |
-
# ذخیره گزارش در یک فایل متنی
|
54 |
with open("report.txt", "w", encoding="utf-8") as file:
|
55 |
file.write(response.content)
|
56 |
|
57 |
-
return response.content, "report.txt"
|
|
|
58 |
|
59 |
demo = gr.Interface(
|
60 |
fn=generate_report,
|
@@ -69,16 +69,13 @@ demo = gr.Interface(
|
|
69 |
gr.Slider(0.1, 1.5, value=0.7, step=0.1, label="🔥 دمای خلاقیت (temperature)", elem_id="slider-2"),
|
70 |
gr.Slider(0.1, 1.0, value=0.95, step=0.05, label="🎯 Top-p", elem_id="slider-3"),
|
71 |
],
|
72 |
-
outputs=
|
73 |
-
gr.Textbox(label="📄 گزارش رسمی تولید شده", lines=10, elem_id="military-output"),
|
74 |
-
gr.File(label=" دانلود گزارش", elem_id="download-btn") # اضافه کردن دکمه دانلود
|
75 |
-
],
|
76 |
title="🛰️ سامانه گزارشساز هوش مصنوعی «توانا»",
|
77 |
description="🔰 اطلاعات خام عملیات را وارد کن تا سامانه توانا یک گزارش رسمی، حرفهای و محرمانه تولید کند.",
|
78 |
css="""
|
79 |
body {
|
80 |
-
background-color: #d9dec5 !important;
|
81 |
-
color: #1e293b !important;
|
82 |
font-family: 'Vazir', sans-serif;
|
83 |
direction: rtl;
|
84 |
}
|
@@ -87,16 +84,16 @@ demo = gr.Interface(
|
|
87 |
}
|
88 |
label {
|
89 |
font-size: 22px !important;
|
90 |
-
color: #eeeeee !important;
|
91 |
font-weight: bold;
|
92 |
}
|
93 |
#military-input textarea, #military-output textarea {
|
94 |
background-color: #d9dec5 !important;
|
95 |
color: #1e293b !important;
|
96 |
-
border: 2px solid #529b39 !important;
|
97 |
}
|
98 |
.gr-button {
|
99 |
-
background-color: #529b39 !important;
|
100 |
color: #eeeeee !important;
|
101 |
border-radius: 12px;
|
102 |
font-size: 18px;
|
@@ -104,26 +101,26 @@ demo = gr.Interface(
|
|
104 |
transition: all 0.3s ease;
|
105 |
}
|
106 |
.gr-button:hover {
|
107 |
-
background-color: #45a12d !important;
|
108 |
transform: scale(1.05);
|
109 |
}
|
110 |
.gr-button:active {
|
111 |
-
background-color: #3b8e27 !important;
|
112 |
}
|
113 |
.gr-button[type="submit"] {
|
114 |
-
background-color: #529b39 !important;
|
115 |
}
|
116 |
.gr-button[type="reset"] {
|
117 |
-
background-color: #ff7043 !important;
|
118 |
}
|
119 |
.gradio-footer {
|
120 |
display: none !important;
|
121 |
}
|
122 |
|
123 |
.gr-textbox input[type="text"], .gr-textbox textarea {
|
124 |
-
background-color: #1e293b !important;
|
125 |
-
color: #eeeeee !important;
|
126 |
-
border: 2px solid #529b39 !important;
|
127 |
font-size: 16px;
|
128 |
}
|
129 |
.gr-textbox input[type="text"]:focus, .gr-textbox textarea:focus {
|
@@ -134,7 +131,6 @@ demo = gr.Interface(
|
|
134 |
submit_btn="🎯 تولید گزارش",
|
135 |
clear_btn="🗑️ پاک کردن"
|
136 |
)
|
137 |
-
|
138 |
demo.launch()
|
139 |
|
140 |
if __name__ == "__main__":
|
|
|
1 |
+
|
2 |
import gradio as gr
|
3 |
from langchain.chat_models import ChatOpenAI
|
4 |
from langchain.schema import HumanMessage
|
|
|
43 |
✅ این گزارش بر اساس اطلاعات خام ارائهشده تولید شده و ممکن است برخی جزئیات در دسترس نبوده باشند.
|
44 |
"""
|
45 |
|
46 |
+
|
47 |
messages = [
|
48 |
HumanMessage(content=f"{system_prompt}\n\n{operation_data}")
|
49 |
]
|
50 |
|
|
|
51 |
response = llm(messages)
|
52 |
|
|
|
53 |
with open("report.txt", "w", encoding="utf-8") as file:
|
54 |
file.write(response.content)
|
55 |
|
56 |
+
return response.content, "report.txt"
|
57 |
+
|
58 |
|
59 |
demo = gr.Interface(
|
60 |
fn=generate_report,
|
|
|
69 |
gr.Slider(0.1, 1.5, value=0.7, step=0.1, label="🔥 دمای خلاقیت (temperature)", elem_id="slider-2"),
|
70 |
gr.Slider(0.1, 1.0, value=0.95, step=0.05, label="🎯 Top-p", elem_id="slider-3"),
|
71 |
],
|
72 |
+
outputs=gr.Textbox(label="📄 گزارش رسمی تولید شده", lines=10, elem_id="military-output"),
|
|
|
|
|
|
|
73 |
title="🛰️ سامانه گزارشساز هوش مصنوعی «توانا»",
|
74 |
description="🔰 اطلاعات خام عملیات را وارد کن تا سامانه توانا یک گزارش رسمی، حرفهای و محرمانه تولید کند.",
|
75 |
css="""
|
76 |
body {
|
77 |
+
background-color: #d9dec5 !important;
|
78 |
+
color: #1e293b !important;
|
79 |
font-family: 'Vazir', sans-serif;
|
80 |
direction: rtl;
|
81 |
}
|
|
|
84 |
}
|
85 |
label {
|
86 |
font-size: 22px !important;
|
87 |
+
color: #eeeeee !important;
|
88 |
font-weight: bold;
|
89 |
}
|
90 |
#military-input textarea, #military-output textarea {
|
91 |
background-color: #d9dec5 !important;
|
92 |
color: #1e293b !important;
|
93 |
+
border: 2px solid #529b39 !important;
|
94 |
}
|
95 |
.gr-button {
|
96 |
+
background-color: #529b39 !important;
|
97 |
color: #eeeeee !important;
|
98 |
border-radius: 12px;
|
99 |
font-size: 18px;
|
|
|
101 |
transition: all 0.3s ease;
|
102 |
}
|
103 |
.gr-button:hover {
|
104 |
+
background-color: #45a12d !important;
|
105 |
transform: scale(1.05);
|
106 |
}
|
107 |
.gr-button:active {
|
108 |
+
background-color: #3b8e27 !important;
|
109 |
}
|
110 |
.gr-button[type="submit"] {
|
111 |
+
background-color: #529b39 !important;
|
112 |
}
|
113 |
.gr-button[type="reset"] {
|
114 |
+
background-color: #ff7043 !important;
|
115 |
}
|
116 |
.gradio-footer {
|
117 |
display: none !important;
|
118 |
}
|
119 |
|
120 |
.gr-textbox input[type="text"], .gr-textbox textarea {
|
121 |
+
background-color: #1e293b !important;
|
122 |
+
color: #eeeeee !important;
|
123 |
+
border: 2px solid #529b39 !important;
|
124 |
font-size: 16px;
|
125 |
}
|
126 |
.gr-textbox input[type="text"]:focus, .gr-textbox textarea:focus {
|
|
|
131 |
submit_btn="🎯 تولید گزارش",
|
132 |
clear_btn="🗑️ پاک کردن"
|
133 |
)
|
|
|
134 |
demo.launch()
|
135 |
|
136 |
if __name__ == "__main__":
|