Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,6 @@ import gradio as gr
|
|
2 |
from langchain.chat_models import ChatOpenAI
|
3 |
from langchain.schema import HumanMessage
|
4 |
|
5 |
-
# مدل LLaMA-3 از طریق Together API
|
6 |
llm = ChatOpenAI(
|
7 |
base_url="https://api.together.xyz/v1",
|
8 |
api_key="0291f33aee03412a47fa5d8e562e515182dcc5d9aac5a7fb5eefdd1759005979",
|
@@ -10,7 +9,6 @@ llm = ChatOpenAI(
|
|
10 |
max_tokens=1024
|
11 |
)
|
12 |
|
13 |
-
# تابع تولید گزارش
|
14 |
def generate_report(operation_data, max_tokens, temperature, top_p):
|
15 |
system_prompt = """تو یک افسر گزارشنویس نظامی هستی. وظیفه تو تهیه یک گزارش رسمی، دقیق، ساختاریافته و حرفهای از عملیات نظامی بر اساس دادههای ارائهشده است. اگر اطلاعاتی در متن وجود نداشت، صراحتاً بنویس «ذکر نشده است».
|
16 |
لطفاً گزارش را دقیقاً در قالب فرمتیافته زیر تولید کن، با استفاده از نشانهگذاری واضح (مانند ایموجیها و خطوط جداکننده) تا خروجی قابلخواندن و رسمی باشد:
|
@@ -42,7 +40,6 @@ 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 |
]
|
@@ -69,12 +66,12 @@ demo = gr.Interface(
|
|
69 |
outputs=[
|
70 |
gr.Textbox(label="📄 گزارش رسمی تولید شده", lines=10, elem_id="military-output")
|
71 |
],
|
72 |
-
title="🛰️ سامانه گزارشساز
|
73 |
-
description="🔰 اطلاعات خام عملیات را وارد
|
74 |
css="""
|
75 |
body {
|
76 |
-
background-color: #d9dec5 !important;
|
77 |
-
color: #1e293b !important;
|
78 |
font-family: 'Vazir', sans-serif;
|
79 |
direction: rtl;
|
80 |
}
|
@@ -83,16 +80,16 @@ demo = gr.Interface(
|
|
83 |
}
|
84 |
label {
|
85 |
font-size: 22px !important;
|
86 |
-
color: #eeeeee !important;
|
87 |
font-weight: bold;
|
88 |
}
|
89 |
#military-input textarea, #military-output textarea {
|
90 |
background-color: #d9dec5 !important;
|
91 |
color: #1e293b !important;
|
92 |
-
border: 2px solid #529b39 !important;
|
93 |
}
|
94 |
.gr-button {
|
95 |
-
background-color: #529b39 !important;
|
96 |
color: #eeeeee !important;
|
97 |
border-radius: 12px;
|
98 |
font-size: 18px;
|
@@ -100,26 +97,26 @@ demo = gr.Interface(
|
|
100 |
transition: all 0.3s ease;
|
101 |
}
|
102 |
.gr-button:hover {
|
103 |
-
background-color: #45a12d !important;
|
104 |
transform: scale(1.05);
|
105 |
}
|
106 |
.gr-button:active {
|
107 |
-
background-color: #3b8e27 !important;
|
108 |
}
|
109 |
.gr-button[type="submit"] {
|
110 |
-
background-color: #529b39 !important;
|
111 |
}
|
112 |
.gr-button[type="reset"] {
|
113 |
-
background-color: #ff7043 !important;
|
114 |
}
|
115 |
.gradio-footer {
|
116 |
display: none !important;
|
117 |
}
|
118 |
|
119 |
.gr-textbox input[type="text"], .gr-textbox textarea {
|
120 |
-
background-color: #1e293b !important;
|
121 |
-
color: #eeeeee !important;
|
122 |
-
border: 2px solid #529b39 !important;
|
123 |
font-size: 16px;
|
124 |
}
|
125 |
.gr-textbox input[type="text"]:focus, .gr-textbox textarea:focus {
|
|
|
2 |
from langchain.chat_models import ChatOpenAI
|
3 |
from langchain.schema import HumanMessage
|
4 |
|
|
|
5 |
llm = ChatOpenAI(
|
6 |
base_url="https://api.together.xyz/v1",
|
7 |
api_key="0291f33aee03412a47fa5d8e562e515182dcc5d9aac5a7fb5eefdd1759005979",
|
|
|
9 |
max_tokens=1024
|
10 |
)
|
11 |
|
|
|
12 |
def generate_report(operation_data, max_tokens, temperature, top_p):
|
13 |
system_prompt = """تو یک افسر گزارشنویس نظامی هستی. وظیفه تو تهیه یک گزارش رسمی، دقیق، ساختاریافته و حرفهای از عملیات نظامی بر اساس دادههای ارائهشده است. اگر اطلاعاتی در متن وجود نداشت، صراحتاً بنویس «ذکر نشده است».
|
14 |
لطفاً گزارش را دقیقاً در قالب فرمتیافته زیر تولید کن، با استفاده از نشانهگذاری واضح (مانند ایموجیها و خطوط جداکننده) تا خروجی قابلخواندن و رسمی باشد:
|
|
|
40 |
✅ این گزارش بر اساس اطلاعات خام ارائهشده تولید شده و ممکن است برخی جزئیات در دسترس نبوده باشند.
|
41 |
"""
|
42 |
|
|
|
43 |
messages = [
|
44 |
HumanMessage(content=f"{system_prompt}\n\n{operation_data}")
|
45 |
]
|
|
|
66 |
outputs=[
|
67 |
gr.Textbox(label="📄 گزارش رسمی تولید شده", lines=10, elem_id="military-output")
|
68 |
],
|
69 |
+
title="🛰️ سامانه گزارشساز رزم یار»",
|
70 |
+
description="🔰 اطلاعات خام عملیات را وارد کنید تا سامانه یک گزارش رسمی تولید کند.",
|
71 |
css="""
|
72 |
body {
|
73 |
+
background-color: #d9dec5 !important;
|
74 |
+
color: #1e293b !important;
|
75 |
font-family: 'Vazir', sans-serif;
|
76 |
direction: rtl;
|
77 |
}
|
|
|
80 |
}
|
81 |
label {
|
82 |
font-size: 22px !important;
|
83 |
+
color: #eeeeee !important;
|
84 |
font-weight: bold;
|
85 |
}
|
86 |
#military-input textarea, #military-output textarea {
|
87 |
background-color: #d9dec5 !important;
|
88 |
color: #1e293b !important;
|
89 |
+
border: 2px solid #529b39 !important;
|
90 |
}
|
91 |
.gr-button {
|
92 |
+
background-color: #529b39 !important;
|
93 |
color: #eeeeee !important;
|
94 |
border-radius: 12px;
|
95 |
font-size: 18px;
|
|
|
97 |
transition: all 0.3s ease;
|
98 |
}
|
99 |
.gr-button:hover {
|
100 |
+
background-color: #45a12d !important;
|
101 |
transform: scale(1.05);
|
102 |
}
|
103 |
.gr-button:active {
|
104 |
+
background-color: #3b8e27 !important;
|
105 |
}
|
106 |
.gr-button[type="submit"] {
|
107 |
+
background-color: #529b39 !important;
|
108 |
}
|
109 |
.gr-button[type="reset"] {
|
110 |
+
background-color: #ff7043 !important;
|
111 |
}
|
112 |
.gradio-footer {
|
113 |
display: none !important;
|
114 |
}
|
115 |
|
116 |
.gr-textbox input[type="text"], .gr-textbox textarea {
|
117 |
+
background-color: #1e293b !important;
|
118 |
+
color: #eeeeee !important;
|
119 |
+
border: 2px solid #529b39 !important;
|
120 |
font-size: 16px;
|
121 |
}
|
122 |
.gr-textbox input[type="text"]:focus, .gr-textbox textarea:focus {
|