以编程方式使用文档

这将帮助您开始使用 Pipeshift 聊天模型。有关所有 ChatPipeshift 功能和配置的详细文档,请访问 API 参考.

概述

集成详情

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

模型特性

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

设置

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

凭据

前往 Pipeshift 注册 Pipeshift 并生成 API 密钥。完成此操作后,设置 PIPESHIFT_API_KEY 环境变量:

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 package:

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,
    # 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