)
        messages = self.prefix_messages + [{"role": "user", "content": prompts[0]}]
        params: Dict[str, Any] = {**{"model": self.model_id}}
        if stop is not None:
            if "stop" in params:
                raise ValueError("`stop` found in both the input and default params.")
        return messages, params
    def _generate(
        self,
        prompts: List[str],
        stop: Optional[List[str]] = None,
        run_manager: Optional[CallbackManagerForLLMRun] = None,
        **kwargs: Any,
    ) -> LLMResult:
        messages, params = self._get_chat_params(prompts, stop)
        params = {**params, **kwargs}
        full_response = completion_with_retry(self, messages=messages, **params)
        llm_output = {
            "model_id": self.model_id,
        }
        return LLMResult(
            generations=[[Generation(text=full_response[0])]],
            llm_output=llm_output,
        )
    async def _agenerate(
        self,
        prompts: List[str],
        stop: Optional[List[str]] = None,
        run_manager: Optional[AsyncCallbackManagerForLLMRun] = None,
        **kwargs: Any,
    ) -> LLMResult:
        messages, params = self._get_chat_params(prompts, stop)
        params = {**params, **kwargs}
        full_response = await acompletion_with_retry(self, messages=messages, **params)
        llm_output = {
            "model_id": self.model_id,
        }
        return LLMResult(
            generations=[[Generation(text=full_response[0])]],
            llm_output=llm_output,