ChatTogetherAI 통합

ChatTogetherAI 통합

LangChain JavaScript로 ChatTogetherAI 채팅 모델과 통합하는 방법을 안내할게요.

출처: 문서

본문

Together AI는 몇 줄의 코드로 50개 이상의 선도적인 오픈소스 모델을 조회할 수 있는 API를 제공해요.

이 가이드는 ChatTogetherAI 채팅 모델을 시작하는 데 도움을 줘요. 모든 ChatTogetherAI 기능과 구성에 대한 자세한 문서는 API 레퍼런스를 참고하세요.

개요

통합 세부 정보

클래스 패키지 Serializable PY 지원 Downloads Version
ChatTogetherAI @langchain/together-ai NPM - Downloads NPM - Version

모델 기능

아래 표 헤더의 링크에서 특정 기능을 사용하는 방법에 대한 가이드를 확인할 수 있어요.

Tool calling Structured output Image input Audio input Video input Token-level streaming Token usage Logprobs

설정

ChatTogetherAI 모델에 접근하려면 Together 계정을 만들고 API 키를 받은@langchain/together-ai 통합 패키지를 설치해야 해요.

자격 증명

api.together.ai에서 Together AI에 가입하고 API 키를 생성하세요. TOGETHER_AI_API_KEY 환경 변수를 설정하세요:

export TOGETHER_AI_API_KEY="your-api-key"

모델 호출의 자동 추적(tracing)을 원한다면 아래 주석을 해제해 LangSmith API 키를 설정할 수도 있어요:

# export LANGSMITH_TRACING="true"
# export LANGSMITH_API_KEY="your-api-key"

설치

LangChain ChatTogetherAI 통합은 @langchain/together-ai 패키지에 있어요:

```bash npm theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}} npm install @langchain/together-ai @langchain/core ```
yarn add @langchain/together-ai @langchain/core
pnpm add @langchain/together-ai @langchain/core

인스턴스 생성

이제 모델 객체를 생성하고 채팅 완성을 생성할 수 있어요:

import { ChatTogetherAI } from "@langchain/together-ai";

const llm = new ChatTogetherAI({
    model: "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",
    temperature: 0,
    // other params...
})

호출

const aiMsg = await llm.invoke([
    [
        "system",
        "You are a helpful assistant that translates English to French. Translate the user sentence.",
    ],
    ["human", "I love programming."],
])
aiMsg
AIMessage {
  "id": "chatcmpl-9rT9qEDPZ6iLCk6jt3XTzVDDH6pcI",
  "content": "J'adore la programmation.",
  "additional_kwargs": {},
  "response_metadata": {
    "tokenUsage": {
      "completionTokens": 8,
      "promptTokens": 31,
      "totalTokens": 39
    },
    "finish_reason": "stop"
  },
  "tool_calls": [],
  "invalid_tool_calls": [],
  "usage_metadata": {
    "input_tokens": 31,
    "output_tokens": 8,
    "total_tokens": 39
  }
}
console.log(aiMsg.content)
J'adore la programmation.

API 레퍼런스

모든 ChatTogetherAI 기능과 구성에 대한 자세한 문서는 API 레퍼런스를 참고하세요.


[Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers. [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/chat/togetherai.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).

더 알아보기