Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -43,4 +43,40 @@ def provide_advice(table_data: pd.DataFrame, hs_code: str, year: str, month: str
|
|
43 |
)
|
44 |
try:
|
45 |
outputs = client.text_generation(
|
46 |
-
prompt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
)
|
44 |
try:
|
45 |
outputs = client.text_generation(
|
46 |
+
prompt=prompt,
|
47 |
+
model="mistralai/Mixtral-8x7B-Instruct-v0.1",
|
48 |
+
max_new_tokens=256
|
49 |
+
)
|
50 |
+
return outputs
|
51 |
+
except Exception as e:
|
52 |
+
return f"خطا در تولید مشاوره: {str(e)}"
|
53 |
+
|
54 |
+
current_year = pd.Timestamp.now().year
|
55 |
+
years = [str(y) for y in range(2000, current_year+1)]
|
56 |
+
months = [str(m) for m in range(1, 13)]
|
57 |
+
|
58 |
+
with gr.Blocks() as demo:
|
59 |
+
gr.Markdown("## نمایش کشورهایی که یک کالا را وارد کردهاند")
|
60 |
+
with gr.Row():
|
61 |
+
inp_hs = gr.Textbox(label="HS Code")
|
62 |
+
inp_year = gr.Dropdown(choices=years, label="سال", value=str(current_year))
|
63 |
+
inp_month = gr.Dropdown(choices=months, label="ماه", value=str(pd.Timestamp.now().month))
|
64 |
+
btn_show = gr.Button("نمایش اطلاعات")
|
65 |
+
out_table = gr.Dataframe(
|
66 |
+
headers=["کد کشور", "نام کشور", "ارزش CIF"],
|
67 |
+
datatype=["number", "text", "number"],
|
68 |
+
interactive=True,
|
69 |
+
)
|
70 |
+
btn_show.click(get_importers, [inp_hs, inp_year, inp_month], out_table)
|
71 |
+
|
72 |
+
btn_advice = gr.Button("ارائه مشاوره تخصصی")
|
73 |
+
out_advice = gr.Textbox(label="مشاوره تخصصی", lines=6)
|
74 |
+
|
75 |
+
btn_advice.click(
|
76 |
+
provide_advice,
|
77 |
+
inputs=[out_table, inp_hs, inp_year, inp_month],
|
78 |
+
outputs=out_advice
|
79 |
+
)
|
80 |
+
|
81 |
+
if __name__ == "__main__":
|
82 |
+
demo.launch()
|