diginoron commited on
Commit
b975240
·
verified ·
1 Parent(s): ebd075f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
3
  import pandas as pd
4
  import comtradeapicall
5
  from huggingface_hub import InferenceClient
6
- from deep_translator import GoogleTranslator # جایگزین googletrans
7
 
8
  # کلید COMTRADE
9
  subscription_key = os.getenv("COMTRADE_API_KEY", "")
@@ -11,7 +11,7 @@ subscription_key = os.getenv("COMTRADE_API_KEY", "")
11
  hf_token = os.getenv("HF_API_TOKEN")
12
 
13
  client = InferenceClient(token=hf_token)
14
- translator = GoogleTranslator(source='en', target='fa') # مترجم انگلیسی به فارسی
15
 
16
  def get_importers(hs_code: str, year: str, month: str):
17
  period = f"{year}{int(month):02d}"
@@ -41,7 +41,7 @@ def provide_advice(table_data: pd.DataFrame, hs_code: str, year: str, month: str
41
  prompt = (
42
  f"The following table shows countries that imported a product with HS code {hs_code} during the period {period}:\n"
43
  f"{table_str}\n\n"
44
- f"Please provide a detailed analysis in two complete paragraphs. The first paragraph should discuss the market opportunities and potential demand for this product in these countries. The second paragraph should offer strategic recommendations for exporters targeting these markets, focusing on trade strategies and risk management."
45
  )
46
  print("پرامپت ساخته‌شده:")
47
  print(prompt)
@@ -50,7 +50,7 @@ def provide_advice(table_data: pd.DataFrame, hs_code: str, year: str, month: str
50
  outputs = client.text_generation(
51
  prompt=prompt,
52
  model="mistralai/Mixtral-8x7B-Instruct-v0.1",
53
- max_new_tokens=512
54
  )
55
  print("خروجی مدل دریافت شد (به انگلیسی):")
56
  print(outputs)
 
3
  import pandas as pd
4
  import comtradeapicall
5
  from huggingface_hub import InferenceClient
6
+ from deep_translator import GoogleTranslator
7
 
8
  # کلید COMTRADE
9
  subscription_key = os.getenv("COMTRADE_API_KEY", "")
 
11
  hf_token = os.getenv("HF_API_TOKEN")
12
 
13
  client = InferenceClient(token=hf_token)
14
+ translator = GoogleTranslator(source='en', target='fa')
15
 
16
  def get_importers(hs_code: str, year: str, month: str):
17
  period = f"{year}{int(month):02d}"
 
41
  prompt = (
42
  f"The following table shows countries that imported a product with HS code {hs_code} during the period {period}:\n"
43
  f"{table_str}\n\n"
44
+ f"Please provide a detailed and comprehensive analysis in two paragraphs. The first paragraph should discuss market opportunities, potential demand, and specific cultural or economic factors influencing the demand for this product in these countries. The second paragraph should offer actionable strategic recommendations for exporters, including detailed trade strategies, risk management techniques, and steps to establish local partnerships."
45
  )
46
  print("پرامپت ساخته‌شده:")
47
  print(prompt)
 
50
  outputs = client.text_generation(
51
  prompt=prompt,
52
  model="mistralai/Mixtral-8x7B-Instruct-v0.1",
53
+ max_new_tokens=1024 # افزایش برای تکمیل جملات
54
  )
55
  print("خروجی مدل دریافت شد (به انگلیسی):")
56
  print(outputs)