현재 Cohere 모델을 text completion 모델로 사용하는 방법을 설명하는 페이지를 보고 계십니다. 많은 인기 있는 Cohere 모델은 chat completion 모델입니다.이 페이지를 찾고 계실 수 있습니다.
Cohere는 기업이 인간-기계 상호작용을 개선할 수 있도록 자연어 처리 모델을 제공하는 캐나다 스타트업입니다.
모든 속성과 메서드에 대한 자세한 문서는 API reference를 참조하세요.

Overview

Integration details

ClassPackageLocalSerializableJS supportDownloadsVersion
Coherelangchain-communitybetaPyPI - DownloadsPyPI - Version

Setup

이 통합은 langchain-community 패키지에 포함되어 있습니다. 또한 cohere 패키지 자체도 설치해야 합니다. 다음과 같이 설치할 수 있습니다:

Credentials

Cohere API key를 발급받고 COHERE_API_KEY 환경 변수를 설정해야 합니다:
import getpass
import os

if "COHERE_API_KEY" not in os.environ:
    os.environ["COHERE_API_KEY"] = getpass.getpass()

Installation

pip install -U langchain-community langchain-cohere
최고 수준의 observability를 위해 LangSmith를 설정하는 것도 도움이 됩니다(필수는 아님)
os.environ["LANGSMITH_TRACING"] = "true"
# os.environ["LANGSMITH_API_KEY"] = getpass.getpass()

Invocation

Cohere는 모든 LLM 기능을 지원합니다:
from langchain_cohere import Cohere
from langchain.messages import HumanMessage
model = Cohere(max_tokens=256, temperature=0.75)
message = "Knock knock"
model.invoke(message)
" Who's there?"
await model.ainvoke(message)
" Who's there?"
for chunk in model.stream(message):
    print(chunk, end="", flush=True)
 Who's there?
model.batch([message])
[" Who's there?"]

API reference

모든 Cohere llm 기능과 구성에 대한 자세한 문서는 API reference를 참조하세요: python.langchain.com/api_reference/community/llms/langchain_community.llms.cohere.Cohere.html
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I