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

Add file handler to capture langchain agent logging #1515

Conversation

dagardner-nv
Copy link
Contributor

@dagardner-nv dagardner-nv commented Feb 13, 2024

Description

  • When a compatible version of langchain (0.0.310) is installed agent logs will be directed to a file named agent.log in the user's log dir.
  • This makes use of the astream method (https://python.langchain.com/docs/modules/agents/how_to/streaming#using-agentactionobservation) which is available in langchain 0.0.310, but not in 0.0.190
  • When the AgentExecutor instance contains an astream attribute it is used allowing us to log intermediate steps, otherwise the older arun method is used.

Note: this feature requires langchain 0.0.310 which requires pandas 2.0

By Submitting this PR I confirm:

  • I am familiar with the Contributing Guidelines.
  • When the PR is ready for review, new or existing tests cover these changes.
  • When the PR is ready for review, the documentation is up to date with these changes.

@dagardner-nv dagardner-nv added non-breaking Non-breaking change feature request New feature or request sherlock Issues/PRs related to Sherlock workflows and components labels Feb 13, 2024
@dagardner-nv dagardner-nv self-assigned this Feb 13, 2024
@dagardner-nv dagardner-nv requested a review from a team as a code owner February 13, 2024 17:35
Comment on lines +143 to +145
llm_agent_file_handler = _get_file_handler(llm_agent_log_file)
llm_agent_file_handler.addFilter(logging.Filter(name=LLM_AGENT_LOG_NAME))
llm_agent_logger.addHandler(llm_agent_file_handler)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fyi - This PR updates logger so that you can pass in additional handlers.

@dagardner-nv dagardner-nv marked this pull request as draft February 29, 2024 16:55
@mdemoret-nv mdemoret-nv changed the base branch from branch-24.03 to branch-24.06 April 6, 2024 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request non-breaking Non-breaking change sherlock Issues/PRs related to Sherlock workflows and components
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants