本页还没有译文
本页 22 段还没译成日本語,下面显示的是英文原文。Prediction guard integrations
还没翻译译自英文(docs.langchain.com)本页 22 段都还没译
This page covers how to use the Prediction Guard ecosystem within LangChain. It is broken into two parts: installation and setup, and then references to specific Prediction Guard wrappers.
This integration is maintained in the langchain-predictionguard package.
Installation and setup
- Install the PredictionGuard LangChain partner package:
pip install langchain-predictionguarduv add langchain-predictionguard- Get a Prediction Guard API key (as described in the Prediction Guard documentation) and set it as an environment variable (
PREDICTIONGUARD_API_KEY)
Prediction guard LangChain integrations
| API | Description | Endpoint Docs | Import | Example Usage |
|---|---|---|---|---|
| Chat | Build Chat Bots | Chat | from langchain_predictionguard import ChatPredictionGuard | langchain-predictionguard |
| Completions | Generate Text | Completions | from langchain_predictionguard import PredictionGuard | PredictionGuard.ipynb |
| Text Embedding | Embed String to Vectors | Embeddings | from langchain_predictionguard import PredictionGuardEmbeddings | PredictionGuard embeddings |
Getting started
Chat models
Prediction guard chat
See a usage example
from langchain_predictionguard import ChatPredictionGuardUsage
# If predictionguard_api_key is not passed, default behavior is to use the `PREDICTIONGUARD_API_KEY` environment variable.
chat = ChatPredictionGuard(model="Hermes-3-Llama-3.1-8B")
chat.invoke("Tell me a joke")Embedding models
Prediction guard embeddings
See a usage example
from langchain_predictionguard import PredictionGuardEmbeddingsUsage
# If predictionguard_api_key is not passed, default behavior is to use the `PREDICTIONGUARD_API_KEY` environment variable.
embeddings = PredictionGuardEmbeddings(model="bridgetower-large-itm-mlm-itc")
text = "This is an embedding example."
output = embeddings.embed_query(text)LLMs
Prediction guard LLM
See a usage example
from langchain_predictionguard import PredictionGuardUsage
# If predictionguard_api_key is not passed, default behavior is to use the `PREDICTIONGUARD_API_KEY` environment variable.
llm = PredictionGuard(model="Hermes-2-Pro-Llama-3-8B")
llm.invoke("Tell me a joke about bears")AI 翻译查看英文原文