-
Notifications
You must be signed in to change notification settings - Fork 90
Error Analysis API #208
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
Open
recursix
wants to merge
27
commits into
main
Choose a base branch
from
error-analysis
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Error Analysis API #208
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
048a622
Add initial implementation of ChangeSummarizer and EpisodeAnalysis cl…
recursix fd8fd95
Added chain summarizer prompt
Megh-Thakkar b8c85b1
Added error classification prompt
Megh-Thakkar 5cb6cc2
Fix typo
jardinetsouffleton 9f531cc
Update error_analysis.py
Megh-Thakkar 31e5bf5
added pipeline and tests
TLSDC 000893d
quick parsing to run from cligit push
TLSDC 4727a9e
even more parsing and making imports absolute
TLSDC 42f0362
.
TLSDC 394999b
chat_models can take str as input
TLSDC e0e786c
typing
TLSDC 46d2c8c
keep this here bc it's going to pop back up
TLSDC 8a882ad
pipeline mvp
TLSDC 3fab5b4
added a specific tab and viz for it in xray
TLSDC 2be23e5
added formatting options
TLSDC 41f8f69
Update summarizer_prompts.py
Megh-Thakkar 6163b47
xml parsing
TLSDC a1f3416
fix
TLSDC a455d0d
add error analysis prediction validation script
jardinetsouffleton 82dbaba
black version update
TLSDC 5fbbe57
phony command, joblib stuff, took think out of prompt
TLSDC 3a3d602
task_info
TLSDC 5bf1bac
added flag to oracle success or no
TLSDC c7b1c5a
Merge branch 'main' into error-analysis
TLSDC 0972130
darglint
TLSDC ec1395b
Merge branch 'error-analysis' of github.com:ServiceNow/AgentLab into …
TLSDC 46d1075
tests
TLSDC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,11 @@ def __call__(self, *args, **kwds): | |
| return "analysis" | ||
|
|
||
|
|
||
| def analyze(exp_result, episode_summarizer, save_analysis_func): | ||
| error_analysis = episode_summarizer(exp_result) | ||
| save_analysis_func(exp_result, error_analysis) | ||
|
|
||
|
|
||
| @dataclass | ||
| class ErrorAnalysisPipeline: | ||
| exp_dir: Path | ||
|
|
@@ -36,12 +41,21 @@ def filter_exp_results(self) -> Generator[ExpResult, None, None]: | |
| if self.filter is None or self.filter in str(exp_result.exp_dir): | ||
| yield exp_result | ||
|
|
||
| def run_analysis(self): | ||
| def run_analysis(self, parallel=False, jobs=-1): | ||
| filtered_results = self.filter_exp_results() | ||
|
|
||
| for exp_result in filtered_results: | ||
| error_analysis = self.episode_summarizer(exp_result) | ||
| self.save_analysis(exp_result, error_analysis) | ||
| if parallel: | ||
| import joblib | ||
|
|
||
| joblib.Parallel(n_jobs=jobs, backend="threading")( | ||
| joblib.delayed(analyze)(exp_result, self.episode_summarizer, self.save_analysis) | ||
| for exp_result in filtered_results | ||
| ) | ||
|
|
||
| else: | ||
| for exp_result in filtered_results: | ||
| error_analysis = self.episode_summarizer(exp_result) | ||
| self.save_analysis(exp_result, error_analysis) | ||
|
|
||
| def save_analysis(self, exp_result: ExpResult, error_analysis: dict, exists_ok=True): | ||
| """Save the analysis to json""" | ||
|
|
@@ -56,28 +70,37 @@ def save_analysis(self, exp_result: ExpResult, error_analysis: dict, exists_ok=T | |
| HTML_FORMATTER = lambda x: x.get("pruned_html", "No HTML available") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| def main(): | ||
| import argparse | ||
|
|
||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument("-e", "--exp_dir", type=str) | ||
| parser.add_argument("-f", "--filter", type=str, default=None) | ||
| parser.add_argument("-p", "--parallel", action="store_true") | ||
| parser.add_argument("-j", "--jobs", type=int, default=-1) | ||
|
|
||
| args = parser.parse_args() | ||
|
|
||
| assert args.exp_dir is not None, "Please provide an exp_dir, e.g., -e /path/to/exp_dir" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. required=True? |
||
|
|
||
| exp_dir = Path(args.exp_dir) | ||
| filter = args.filter | ||
| parallel = args.parallel | ||
| jobs = args.jobs | ||
|
|
||
| from agentlab.llm.llm_configs import CHAT_MODEL_ARGS_DICT | ||
|
|
||
| llm = CHAT_MODEL_ARGS_DICT["azure/gpt-4o-2024-08-06"].make_model() | ||
|
|
||
| step_summarizer = ChangeSummarizer(llm, lambda x: x) | ||
| episode_summarizer = EpisodeSummarizer() | ||
|
|
||
| pipeline = ErrorAnalysisPipeline( | ||
| exp_dir=exp_dir, | ||
| filter=filter, | ||
| episode_summarizer=EpisodeErrorSummarizer(ChangeSummarizer(llm, AXTREE_FORMATTER), llm), | ||
| ) | ||
|
|
||
| pipeline.run_analysis() | ||
| pipeline.run_analysis(parallel=parallel, jobs=jobs) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
|
|
||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nicee