Skip to content

Commit

Permalink
Refactored code to use LANGCHAIN_ENDPOINT environment variable for AP…
Browse files Browse the repository at this point in the history
…I calls (#250)
  • Loading branch information
jgroetzi authored Jul 30, 2024
1 parent 668182e commit de2c955
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tracing-examples/rest/rest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"run_id = str(uuid.uuid4())\n",
"\n",
"res = requests.post(\n",
" \"https://api.smith.langchain.com/runs\",\n",
" f\"{os.environ['LANGCHAIN_ENDPOINT']}/runs\",\n",
" json={\n",
" \"id\": run_id,\n",
" \"name\": \"MyFirstRun\",\n",
Expand All @@ -106,7 +106,7 @@
"# ... do some work ...\n",
"\n",
"requests.patch(\n",
" f\"https://api.smith.langchain.com/runs/{run_id}\",\n",
" f\"{os.environ['LANGCHAIN_ENDPOINT']}/runs/{run_id}\",\n",
" json={\n",
" \"outputs\": {\"my_output\": \"Bar\"},\n",
" \"end_time\": datetime.datetime.utcnow().isoformat(),\n",
Expand Down Expand Up @@ -173,7 +173,7 @@
"run_id = str(uuid.uuid4())\n",
"\n",
"requests.post(\n",
" \"https://api.smith.langchain.com/runs\",\n",
" f\"{os.environ['LANGCHAIN_ENDPOINT']}/runs\",\n",
" json={\n",
" \"id\": run_id,\n",
" \"name\": \"MySecondRun\",\n",
Expand All @@ -198,7 +198,7 @@
"events.append({\"event_name\": \"new_token\", \"value\": \"foo\"})\n",
"\n",
"res = requests.patch(\n",
" f\"https://api.smith.langchain.com/runs/{run_id}\",\n",
" f\"{os.environ['LANGCHAIN_ENDPOINT']}/runs/{run_id}\",\n",
" json={\n",
" \"end_time\": datetime.datetime.utcnow().isoformat(),\n",
" \"outputs\": {\"generated\": \"Bar\"},\n",
Expand Down Expand Up @@ -282,7 +282,7 @@
"source": [
"run_id = str(uuid.uuid4())\n",
"requests.post(\n",
" \"https://api.smith.langchain.com/runs\",\n",
" f\"{os.environ['LANGCHAIN_ENDPOINT']}/runs\",\n",
" json={\n",
" \"id\": run_id,\n",
" \"name\": \"MyChatModelRun\",\n",
Expand Down Expand Up @@ -321,7 +321,7 @@
")\n",
"\n",
"requests.patch(\n",
" f\"https://api.smith.langchain.com/runs/{run_id}\",\n",
" f\"{os.environ['LANGCHAIN_ENDPOINT']}/runs/{run_id}\",\n",
" json={\n",
" \"end_time\": datetime.datetime.utcnow().isoformat(),\n",
" \"outputs\": {\n",
Expand Down Expand Up @@ -394,7 +394,7 @@
"source": [
"run_id = str(uuid.uuid4())\n",
"requests.post(\n",
" \"https://api.smith.langchain.com/runs\",\n",
" f\"{os.environ['LANGCHAIN_ENDPOINT']}/runs\",\n",
" json={\n",
" \"id\": run_id,\n",
" \"name\": \"MyLLMRun\",\n",
Expand All @@ -412,7 +412,7 @@
")\n",
"\n",
"requests.patch(\n",
" f\"https://api.smith.langchain.com/runs/{run_id}\",\n",
" f\"{os.environ['LANGCHAIN_ENDPOINT']}/runs/{run_id}\",\n",
" json={\n",
" \"end_time\": datetime.datetime.utcnow().isoformat(),\n",
" \"outputs\": {\n",
Expand Down Expand Up @@ -473,7 +473,7 @@
" self, data: dict, name: str, run_id: str, parent_run_id: Optional[str] = None\n",
" ) -> None:\n",
" requests.post(\n",
" \"https://api.smith.langchain.com/runs\",\n",
" f\"{os.environ['LANGCHAIN_ENDPOINT']}/runs\",\n",
" json={\n",
" \"id\": run_id,\n",
" \"name\": name,\n",
Expand All @@ -490,7 +490,7 @@
" self, run_id: str, output: Optional[dict] = None, error: Optional[str] = None\n",
" ) -> None:\n",
" requests.patch(\n",
" f\"https://api.smith.langchain.com/runs/{run_id}\",\n",
" f\"{os.environ['LANGCHAIN_ENDPOINT']}/runs/{run_id}\",\n",
" json={\n",
" \"error\": error,\n",
" \"outputs\": output,\n",
Expand Down Expand Up @@ -654,7 +654,7 @@
],
"source": [
"requests.post(\n",
" \"https://api.smith.langchain.com/runs\",\n",
" f\"{os.environ['LANGCHAIN_ENDPOINT']}/runs\",\n",
" json={\n",
" \"name\": \"MyLLMRun\",\n",
" \"run_type\": \"llm\",\n",
Expand Down

0 comments on commit de2c955

Please sign in to comment.