how to # control the output with integer, float, boolean, JSON, and other types and# structures.pgllm = PredictionGuard(model="MPT-7B-Instruct",                         output={                                "type": "categorical",                                "categories": [                                    "product announcement",                                     "apology",                                     "relational"                                    ]                                })pgllm(prompt.format(query="What kind of post is this?"))Basic LLM Chaining with the Prediction Guard wrapper:import osfrom langchain.prompts import PromptTemplatefrom langchain.chains import LLMChainfrom langchain.llms import PredictionGuard# Optional, add your OpenAI API Key. This is optional, as Prediction Guard allows# you to access all the latest open access models (see https://docs.predictionguard.com)os.environ["OPENAI_API_KEY"] = "<your OpenAI api key>"# Your Prediction Guard API key. Get one at predictionguard.comos.environ["PREDICTIONGUARD_TOKEN"] = "<your Prediction Guard access token>"pgllm = PredictionGuard(model="OpenAI-text-davinci-003")template = """Question: {question}Answer: Let's think step by step."""prompt = PromptTemplate(template=template, input_variables=["question"])llm_chain = LLMChain(prompt=prompt, llm=pgllm, verbose=True)question = "What NFL team won the Super Bowl in the year Justin Beiber was born?"llm_chain.predict(question=question)PreviousPredibaseNextPromptLayerInstallation and SetupLLM WrapperExample usageCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.
This page covers how to use the Prediction Guard ecosystem within LangChain.
This page covers how to use the Prediction Guard ecosystem within LangChain. ->: how to # control the output with integer, float, boolean, JSON, and other types and# structures.pgllm = PredictionGuard(model="MPT-7B-Instruct",                         output={                                "type": "categorical",                                "categories": [                                    "product announcement",                                     "apology",                                     "relational"                                    ]                                })pgllm(prompt.format(query="What kind of post is this?"))Basic LLM Chaining with the Prediction Guard wrapper:import osfrom langchain.prompts import PromptTemplatefrom langchain.chains import LLMChainfrom langchain.llms import PredictionGuard# Optional, add your OpenAI API Key. This is optional, as Prediction Guard allows# you to access all the latest open access models (see https://docs.predictionguard.com)os.environ["OPENAI_API_KEY"] = "<your OpenAI api key>"# Your Prediction Guard API key. Get one at predictionguard.comos.environ["PREDICTIONGUARD_TOKEN"] = "<your Prediction Guard access token>"pgllm = PredictionGuard(model="OpenAI-text-davinci-003")template = """Question: {question}Answer: Let's think step by step."""prompt = PromptTemplate(template=template, input_variables=["question"])llm_chain = LLMChain(prompt=prompt, llm=pgllm, verbose=True)question = "What NFL team won the Super Bowl in the year Justin Beiber was born?"llm_chain.predict(question=question)PreviousPredibaseNextPromptLayerInstallation and SetupLLM WrapperExample usageCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.