Skip to content

Commit baa4170

Browse files
committed
added langsmith demo
1 parent 5070247 commit baa4170

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

Langchain/imgs/smith-getstarted.png

57.9 KB
Loading

Langchain/langsmith-intro.ipynb

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "59d9c713",
6+
"metadata": {},
7+
"source": [
8+
"# Langsmith\n",
9+
"**The companion tool I've been waiting for**\n",
10+
"![viusalize your runs with langsmith](https://docs.smith.langchain.com/assets/images/run_details-f579aef109cb8f576e7a4a864e405143.png)\n",
11+
"\n",
12+
"debugging is a pain when building complicated LLM application. There is a lot of text to parse from each step, each input and output is different and if there is an a step mid-way, it is hard to change just that value and run it again. Basically when developing I want a tool that\n",
13+
"- shows me exactly what the input/outputs are from the LLM, tools etc (visualisation)\n",
14+
"- allows me to edit prompts at each step and see how it affects the output (live debugging)\n",
15+
"- show the exact sequence of events, the time taken at each step, tokens used\n",
16+
"- share the my debug traces with other (honestly I didn't know I needed this until I saw langsmith has support for it 😂)\n",
17+
"\n",
18+
"and boy does langsmith solve these problems. In-face I've changed my workflow to always have langsmith open in the side, logging everything, ready to be help me visualize what is happening with my apps.\n",
19+
"\n",
20+
"Langsmith also has a few more features and you can see the whole list [here](https://docs.smith.langchain.com/overview)"
21+
]
22+
},
23+
{
24+
"cell_type": "markdown",
25+
"id": "0e43ec44",
26+
"metadata": {},
27+
"source": [
28+
"## Getting Started"
29+
]
30+
},
31+
{
32+
"cell_type": "code",
33+
"execution_count": 1,
34+
"id": "296878ac",
35+
"metadata": {},
36+
"outputs": [],
37+
"source": [
38+
"import os\n",
39+
"\n",
40+
"os.environ[\"LANGCHAIN_TRACING_V2\"]=\"true\"\n",
41+
"os.environ[\"LANGCHAIN_ENDPOINT\"]=\"https://api.smith.langchain.com\"\n",
42+
"os.environ[\"LANGCHAIN_API_KEY\"]=\"<your-api-key>\"\n",
43+
"os.environ[\"LANGCHAIN_PROJECT\"]=\"<your-project>\" # if not specified, defaults to \"default\""
44+
]
45+
},
46+
{
47+
"cell_type": "code",
48+
"execution_count": 1,
49+
"id": "c8d70977",
50+
"metadata": {},
51+
"outputs": [
52+
{
53+
"data": {
54+
"text/plain": [
55+
"'Hello! How can I assist you today?'"
56+
]
57+
},
58+
"execution_count": 1,
59+
"metadata": {},
60+
"output_type": "execute_result"
61+
}
62+
],
63+
"source": [
64+
"from langchain.chat_models import ChatOpenAI\n",
65+
"\n",
66+
"llm = ChatOpenAI()\n",
67+
"llm.predict(\"Hello, world!\")"
68+
]
69+
},
70+
{
71+
"cell_type": "markdown",
72+
"id": "cb6bddf0",
73+
"metadata": {},
74+
"source": [
75+
"and this is the output of the run in langsmith's dashboard\n",
76+
"\n",
77+
"![](imgs/smith-getstarted.png)"
78+
]
79+
},
80+
{
81+
"cell_type": "code",
82+
"execution_count": null,
83+
"id": "2988c6d1",
84+
"metadata": {},
85+
"outputs": [],
86+
"source": []
87+
}
88+
],
89+
"metadata": {
90+
"kernelspec": {
91+
"display_name": "Python 3 (ipykernel)",
92+
"language": "python",
93+
"name": "python3"
94+
},
95+
"language_info": {
96+
"codemirror_mode": {
97+
"name": "ipython",
98+
"version": 3
99+
},
100+
"file_extension": ".py",
101+
"mimetype": "text/x-python",
102+
"name": "python",
103+
"nbconvert_exporter": "python",
104+
"pygments_lexer": "ipython3",
105+
"version": "3.10.12"
106+
}
107+
},
108+
"nbformat": 4,
109+
"nbformat_minor": 5
110+
}

0 commit comments

Comments
 (0)