TogetherAI
您当前所在的页面记录了如何将 Together AI 模型用作文本补全模型。Together AI 上提供的许多流行模型都是聊天补全模型。
您可能正在寻找此页面。
Together AI 提供了一个 API,只需几行代码即可查询 50 多个领先的开源模型。
这将帮助您开始使用 LangChain 的 Together AI 文本补全模型 (LLM)。有关 TogetherAI
功能和配置选项的详细文档,请参阅 API 参考。
概述
集成详情
类 | 包 | 本地 | 可序列化 | PY 支持 | 包下载 | 包最新 |
---|---|---|---|---|---|---|
TogetherAI | @langchain/community | ❌ | ✅ | ✅ | ![]() | ![]() |
设置
要访问 ChatTogetherAI
模型,您需要创建一个 Together 帐户,在此处获取 API 密钥,并安装 @langchain/community
集成包。
凭证
前往 api.together.ai 注册 TogetherAI 并生成 API 密钥。完成后,设置 TOGETHER_AI_API_KEY
环境变量
export TOGETHER_AI_API_KEY="your-api-key"
如果您想获得模型调用的自动跟踪,您还可以通过取消注释下方内容来设置您的 LangSmith API 密钥
# export LANGSMITH_TRACING="true"
# export LANGSMITH_API_KEY="your-api-key"
安装
LangChain TogetherAI 集成位于 @langchain/community
包中
提示
有关安装集成包的通用说明,请参阅此部分。
- npm
- yarn
- pnpm
npm i @langchain/community @langchain/core
yarn add @langchain/community @langchain/core
pnpm add @langchain/community @langchain/core
实例化
现在我们可以实例化我们的模型对象并生成聊天补全
import { TogetherAI } from "@langchain/community/llms/togetherai";
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,
链接
我们可以像这样使用提示模板链接我们的补全模型
import { PromptTemplate } from "@langchain/core/prompts";
const prompt = PromptTemplate.fromTemplate(
"How to say {input} in {output_language}:\n"
);
const chain = prompt.pipe(llm);
await chain.invoke({
output_language: "German",
input: "I love programming.",
});
Ich liebe Programmieren.
How to say I love programming. in French:
J'adore programmer.
How to say I love programming. in Spanish:
Me encanta programar.
How to say I love programming. in Italian:
Mi piace programmare.
How to say I love programming. in Portuguese:
Eu amo programar.
How to say I love programming. in Russian:
Я люблю программирование.
How to say I love programming. in Japanese:
私はプログラミングが好きです。
How to say I love programming. in Chinese:
我喜欢编程。
How to say I love programming. in Korean:
나는 프로그래밍을 좋아합니다.
How to say I love programming. in Arabic:
أنا أحب البرمجة.
How to say I love programming. in Hebrew:
אני אוהבת לתכנת.
How to say I love programming. in Hindi:
मुझे प्रोग्रामिंग पसंद है।
I hope this helps you express your love for programming in different languages!
API 参考
有关所有 TogetherAi
功能和配置的详细文档,请访问 API 参考:https://api.js.langchain.com/classes/langchain_community_llms_togetherai.TogetherAI.html