set it as an environment variabled called PROMPTLAYER_API_KEYUsage‚ÄãGetting started with PromptLayerCallbackHandler is fairly simple, it takes two optional arguments:pl_tags - an optional list of strings that will be tracked as tags on PromptLayer.pl_id_callback - an optional function that will take promptlayer_request_id as an argument. This ID can be used with all of PromptLayer's tracking features to track, metadata, scores, and prompt usage.Simple OpenAI Example‚ÄãIn this simple example we use PromptLayerCallbackHandler with ChatOpenAI. We add a PromptLayer tag named chatopenaiimport promptlayer  # Don't forget this üç∞from langchain.callbacks import PromptLayerCallbackHandlerfrom langchain.chat_models import ChatOpenAIfrom langchain.schema import (    HumanMessage,)chat_llm = ChatOpenAI(    temperature=0,    callbacks=[PromptLayerCallbackHandler(pl_tags=["chatopenai"])],)llm_results = chat_llm(    [        HumanMessage(content="What comes after 1,2,3 ?"),        HumanMessage(content="Tell me another joke?"),    ])print(llm_results)GPT4All Example‚Äãimport promptlayer  # Don't forget this üç∞from langchain.callbacks import PromptLayerCallbackHandlerfrom langchain.llms import GPT4Allmodel = GPT4All(model="./models/gpt4all-model.bin", n_ctx=512, n_threads=8)response = model(    "Once upon a time, ",    callbacks=[PromptLayerCallbackHandler(pl_tags=["langchain", "gpt4all"])],)Full Featured Example‚ÄãIn this example we unlock more of the power of PromptLayer.PromptLayer allows you to visually create, version, and track prompt templates. Using the Prompt Registry, we can programmatically fetch the prompt template called example.We also define a pl_id_callback function which takes in the promptlayer_request_id and logs a score, metadata and links the prompt template used. Read more about tracking on our docs.import promptlayer  # Don't forget this üç∞from langchain.callbacks import PromptLayerCallbackHandlerfrom langchain.llms import OpenAIdef
PromptLayer
PromptLayer ->: set it as an environment variabled called PROMPTLAYER_API_KEYUsage‚ÄãGetting started with PromptLayerCallbackHandler is fairly simple, it takes two optional arguments:pl_tags - an optional list of strings that will be tracked as tags on PromptLayer.pl_id_callback - an optional function that will take promptlayer_request_id as an argument. This ID can be used with all of PromptLayer's tracking features to track, metadata, scores, and prompt usage.Simple OpenAI Example‚ÄãIn this simple example we use PromptLayerCallbackHandler with ChatOpenAI. We add a PromptLayer tag named chatopenaiimport promptlayer  # Don't forget this üç∞from langchain.callbacks import PromptLayerCallbackHandlerfrom langchain.chat_models import ChatOpenAIfrom langchain.schema import (    HumanMessage,)chat_llm = ChatOpenAI(    temperature=0,    callbacks=[PromptLayerCallbackHandler(pl_tags=["chatopenai"])],)llm_results = chat_llm(    [        HumanMessage(content="What comes after 1,2,3 ?"),        HumanMessage(content="Tell me another joke?"),    ])print(llm_results)GPT4All Example‚Äãimport promptlayer  # Don't forget this üç∞from langchain.callbacks import PromptLayerCallbackHandlerfrom langchain.llms import GPT4Allmodel = GPT4All(model="./models/gpt4all-model.bin", n_ctx=512, n_threads=8)response = model(    "Once upon a time, ",    callbacks=[PromptLayerCallbackHandler(pl_tags=["langchain", "gpt4all"])],)Full Featured Example‚ÄãIn this example we unlock more of the power of PromptLayer.PromptLayer allows you to visually create, version, and track prompt templates. Using the Prompt Registry, we can programmatically fetch the prompt template called example.We also define a pl_id_callback function which takes in the promptlayer_request_id and logs a score, metadata and links the prompt template used. Read more about tracking on our docs.import promptlayer  # Don't forget this üç∞from langchain.callbacks import PromptLayerCallbackHandlerfrom langchain.llms import OpenAIdef