Upload folder using huggingface_hub
Browse files- advanced_rag.py +16 -5
advanced_rag.py
CHANGED
|
@@ -454,15 +454,26 @@ class ElevatedRagChain:
|
|
| 454 |
debug_print("Mistral client library not installed. Falling back to Llama pipeline.")
|
| 455 |
normalized = "llama"
|
| 456 |
if normalized != "llama":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 457 |
class MistralLLM(LLM):
|
| 458 |
temperature: float = 0.7
|
| 459 |
top_p: float = 0.95
|
| 460 |
-
_client: Any = None
|
|
|
|
| 461 |
def __init__(self, api_key: str, temperature: float = 0.7, top_p: float = 0.95, **kwargs: Any):
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 466 |
@property
|
| 467 |
def _llm_type(self) -> str:
|
| 468 |
return "mistral_llm"
|
|
|
|
| 454 |
debug_print("Mistral client library not installed. Falling back to Llama pipeline.")
|
| 455 |
normalized = "llama"
|
| 456 |
if normalized != "llama":
|
| 457 |
+
from pydantic import PrivateAttr
|
| 458 |
+
# from langchain.llms.base import LLM
|
| 459 |
+
# from typing import Any, Optional, List
|
| 460 |
+
# import typing
|
| 461 |
+
|
| 462 |
class MistralLLM(LLM):
|
| 463 |
temperature: float = 0.7
|
| 464 |
top_p: float = 0.95
|
| 465 |
+
_client: Any = PrivateAttr(default=None)
|
| 466 |
+
|
| 467 |
def __init__(self, api_key: str, temperature: float = 0.7, top_p: float = 0.95, **kwargs: Any):
|
| 468 |
+
try:
|
| 469 |
+
super().__init__(**kwargs)
|
| 470 |
+
# Bypass Pydantic's __setattr__ to assign to _client
|
| 471 |
+
object.__setattr__(self, '_client', Mistral(api_key=api_key))
|
| 472 |
+
self.temperature = temperature
|
| 473 |
+
self.top_p = top_p
|
| 474 |
+
except Exception as e:
|
| 475 |
+
debug_print(f"Init Mistral failed with error: {e}")
|
| 476 |
+
|
| 477 |
@property
|
| 478 |
def _llm_type(self) -> str:
|
| 479 |
return "mistral_llm"
|