Spaces:
Running
Running
Update app.py
Browse files
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
|
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
|
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=
|
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)
|