|
698 | 698 | "cell_type": "markdown", |
699 | 699 | "id": "mp3fa80d86", |
700 | 700 | "metadata": {}, |
| 701 | + "source": "**3. Add LangSmith tracing to your config**\n\nRun the cell below to automatically update `config_simple_researcher.yml` with LangSmith tracing:" |
| 702 | + }, |
| 703 | + { |
| 704 | + "cell_type": "code", |
| 705 | + "execution_count": null, |
| 706 | + "id": "ls_config_writer", |
| 707 | + "metadata": {}, |
| 708 | + "outputs": [], |
701 | 709 | "source": [ |
702 | | - "**3. Add LangSmith tracing to your config**\n", |
| 710 | + "config_path = \"config_simple_researcher.yml\"\n", |
703 | 711 | "\n", |
704 | | - "Add the `tracing` block under `general.telemetry` in your config file (e.g. `config_simple_researcher.yml`):\n", |
| 712 | + "with open(config_path) as f:\n", |
| 713 | + " content = f.read()\n", |
705 | 714 | "\n", |
706 | | - "```yaml\n", |
707 | | - "general:\n", |
708 | | - " use_uvloop: true\n", |
709 | | - " telemetry:\n", |
710 | | - " logging:\n", |
711 | | - " console:\n", |
712 | | - " _type: console\n", |
713 | | - " level: WARN\n", |
714 | | - " tracing:\n", |
715 | | - " langsmith:\n", |
716 | | - " _type: langsmith\n", |
717 | | - " project: langsmith-project\n", |
718 | | - " api_key: ${LANGSMITH_API_KEY}\n", |
719 | | - "```\n", |
720 | | - "\n", |
721 | | - "Then re-run the agent as before. Traces will appear in your LangSmith project dashboard at [smith.langchain.com](https://smith.langchain.com/)." |
| 715 | + "if \"tracing:\" not in content:\n", |
| 716 | + " content = content.replace(\n", |
| 717 | + " \" level: INFO\\n\",\n", |
| 718 | + " \" level: INFO\\n\\n\"\n", |
| 719 | + " \" tracing:\\n\"\n", |
| 720 | + " \" langsmith:\\n\"\n", |
| 721 | + " \" _type: langsmith\\n\"\n", |
| 722 | + " \" project: ${LANGSMITH_PROJECT}\\n\"\n", |
| 723 | + " \" api_key: ${LANGSMITH_API_KEY}\\n\",\n", |
| 724 | + " 1,\n", |
| 725 | + " )\n", |
| 726 | + " with open(config_path, \"w\") as f:\n", |
| 727 | + " f.write(content)\n", |
| 728 | + " print(f\"Tracing config added to {config_path}\")\n", |
| 729 | + "else:\n", |
| 730 | + " print(\"Tracing config already present — no changes made.\")" |
722 | 731 | ] |
723 | 732 | }, |
| 733 | + { |
| 734 | + "cell_type": "markdown", |
| 735 | + "id": "ls_verify_md", |
| 736 | + "metadata": {}, |
| 737 | + "source": "**4. Run the agent and verify traces**\n\nRe-run the agent with the updated config:" |
| 738 | + }, |
| 739 | + { |
| 740 | + "cell_type": "code", |
| 741 | + "execution_count": null, |
| 742 | + "id": "ls_run_agent", |
| 743 | + "metadata": {}, |
| 744 | + "outputs": [], |
| 745 | + "source": [ |
| 746 | + "!.venv/bin/nat run --config_file config_simple_researcher.yml --input \"What is NVIDIA Spectrum-X?\" | sed 's/\\\\n/\\n/g'" |
| 747 | + ] |
| 748 | + }, |
| 749 | + { |
| 750 | + "cell_type": "markdown", |
| 751 | + "id": "ls_check_md", |
| 752 | + "metadata": {}, |
| 753 | + "source": "After the run completes, go to [smith.langchain.com](https://smith.langchain.com/), open your project, and you should see a new trace for the query above. Click into it to explore the agent's steps, LLM calls, and tool usage." |
| 754 | + }, |
| 755 | + { |
| 756 | + "cell_type": "markdown", |
| 757 | + "id": "together_lightweight_md", |
| 758 | + "metadata": {}, |
| 759 | + "source": "## (Optional) Use a Partner LLM Endpoint\n\nYou can swap the LLM provider in `config_simple_researcher.yml` with any OpenAI-compatible API.\n\nFor example, to use [Together.ai](https://www.together.ai/) with the [Nemotron model](https://www.together.ai/models/nvidia-nemotron-3-nano) — sign up at [together.ai](https://www.together.ai/), generate an API key, and update the three Nemotron LLM blocks (`nemotron_llm_intent`, `nemotron_llm`, `nemotron_llm_deep`) following this pattern:\n\n```yaml\nllms:\n nemotron_llm:\n _type: openai\n model_name: nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16\n base_url: \"https://api.together.xyz/v1\"\n api_key: ${TOGETHER_API_KEY}\n temperature: 0.1\n top_p: 0.3\n max_tokens: 16384\n num_retries: 5\n```\n\nKey changes from the default NIM config:\n- `_type: nim` → `_type: openai`\n- `base_url` → partner endpoint URL\n- `api_key` → your `TOGETHER_API_KEY`\n- Remove `chat_template_kwargs: enable_thinking: true` (NIM-specific)\n\n> More provider guides coming soon." |
| 760 | + }, |
724 | 761 | { |
725 | 762 | "cell_type": "markdown", |
726 | 763 | "id": "ed4b4431", |
|
0 commit comments