Skip to main content
本文将帮助您快速上手 Pipeshift 聊天模型。有关 ChatPipeshift 所有特性和配置的详细文档,请参阅 API 参考

概述

集成详情

可序列化JS 支持下载量版本
ChatPipeshiftlangchain-pipeshift-PyPI - DownloadsPyPI - Version

模型功能

工具调用结构化输出图像输入音频输入视频输入Token 级流式输出原生异步Token 用量对数概率
-

安装配置

要访问 Pipeshift 模型,您需要在 Pipeshift 上创建账户、获取 API 密钥,并安装 langchain-pipeshift 集成包。

凭据

前往 Pipeshift 注册并生成 API 密钥。完成后,设置 PIPESHIFT_API_KEY 环境变量:
import getpass
import os

if not os.getenv("PIPESHIFT_API_KEY"):
    os.environ["PIPESHIFT_API_KEY"] = getpass.getpass("Enter your Pipeshift API key: ")
如果希望自动追踪模型调用,也可以设置您的 LangSmith API 密钥(取消下方注释):
os.environ["LANGSMITH_TRACING"] = "true"
os.environ["LANGSMITH_API_KEY"] = getpass.getpass("Enter your LangSmith API key: ")

安装

LangChain Pipeshift 集成位于 langchain-pipeshift 包中:
pip install -qU langchain-pipeshift

实例化

现在可以实例化模型对象并生成聊天补全:
from langchain_pipeshift import ChatPipeshift

llm = ChatPipeshift(
    model="meta-llama/Meta-Llama-3.1-8B-Instruct",
    temperature=0,
    max_tokens=512,
    # 其他参数...
)

调用

messages = [
    (
        "system",
        "You are a helpful assistant that translates English to French. Translate the user sentence.",
    ),
    ("human", "I love programming."),
]
ai_msg = llm.invoke(messages)
ai_msg
AIMessage(content='Here is the translation:\n\nJe suis amoureux du programme. \n\nHowever, a more common translation would be:\n\nJ\'aime programmer.\n\nNote that "Je suis amoureux" typically implies romantic love, whereas "J\'aime" is a more casual way to express affection or enjoyment for an activity, in this case, programming.', additional_kwargs={}, response_metadata={}, id='run-5cad8e5c-d089-44a8-8dcd-22736cde7d7b-0')
print(ai_msg.content)
Here is the translation:

Je suis amoureux du programme.

However, a more common translation would be:

J'aime programmer.

Note that "Je suis amoureux" typically implies romantic love, whereas "J'aime" is a more casual way to express affection or enjoyment for an activity, in this case, programming.

API 参考

有关 ChatPipeshift 所有特性和配置的详细文档,请参阅 API 参考:dashboard.pipeshift.com/docs