It is broken into two parts: installation and setup, and then references to specific Prediction Guard wrappers.Installation and Setup‚ÄãInstall the Python SDK with pip install predictionguardGet a Prediction Guard access token (as described here) and set it as an environment variable (PREDICTIONGUARD_TOKEN)LLM Wrapper‚ÄãThere exists a Prediction Guard LLM wrapper, which you can access with from langchain.llms import PredictionGuardYou can provide the name of the Prediction Guard model as an argument when initializing the LLM:pgllm = PredictionGuard(model="MPT-7B-Instruct")You can also provide your access token directly as an argument:pgllm = PredictionGuard(model="MPT-7B-Instruct", token="<your access token>")Finally, you can provide an "output" argument that is used to structure/ control the output of the LLM:pgllm = PredictionGuard(model="MPT-7B-Instruct", output={"type": "boolean"})Example usage‚ÄãBasic usage of the controlled or guarded LLM wrapper:import osimport predictionguard as pgfrom langchain.llms import PredictionGuardfrom langchain.prompts import PromptTemplatefrom langchain.chains import LLMChain# Your Prediction Guard API key. Get one at predictionguard.comos.environ["PREDICTIONGUARD_TOKEN"] = "<your Prediction Guard access token>"# Define a prompt templatetemplate = """Respond to the following query based on the context.Context: EVERY comment, DM + email suggestion has led us to this EXCITING announcement! üéâ We have officially added TWO new candle subscription box options! üì¶Exclusive Candle Box - $80 Monthly Candle Box - $45 (NEW!)Scent of The Month Box - $28 (NEW!)Head to stories to get ALL the deets on each box! üëÜ BONUS: Save 50% on your first box with code 50OFF! üéâQuery: {query}Result: """prompt = PromptTemplate(template=template, input_variables=["query"])# With "guarding" or controlling the output of the LLM. See the # Prediction Guard docs (https://docs.predictionguard.com) to learn how to # control the output with integer, float,
This page covers how to use the Prediction Guard ecosystem within LangChain.
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.Installation and Setup‚ÄãInstall the Python SDK with pip install predictionguardGet a Prediction Guard access token (as described here) and set it as an environment variable (PREDICTIONGUARD_TOKEN)LLM Wrapper‚ÄãThere exists a Prediction Guard LLM wrapper, which you can access with from langchain.llms import PredictionGuardYou can provide the name of the Prediction Guard model as an argument when initializing the LLM:pgllm = PredictionGuard(model="MPT-7B-Instruct")You can also provide your access token directly as an argument:pgllm = PredictionGuard(model="MPT-7B-Instruct", token="<your access token>")Finally, you can provide an "output" argument that is used to structure/ control the output of the LLM:pgllm = PredictionGuard(model="MPT-7B-Instruct", output={"type": "boolean"})Example usage‚ÄãBasic usage of the controlled or guarded LLM wrapper:import osimport predictionguard as pgfrom langchain.llms import PredictionGuardfrom langchain.prompts import PromptTemplatefrom langchain.chains import LLMChain# Your Prediction Guard API key. Get one at predictionguard.comos.environ["PREDICTIONGUARD_TOKEN"] = "<your Prediction Guard access token>"# Define a prompt templatetemplate = """Respond to the following query based on the context.Context: EVERY comment, DM + email suggestion has led us to this EXCITING announcement! üéâ We have officially added TWO new candle subscription box options! üì¶Exclusive Candle Box - $80 Monthly Candle Box - $45 (NEW!)Scent of The Month Box - $28 (NEW!)Head to stories to get ALL the deets on each box! üëÜ BONUS: Save 50% on your first box with code 50OFF! üéâQuery: {query}Result: """prompt = PromptTemplate(template=template, input_variables=["query"])# With "guarding" or controlling the output of the LLM. See the # Prediction Guard docs (https://docs.predictionguard.com) to learn how to # control the output with integer, float,