Spaces:
Build error
Build error
Update mistral_api.py
Browse files- mistral_api.py +2 -2
mistral_api.py
CHANGED
|
@@ -20,7 +20,7 @@ def get_embedding(text: str, model: str=EMBEDDING_MODEL) -> list[float]:
|
|
| 20 |
return result.data[0].embedding
|
| 21 |
|
| 22 |
# Initialize the mistral client using HuggingFace's Inference Client
|
| 23 |
-
client = InferenceClient("mistralai/Mistral-Small-24B-Instruct-2501"
|
| 24 |
|
| 25 |
def get_response(messages: list[dict], temperature=0, max_tokens=800) -> str:
|
| 26 |
"""Chat completion using HuggingFace's Inference API."""
|
|
@@ -31,7 +31,7 @@ def get_response(messages: list[dict], temperature=0, max_tokens=800) -> str:
|
|
| 31 |
# stream=True # Enables streaming
|
| 32 |
)
|
| 33 |
print(response)
|
| 34 |
-
return
|
| 35 |
|
| 36 |
# def get_response(message, system_message=META_PROMPT, max_tokens=800, temperature=0) -> str:
|
| 37 |
# """Chat completion using HuggingFace's Inference API"""
|
|
|
|
| 20 |
return result.data[0].embedding
|
| 21 |
|
| 22 |
# Initialize the mistral client using HuggingFace's Inference Client
|
| 23 |
+
client = InferenceClient("mistralai/Mistral-Small-24B-Instruct-2501", token=os.getenv("HF_TOKEn"))
|
| 24 |
|
| 25 |
def get_response(messages: list[dict], temperature=0, max_tokens=800) -> str:
|
| 26 |
"""Chat completion using HuggingFace's Inference API."""
|
|
|
|
| 31 |
# stream=True # Enables streaming
|
| 32 |
)
|
| 33 |
print(response)
|
| 34 |
+
return response["choices"][0]["message"]["content"]
|
| 35 |
|
| 36 |
# def get_response(message, system_message=META_PROMPT, max_tokens=800, temperature=0) -> str:
|
| 37 |
# """Chat completion using HuggingFace's Inference API"""
|