ibm: added partners package langchain_ibm, added llm (#16512)

- **Description:** Added `langchain_ibm` as an langchain partners
package of IBM [watsonx.ai](https://www.ibm.com/products/watsonx-ai) LLM
provider (`WatsonxLLM`)
- **Dependencies:**
[ibm-watsonx-ai](https://pypi.org/project/ibm-watsonx-ai/),
  - **Tag maintainer:** : 
---------

Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
Mateusz Szewczyk
2024-02-14 21:12:19 +01:00
committed by GitHub
parent f6d3a3546f
commit 916332ef5b
23 changed files with 1906 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ import logging
import os
from typing import Any, Dict, Iterator, List, Mapping, Optional, Union
from langchain_core._api.deprecation import deprecated
from langchain_core.callbacks import CallbackManagerForLLMRun
from langchain_core.language_models.llms import BaseLLM
from langchain_core.outputs import Generation, GenerationChunk, LLMResult
@@ -11,6 +12,9 @@ from langchain_core.utils import convert_to_secret_str, get_from_dict_or_env
logger = logging.getLogger(__name__)
@deprecated(
since="0.0.18", removal="0.2", alternative_import="langchain_ibm.WatsonxLLM"
)
class WatsonxLLM(BaseLLM):
"""
IBM watsonx.ai large language models.
@@ -293,9 +297,6 @@ class WatsonxLLM(BaseLLM):
generation_info=dict(
finish_reason=stream_response["results"][0].get("stop_reason", None),
llm_output={
"generated_token_count": stream_response["results"][0].get(
"generated_token_count", None
),
"model_id": self.model_id,
"deployment_id": self.deployment_id,
},