跳到主要内容
这将帮助您开始使用 Pipeshift 聊天模型。有关所有 ChatPipeshift 功能和配置的详细文档,请参阅API 参考

概览

集成详情

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

模型功能

工具调用结构化输出JSON 模式图像输入音频输入视频输入令牌级流式传输原生异步Token 用量Logprobs
-

设置

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

凭据

前往 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
Note: you may need to restart the kernel to use updated packages.

实例化

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

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

调用

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
以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.