-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/plasma-umass/ChatDBG
- Loading branch information
Showing
10 changed files
with
162 additions
and
108 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -12,7 +12,7 @@ authors = [ | |
{ name="Stephen Freund", email="[email protected]" }, | ||
] | ||
dependencies = [ | ||
"llm-utils>=0.2.6", | ||
"llm-utils>=0.2.8", | ||
"openai>=1.6.1", | ||
"rich>=13.7.0", | ||
"ansicolors>=1.1.8", | ||
|
@@ -22,6 +22,7 @@ dependencies = [ | |
"litellm>=1.26.6", | ||
"PyYAML>=6.0.1", | ||
"ipyflow>=0.0.130", | ||
"numpy>=1.26.3" | ||
] | ||
description = "AI-assisted debugging. Uses AI to answer 'why'." | ||
readme = "README.md" | ||
|
This file contains 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 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 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 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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import argparse | ||
import os | ||
import textwrap | ||
from typing import Any, List, Optional, Tuple | ||
|
||
|
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import ast | ||
import inspect | ||
import textwrap | ||
|
||
class SymbolFinder(ast.NodeVisitor): | ||
def __init__(self): | ||
self.defined_symbols = set() | ||
|
||
def visit_Assign(self, node): | ||
for target in node.targets: | ||
if isinstance(target, ast.Name): | ||
self.defined_symbols.add(target.id) | ||
self.generic_visit(node) | ||
|
||
def visit_For(self, node): | ||
if isinstance(node.target, ast.Name): | ||
self.defined_symbols.add(node.target.id) | ||
self.generic_visit(node) | ||
|
||
def visit_comprehension(self, node): | ||
if isinstance(node.target, ast.Name): | ||
self.defined_symbols.add(node.target.id) | ||
self.generic_visit(node) | ||
|
||
def extract_locals(frame): | ||
try: | ||
source = textwrap.dedent(inspect.getsource(frame)) | ||
tree = ast.parse(source) | ||
|
||
finder = SymbolFinder() | ||
finder.visit(tree) | ||
|
||
args, varargs, keywords, locals = inspect.getargvalues(frame) | ||
parameter_symbols = set(args + [ varargs, keywords ]) | ||
parameter_symbols.discard(None) | ||
|
||
return (finder.defined_symbols | parameter_symbols) & locals.keys() | ||
except: | ||
# ipes | ||
return set() | ||
|
||
def extract_nb_globals(globals): | ||
result = set() | ||
for source in globals["In"]: | ||
try: | ||
tree = ast.parse(source) | ||
finder = SymbolFinder() | ||
finder.visit(tree) | ||
result = result | (finder.defined_symbols & globals.keys()) | ||
except Exception as e: | ||
pass | ||
return result |
This file contains 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 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
Oops, something went wrong.