跳到主要内容

TogetherAI

您当前位于一个页面,该页面记录了将 Together AI 模型用作文本完成模型。Together AI 上提供许多流行的模型是聊天完成模型

您可能正在寻找此页面

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

这将帮助您开始使用 Together AI 的文本完成模型 (LLM) 和 LangChain。有关 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

实例化

现在我们可以实例化我们的模型对象并生成聊天完成

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 上.