From ff3aada0b2ccd87ff16d38ebea4f0119030e9b46 Mon Sep 17 00:00:00 2001 From: Ankush Gola <9536492+agola11@users.noreply.github.com> Date: Sun, 16 Jul 2023 21:27:03 -0700 Subject: [PATCH] minor langsmith notebook fixes (#7814) --- docs/extras/guides/langsmith/walkthrough.ipynb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/extras/guides/langsmith/walkthrough.ipynb b/docs/extras/guides/langsmith/walkthrough.ipynb index 608f5621698..369d8fc9f6d 100644 --- a/docs/extras/guides/langsmith/walkthrough.ipynb +++ b/docs/extras/guides/langsmith/walkthrough.ipynb @@ -47,13 +47,23 @@ "## Log runs to LangSmith\n", "\n", "First, configure your environment variables to tell LangChain to log traces. This is done by setting the `LANGCHAIN_TRACING_V2` environment variable to true.\n", - "You can tell LangChain which project to log to by setting the `LANGCHAIN_PROJECT` environment variable (if this isn't set, runs will be logged to the `default` project). This will automatically create the project for you if it doesn't exiust. You must also set the `LANGCHAIN_ENDPOINT` and `LANGCHAIN_API_KEY` environment variables.\n", + "You can tell LangChain which project to log to by setting the `LANGCHAIN_PROJECT` environment variable (if this isn't set, runs will be logged to the `default` project). This will automatically create the project for you if it doesn't exist. You must also set the `LANGCHAIN_ENDPOINT` and `LANGCHAIN_API_KEY` environment variables.\n", "\n", "For more information on other ways to set up tracing, please reference the [LangSmith documentation](https://docs.smith.langchain.com/docs/)\n", "\n", "**NOTE:** You must also set your `OPENAI_API_KEY` and `SERPAPI_API_KEY` environment variables in order to run the following tutorial.\n", "\n", - "**NOTE:** You can only access an API key when you first create it. Keep it somewhere safe." + "**NOTE:** You can only access an API key when you first create it. Keep it somewhere safe.\n", + "\n", + "**NOTE:** You can also use a context manager in python to log traces using\n", + "```python\n", + "from langchain.callbacks.manager import tracing_v2_enabled\n", + "\n", + "with tracing_v2_enabled(project_name=\"My Project\"):\n", + " agent.run(\"How many people live in canada as of 2023?\")\n", + "```\n", + "\n", + "However, in this example, we will use environment variables." ] }, { @@ -229,7 +239,7 @@ "source": [ "### 1. Create a LangSmith dataset\n", "\n", - "Below, we use the LangSmith client to create a dataset from the agent runs you just logged above. You will use these later to measure performance for a new agent. This simple taking the inputs and outputs of the runs and saving them as examples to a dataset. A dataset is a collection of examples, which are nothing more than input-output pairs you can use as test cases to your application.\n", + "Below, we use the LangSmith client to create a dataset from the agent runs you just logged above. You will use these later to measure performance for a new agent. This is simply taking the inputs and outputs of the runs and saving them as examples to a dataset. A dataset is a collection of examples, which are nothing more than input-output pairs you can use as test cases to your application.\n", "\n", "**Note: this is a simple, walkthrough example. In a real-world setting, you'd ideally first validate the outputs before adding them to a benchmark dataset to be used for evaluating other agents.**\n", "\n",