alx-d commited on
Commit
71ab05d
·
verified ·
1 Parent(s): 3fac86a

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. advanced_rag.py +8 -9
advanced_rag.py CHANGED
@@ -196,19 +196,18 @@ class ElevatedRagChain:
196
  class MistralLLM(LLM):
197
  temperature: float = 0.7
198
  top_p: float = 0.95
199
- _client: Any = PrivateAttr(default=None) # Set default to None
200
-
201
  def __init__(self, api_key: str, temperature: float = 0.7, top_p: float = 0.95, **kwargs: Any):
202
- # Do not pass api_key to super().__init__ since it's not a field
203
- super().__init__(**kwargs)
204
  self._client = Mistral(api_key=api_key)
205
- self.temperature = temperature
206
- self.top_p = top_p
207
-
208
  @property
209
  def _llm_type(self) -> str:
210
  return "mistral_llm"
211
-
212
  def _call(self, prompt: str, stop: Optional[List[str]] = None) -> str:
213
  response = self._client.chat.complete(
214
  model="mistral-small-latest",
@@ -218,7 +217,7 @@ class ElevatedRagChain:
218
  max_tokens=32000
219
  )
220
  return response.choices[0].message.content
221
-
222
  @property
223
  def _identifying_params(self) -> dict:
224
  return {"model": "mistral-small-latest"}
 
196
  class MistralLLM(LLM):
197
  temperature: float = 0.7
198
  top_p: float = 0.95
199
+ _client: Any = PrivateAttr() # Remove the default=None here
200
+
201
  def __init__(self, api_key: str, temperature: float = 0.7, top_p: float = 0.95, **kwargs: Any):
202
+ # Initialize the private attributes before calling super().__init__
 
203
  self._client = Mistral(api_key=api_key)
204
+ # Now call super().__init__
205
+ super().__init__(temperature=temperature, top_p=top_p, **kwargs)
206
+
207
  @property
208
  def _llm_type(self) -> str:
209
  return "mistral_llm"
210
+
211
  def _call(self, prompt: str, stop: Optional[List[str]] = None) -> str:
212
  response = self._client.chat.complete(
213
  model="mistral-small-latest",
 
217
  max_tokens=32000
218
  )
219
  return response.choices[0].message.content
220
+
221
  @property
222
  def _identifying_params(self) -> dict:
223
  return {"model": "mistral-small-latest"}