and toolkitsMemoryCallbacksChat loadersProvidersMoreCometOn this pageCometIn this guide we will demonstrate how to track your Langchain Experiments, Evaluation Metrics, and LLM Sessions with Comet.  Example Project: Comet with LangChainInstall Comet and Dependencies‚Äãimport sys{sys.executable} -m spacy download en_core_web_smInitialize Comet and Set your Credentials‚ÄãYou can grab your Comet API Key here or click the link after initializing Cometimport comet_mlcomet_ml.init(project_name="comet-example-langchain")Set OpenAI and SerpAPI credentials‚ÄãYou will need an OpenAI API Key and a SerpAPI API Key to run the following examplesimport osos.environ["OPENAI_API_KEY"] = "..."# os.environ["OPENAI_ORGANIZATION"] = "..."os.environ["SERPAPI_API_KEY"] = "..."Scenario 1: Using just an LLM‚Äãfrom datetime import datetimefrom langchain.callbacks import CometCallbackHandler, StdOutCallbackHandlerfrom langchain.llms import OpenAIcomet_callback = CometCallbackHandler(    project_name="comet-example-langchain",    complexity_metrics=True,    stream_logs=True,    tags=["llm"],    visualizations=["dep"],)callbacks = [StdOutCallbackHandler(), comet_callback]llm = OpenAI(temperature=0.9, callbacks=callbacks, verbose=True)llm_result = llm.generate(["Tell me a joke", "Tell me a poem", "Tell me a fact"] * 3)print("LLM result", llm_result)comet_callback.flush_tracker(llm, finish=True)Scenario 2: Using an LLM in a Chain‚Äãfrom langchain.callbacks import CometCallbackHandler, StdOutCallbackHandlerfrom langchain.chains import LLMChainfrom langchain.llms import OpenAIfrom langchain.prompts import PromptTemplatecomet_callback = CometCallbackHandler(    complexity_metrics=True,    project_name="comet-example-langchain",    stream_logs=True,    tags=["synopsis-chain"],)callbacks = [StdOutCallbackHandler(), comet_callback]llm = OpenAI(temperature=0.9, callbacks=callbacks)template = """You are a playwright. Given the title of play, it is your job to write a synopsis for that title.Title:
In this guide we will demonstrate how to track your Langchain Experiments, Evaluation Metrics, and LLM Sessions with Comet.
In this guide we will demonstrate how to track your Langchain Experiments, Evaluation Metrics, and LLM Sessions with Comet. ->: and toolkitsMemoryCallbacksChat loadersProvidersMoreCometOn this pageCometIn this guide we will demonstrate how to track your Langchain Experiments, Evaluation Metrics, and LLM Sessions with Comet.  Example Project: Comet with LangChainInstall Comet and Dependencies‚Äãimport sys{sys.executable} -m spacy download en_core_web_smInitialize Comet and Set your Credentials‚ÄãYou can grab your Comet API Key here or click the link after initializing Cometimport comet_mlcomet_ml.init(project_name="comet-example-langchain")Set OpenAI and SerpAPI credentials‚ÄãYou will need an OpenAI API Key and a SerpAPI API Key to run the following examplesimport osos.environ["OPENAI_API_KEY"] = "..."# os.environ["OPENAI_ORGANIZATION"] = "..."os.environ["SERPAPI_API_KEY"] = "..."Scenario 1: Using just an LLM‚Äãfrom datetime import datetimefrom langchain.callbacks import CometCallbackHandler, StdOutCallbackHandlerfrom langchain.llms import OpenAIcomet_callback = CometCallbackHandler(    project_name="comet-example-langchain",    complexity_metrics=True,    stream_logs=True,    tags=["llm"],    visualizations=["dep"],)callbacks = [StdOutCallbackHandler(), comet_callback]llm = OpenAI(temperature=0.9, callbacks=callbacks, verbose=True)llm_result = llm.generate(["Tell me a joke", "Tell me a poem", "Tell me a fact"] * 3)print("LLM result", llm_result)comet_callback.flush_tracker(llm, finish=True)Scenario 2: Using an LLM in a Chain‚Äãfrom langchain.callbacks import CometCallbackHandler, StdOutCallbackHandlerfrom langchain.chains import LLMChainfrom langchain.llms import OpenAIfrom langchain.prompts import PromptTemplatecomet_callback = CometCallbackHandler(    complexity_metrics=True,    project_name="comet-example-langchain",    stream_logs=True,    tags=["synopsis-chain"],)callbacks = [StdOutCallbackHandler(), comet_callback]llm = OpenAI(temperature=0.9, callbacks=callbacks)template = """You are a playwright. Given the title of play, it is your job to write a synopsis for that title.Title: