Replies: 1 comment 7 replies
-
Hey there, @apoorvkk! 👋 I'm here to help you with any bugs, questions, or contributions you have in mind. Let's tackle this together! To disable logging to Langsmith for custom Python threads that call an LLM via Langchain, you can set the from contextvars import ContextVar
from concurrent.futures import ThreadPoolExecutor, as_completed
# Assuming tracing_v2_callback_var is imported from the relevant module
tracing_v2_callback_var: ContextVar[Optional[LangChainTracer]] = ContextVar(
"tracing_callback_v2", default=None
)
def process_search(search, syllabus):
# Disable tracing for this thread
tracing_v2_callback_var.set(None)
# Your code that processes the search
# ...
def questions_filter(state: AgentState):
searches = state["searches"]
subject_details = state["subject_details"]
syllabus = generate_syllabus_prompt(subject_details)
updated_searches = []
all_already_seen_question_chunk_ids = []
with ThreadPoolExecutor() as executor:
futures = [
executor.submit(process_search, search, syllabus)
for search in searches
]
results = [future.result() for future in as_completed(futures)]
for search, already_seen_question_chunk_ids in results:
updated_searches.append(search)
all_already_seen_question_chunk_ids.extend(already_seen_question_chunk_ids)
return {
"searches": updated_searches,
"already_seen_question_chunk_ids": list(set(state["already_seen_question_chunk_ids"] + all_already_seen_question_chunk_ids))
} By setting |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
Hi all,
I was just curious on how can one disable logging to Langsmith when I create a new custom Python thread which calls an LLM via langchain? Please note these are standard Python threads. I would like to disable tracing for these spawned threads during runtime.
Please see the code reference of how I am spawning threads within a node of my Langgraph.
Thank you!
System Info
langchain = "^0.2.6"
mac
python3
Beta Was this translation helpful? Give feedback.
All reactions