MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / run

Method run

camel/models/mistral_model.py:215–252  ·  view source on GitHub ↗

r"""Runs inference of Mistral chat completion. Args: messages (List[OpenAIMessage]): Message list with the chat history in OpenAI API format. Returns: ChatCompletion.

(
        self,
        messages: List[OpenAIMessage],
    )

Source from the content-addressed store, hash-verified

213 return self._token_counter
214
215 def run(
216 self,
217 messages: List[OpenAIMessage],
218 ) -> ChatCompletion:
219 r"""Runs inference of Mistral chat completion.
220
221 Args:
222 messages (List[OpenAIMessage]): Message list with the chat history
223 in OpenAI API format.
224
225 Returns:
226 ChatCompletion.
227 """
228 mistral_messages = self._to_mistral_chatmessage(messages)
229
230 response = self._client.chat.complete(
231 messages=mistral_messages,
232 model=self.model_type,
233 **self.model_config_dict,
234 )
235
236 openai_response = self._to_openai_response(response) # type: ignore[arg-type]
237
238 # Add AgentOps LLM Event tracking
239 if LLMEvent:
240 llm_event = LLMEvent(
241 thread_id=openai_response.id,
242 prompt=" ".join(
243 [message.get("content") for message in messages] # type: ignore[misc]
244 ),
245 prompt_tokens=openai_response.usage.prompt_tokens, # type: ignore[union-attr]
246 completion=openai_response.choices[0].message.content,
247 completion_tokens=openai_response.usage.completion_tokens, # type: ignore[union-attr]
248 model=self.model_type,
249 )
250 record(llm_event)
251
252 return openai_response
253
254 def check_model_config(self):
255 r"""Check whether the model configuration contains any

Callers

nothing calls this directly

Calls 2

_to_openai_responseMethod · 0.95

Tested by

no test coverage detected