Spaces:
Sleeping
Sleeping
Update analytics/ai_assistant.py
Browse files- analytics/ai_assistant.py +17 -5
analytics/ai_assistant.py
CHANGED
|
@@ -144,14 +144,26 @@ def generate_ai_answer(question: str, df: pd.DataFrame, as_of_month: str = None,
|
|
| 144 |
|
| 145 |
client = _get_inference_client()
|
| 146 |
print("Inference called successfully")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
response = client.chat.completions.create(
|
| 148 |
model=HF_MODEL_ID,
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
temperature=
|
| 152 |
-
|
| 153 |
-
top_p= 0.95
|
| 154 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
print(response)
|
| 156 |
|
| 157 |
if isinstance(response, dict):
|
|
|
|
| 144 |
|
| 145 |
client = _get_inference_client()
|
| 146 |
print("Inference called successfully")
|
| 147 |
+
# 1. Format your prompt into OpenAI message style
|
| 148 |
+
messages = [{"role": "user", "content": prompt}]
|
| 149 |
+
print(messages)
|
| 150 |
+
|
| 151 |
+
|
| 152 |
response = client.chat.completions.create(
|
| 153 |
model=HF_MODEL_ID,
|
| 154 |
+
messages=messages, # Changed from prompt
|
| 155 |
+
max_tokens=HF_MAX_TOKENS, # Changed from max_new_tokens
|
| 156 |
+
temperature=HF_TEMPERATURE,
|
| 157 |
+
top_p=0.95
|
|
|
|
| 158 |
)
|
| 159 |
+
#response = client.chat.completions.create(
|
| 160 |
+
# model=HF_MODEL_ID,
|
| 161 |
+
# prompt = prompt,
|
| 162 |
+
# max_new_tokens= HF_MAX_TOKENS,
|
| 163 |
+
# temperature= HF_TEMPERATURE,
|
| 164 |
+
# top_k= 50,
|
| 165 |
+
# top_p= 0.95
|
| 166 |
+
#)
|
| 167 |
print(response)
|
| 168 |
|
| 169 |
if isinstance(response, dict):
|