Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSPostPatch #423

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions docs/tracing/faq/customizing_trace_attributes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ chat_completion = client.chat.completions.create(
messages=messages,
)
# End and submit the run
rt.end(outputs=chat_completion)
rt.post()
await rt.end(outputs=chat_completion)
rt.postRun()
`),
TypeScriptBlock(`import OpenAI from "openai";
import { RunTree } from "langsmith";\n
Expand All @@ -100,13 +100,14 @@ const rt = new RunTree({
// highlight-next-line
project_name: "My Project"
})
await rt.postRun();
const chatCompletion = await client.chat.completions.create({
model: "gpt-3.5-turbo",
messages: messages,
});
// End and submit the run
rt.end(chatCompletion)
await rt.postRun()`),
await rt.end(chatCompletion);
await rt.patchRun();`),
LangChainPyBlock(`# You can set the project name for a specific tracer instance:
from langchain.callbacks.tracers import LangChainTracer\n
tracer = LangChainTracer(project_name="My Project")
Expand Down Expand Up @@ -185,8 +186,8 @@ chat_completion = client.chat.completions.create(
messages=messages,
)
# End and submit the run
rt.end(outputs=chat_completion)
rt.post()`),
await rt.end(outputs=chat_completion)
rt.postRun()`),
TypeScriptBlock(`import OpenAI from "openai";
import { RunTree } from "langsmith";\n
const client = new OpenAI();\n
Expand All @@ -204,13 +205,14 @@ const rt = new RunTree({
// highlight-next-line
extra: {metadata: {"my-key": "my-value"}}
})
await rt.postRun();
const chatCompletion = await client.chat.completions.create({
model: "gpt-3.5-turbo",
messages: messages,
});
// End and submit the run
rt.end(chatCompletion)
await rt.postRun()`),
await rt.end(chatCompletion)
await rt.patchRun()`),
LangChainPyBlock(`from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser\n
Expand Down Expand Up @@ -282,8 +284,8 @@ chat_completion = client.chat.completions.create(
messages=messages,
)
# End and submit the run
rt.end(outputs=chat_completion)
rt.post()`),
await rt.end(outputs=chat_completion)
rt.postRun()`),
TypeScriptBlock(`import OpenAI from "openai";
import { RunTree } from "langsmith";\n
const client = new OpenAI();\n
Expand All @@ -298,13 +300,14 @@ const rt = new RunTree({
name: "OpenAI Call RunTree",
inputs: { messages },
})
await rt.postRun()
const chatCompletion = await client.chat.completions.create({
model: "gpt-3.5-turbo",
messages: messages,
});
// End and submit the run
rt.end(chatCompletion)
await rt.postRun()`),
await rt.end(chatCompletion)
await rt.patchRun()`),
LangChainPyBlock(`# When tracing within LangChain, run names default to the class name of the traced object (e.g., 'ChatOpenAI').
# (Note: this is not currently supported directly on LLM objects.)
...
Expand Down
14 changes: 8 additions & 6 deletions docs/tracing/faq/logging_and_viewing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ pipeline = RunTree(
run_type="chain",
inputs={"question": question}
)
await pipeline.postRun();
# This can be retrieved in a retrieval step
context = "During this morning's meeting, we solved all world conflict."
messages = [
Expand All @@ -206,9 +207,9 @@ chat_completion = client.chat.completions.create(
)
# End the runs and log them
child_llm_run.end(outputs=chat_completion)
child_llm_run.post()
child_llm_run.postRun()
pipeline.end(outputs={"answer": chat_completion.choices[0].message.content})
pipeline.post()`),
pipeline.postRun()`),
TypeScriptBlock(`import OpenAI from "openai";
import { RunTree } from "langsmith";
// This can be a user input to your app
Expand Down Expand Up @@ -239,8 +240,8 @@ const chatCompletion = await client.chat.completions.create({
// End the runs and log them
childRun.end(chatCompletion);
await childRun.postRun();
pipeline.end({ outputs: { answer: chatCompletion.choices[0].message.content } });
await pipeline.postRun();`),
await pipeline.end({ outputs: { answer: chatCompletion.choices[0].message.content } });
await pipeline.patchRun();`),
]}
groupId="client-language"
/>
Expand Down Expand Up @@ -369,7 +370,7 @@ chat_completion = client.chat.completions.create(
model="gpt-3.5-turbo", messages=messages
)
rt.end(outputs=chat_completion)
rt.post()
rt.postRun()
print("RunTree Run ID: ", run_id)\n
# Collect run ID using openai_wrapper
run_id = uuid4()
Expand Down Expand Up @@ -415,12 +416,13 @@ const rt = new RunTree({
inputs: { messages },
id: runId
})
await rt.postRun();
const chatCompletion = await client.chat.completions.create({
model: "gpt-3.5-turbo",
messages: messages,
});
rt.end(chatCompletion)
await rt.postRun()
await rt.patchRun()
console.log("Run ID: ", runId);`),
APIBlock(`import openai
import requests\n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,14 @@ const rt = new RunTree({
// highlight-next-line
extra: { metadata: { "my-key": "my-value" } },
});
await rt.postRun();
const chatCompletion = await client.chat.completions.create({
model: "gpt-3.5-turbo",
messages: messages,
});
// End and submit the run
rt.end(chatCompletion);
await rt.postRun();`),
await rt.end(chatCompletion);
await rt.patchRun();`),
]}
groupId="client-language"
/>
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ chat_completion = client.chat.completions.create(
)
# End the runs and log them
child_llm_run.end(outputs=chat_completion)
child_llm_run.post()
child_llm_run.postRun()
pipeline.end(outputs={"answer": chat_completion.choices[0].message.content})
pipeline.post()`),
pipeline.postRun()`),
TypeScriptBlock(`import OpenAI from "openai";
import { RunTree } from "langsmith";
// This can be a user input to your app
Expand All @@ -237,6 +237,7 @@ const pipeline = new RunTree({
run_type: "chain",
inputs: { question }
});
await pipeline.postRun();\n
// This can be retrieved in a retrieval step
const context = "During this morning's meeting, we solved all world conflict.";
const messages = [
Expand All @@ -259,7 +260,7 @@ const chatCompletion = await client.chat.completions.create({
childRun.end(chatCompletion);
await childRun.postRun();
pipeline.end({ outputs: { answer: chatCompletion.choices[0].message.content } });
await pipeline.postRun();`),
await pipeline.patchRun();`),
]}
groupId="client-language"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ chat_completion = client.chat.completions.create(
)
# End and submit the run
rt.end(outputs=chat_completion)
rt.post()
rt.postRun()
`),
TypeScriptBlock(`import OpenAI from "openai";
import { traceable } from "langsmith/traceable";
Expand Down Expand Up @@ -124,10 +124,11 @@ const rt = new RunTree({
inputs: { messages },
// highlight-next-line
project_name: "My Project"
});\n
});
await rt.postRun();\n
// Execute a chat completion and handle it within RunTree
rt.end({outputs: chatCompletion});
await rt.postRun();`),
await rt.patchRun();`),
]}
groupId="client-language"
/>
Loading