Spaces:
Sleeping
Sleeping
Update analytics/ai_assistant.py
Browse files
analytics/ai_assistant.py
CHANGED
|
@@ -126,7 +126,7 @@ def _get_inference_client():
|
|
| 126 |
"HUGGINGFACE_API_TOKEN is required for AI assistant. "
|
| 127 |
"Set it in your environment before running the app."
|
| 128 |
)
|
| 129 |
-
return InferenceClient(
|
| 130 |
|
| 131 |
|
| 132 |
def generate_ai_answer(question: str, df: pd.DataFrame, as_of_month: str = None, segment: str = None):
|
|
@@ -141,11 +141,13 @@ def generate_ai_answer(question: str, df: pd.DataFrame, as_of_month: str = None,
|
|
| 141 |
)
|
| 142 |
|
| 143 |
client = _get_inference_client()
|
| 144 |
-
response = client.text_generation(
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
|
| 149 |
})
|
| 150 |
|
| 151 |
if isinstance(response, dict):
|
|
|
|
| 126 |
"HUGGINGFACE_API_TOKEN is required for AI assistant. "
|
| 127 |
"Set it in your environment before running the app."
|
| 128 |
)
|
| 129 |
+
return InferenceClient(token=HF_TOKEN)
|
| 130 |
|
| 131 |
|
| 132 |
def generate_ai_answer(question: str, df: pd.DataFrame, as_of_month: str = None, segment: str = None):
|
|
|
|
| 141 |
)
|
| 142 |
|
| 143 |
client = _get_inference_client()
|
| 144 |
+
response = client.text_generation(
|
| 145 |
+
model=HF_MODEL_ID,
|
| 146 |
+
prompt,
|
| 147 |
+
max_new_tokens= HF_MAX_TOKENS,
|
| 148 |
+
temperature= HF_TEMPERATURE,
|
| 149 |
+
top_k= 50,
|
| 150 |
+
top_p= 0.95,
|
| 151 |
})
|
| 152 |
|
| 153 |
if isinstance(response, dict):
|