diginoron commited on
Commit
2f84711
·
verified ·
1 Parent(s): 0e8609b

Update app.py

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