跳至主要内容

TogetherAI

您目前位于一个文档页面,该页面记录了使用 Together AI 模型作为 文本完成模型。在 Together AI 上可用的许多流行模型都是 聊天完成模型.

您可能正在寻找 这个页面.

Together AI 提供了一个 API,用于在几行代码中查询 50 多个领先的开源模型.

这将帮助您使用 LangChain 开始使用 Together AI 文本完成模型 (LLMs)。有关 TogetherAI 功能和配置选项的详细文档,请参阅 API 参考.

概述

集成详细信息

本地可序列化PY 支持包下载包最新版本
TogetherAI@langchain/communityNPM - DownloadsNPM - Version

设置

要访问 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 LANGCHAIN_TRACING_V2="true"
# export LANGCHAIN_API_KEY="your-api-key"

安装

LangChain TogetherAI 集成位于 @langchain/community 包中

yarn 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


此页面是否有帮助?


您也可以在 GitHub 上留下详细的反馈 GitHub.