WatsonxLLM은 IBM watsonx.ai foundation model을 위한 wrapper입니다.이 예제는
LangChain을 사용하여 watsonx.ai model과 통신하는 방법을 보여줍니다.
개요
Integration 세부 정보
| Class | Package | Local | Serializable | JS support | Downloads | Version |
|---|---|---|---|---|---|---|
| WatsonxLLM | langchain-ibm | ❌ | ❌ | ✅ |
설정
IBM watsonx.ai model에 액세스하려면 IBM watsonx.ai 계정을 생성하고, API key를 받고,langchain-ibm integration package를 설치해야 합니다.
자격 증명
아래 셀은 watsonx Foundation Model inferencing 작업에 필요한 자격 증명을 정의합니다. 작업: IBM Cloud 사용자 API key를 제공하세요. 자세한 내용은 Managing user API keys를 참조하세요.설치
LangChain IBM integration은langchain-ibm package에 있습니다:
인스턴스화
다양한 model이나 작업에 대해 modelparameters를 조정해야 할 수 있습니다. 자세한 내용은 documentation을 참조하세요.
WatsonxLLM class를 초기화합니다.
참고:
- API 호출에 대한 context를 제공하려면
project_id또는space_id를 추가해야 합니다. 자세한 내용은 documentation을 참조하세요. - 프로비저닝된 서비스 인스턴스의 지역에 따라 여기에 설명된 url 중 하나를 사용하세요.
project_id와 Dallas url을 사용합니다.
inferencing에 사용할 model_id를 지정해야 합니다. 사용 가능한 모든 model은 documentation에서 찾을 수 있습니다.
model_id 대신 이전에 튜닝된 model의 deployment_id를 전달할 수도 있습니다. 전체 model tuning workflow는 Working with TuneExperiment and PromptTuner에 설명되어 있습니다.
APIClient 객체를 WatsonxLLM class에 전달하는 옵션이 있습니다.
ModelInference 객체를 WatsonxLLM class에 전달할 수도 있습니다.
호출
completion을 얻으려면 문자열 prompt를 사용하여 model을 직접 호출할 수 있습니다.Model output Streaming
model output을 streaming할 수 있습니다.Chaining
무작위 질문을 생성하는PromptTemplate 객체를 생성합니다.
API reference
모든WatsonxLLM 기능 및 구성에 대한 자세한 문서는 API reference를 참조하세요.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.