以编程方式使用文档

Together AI 提供一个 API 来查询 50+ 领先的开源模型 仅需几行代码。

这将帮助您开始使用 LangChain 与 Together AI 文本补全模型(LLM)。有关详细文档,请参阅 TogetherAI 特性和配置选项,请参阅 API 参考.

概述

集成详情

本地可序列化PY 支持下载量版本
TogetherAI@langchain/together-ai!NPM - 下载量!NPM - 版本

设置

要访问旧的 TogetherAI 补全类,请创建一个 Together 账户, 获取一个 API 密钥,并安装 @langchain/together-ai 集成包。对于聊天和指导模型,请优先使用 ChatTogetherAI.

凭据

前往 api.together.ai 注册 Together AI 并生成 API 密钥。设置 TOGETHER_AI_API_KEY 环境变量:

如果您想获取模型调用的自动追踪,还可以设置您的 LangSmith API 密钥(取消下面的注释):

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

安装

LangChain TogetherAI 集成位于 @langchain/together-ai package:

npm install @langchain/together-ai @langchain/core
yarn add @langchain/together-ai @langchain/core
pnpm add @langchain/together-ai @langchain/core

实例化

实例化补全模型:

const llm = new TogetherAI({
  model: "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",
  maxTokens: 256,
});

调用

const inputText = "Together is an AI company that "

const completion = await llm.invoke(inputText)
completion
 offers a range of AI-powered solutions to help businesses and organizations improve their customer service, sales, and marketing efforts. Their platform uses natural language processing (NLP) and machine learning algorithms to analyze customer interactions and provide insights and recommendations to help businesses improve their customer experience.
Together's solutions include:
1. Customer Service: Together's customer service solution uses AI to analyze customer interactions and provide insights and recommendations to help businesses improve their customer experience. This includes analyzing customer feedback, sentiment analysis, and predictive analytics to identify areas for improvement.
2. Sales: Together's sales solution uses AI to analyze customer interactions and provide insights and recommendations to help businesses improve their sales efforts. This includes analyzing customer behavior, sentiment analysis, and predictive analytics to identify opportunities for upselling and cross-selling.
3. Marketing: Together's marketing solution uses AI to analyze customer interactions and provide insights and recommendations to help businesses improve their marketing efforts. This includes analyzing customer behavior, sentiment analysis, and predictive analytics to identify areas for improvement.
Together's platform is designed to be easy to use and integrates with a range of popular CRM and marketing automation tools. Their solutions are available as a cloud-based subscription service, making it easy for businesses to get started with AI-powered customer service, sales, and marketing.
Overall,

API 参考

有关所有 TogetherAI 特性和配置的详细文档,请参阅 API 参考.