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

Potentially misleading system message #206

Closed
haesleinhuepf opened this issue Sep 17, 2024 · 3 comments · Fixed by #207
Closed

Potentially misleading system message #206

haesleinhuepf opened this issue Sep 17, 2024 · 3 comments · Fixed by #207

Comments

@haesleinhuepf
Copy link
Owner

Currently, the system message mentiones bia-bob and open in a prominent place:

    The following functions are defined: open    
    The following modules or aliases are imported: bia_bob

That might be the reason why these are often proposed. We should remove them from these lists.

@haesleinhuepf
Copy link
Owner Author

This is done in the create_reusable_variables_block function in src/bia_bob/_utilities.py

We should exclude "bob" and "open" from available functions, "bia_bob" from available modules.

git-bob think about this, how would you implement it?

Copy link
Contributor

This message was generated by git-bob (version: 0.2.6, model: gpt-4o-2024-08-06), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

To address the issue, we can modify the create_reusable_variables_block function in src/bia_bob/_utilities.py to exclude "open" and "bob" from the functions list and "bia_bob" from the modules list as follows:

def create_reusable_variables_block():
    """Creates a block of text that explains which variables, functions and libraries are
    available to be used."""
    variables = []
    functions = []
    modules = []
    from ._machinery import Context
    import types

    # figure out which variables are not private
    for key, value in Context.variables.items():
        if key.startswith("_"):
            continue
        if callable(value):
            if key not in ["quit", "exit", "get_ipython", "open", "bob"]:
                functions.append(key)
            continue
        if isinstance(value, types.ModuleType):
            if key != "bia_bob":
                modules.append(key)
            continue
        if key in ["In", "Out"]:
            continue
        variables.append(key)

    return f"""
    The following variables are defined: {",".join([str(v) for v in variables])}    
    The following functions are defined: {",".join([str(v) for v in functions])}    
    The following modules or aliases are imported: {",".join([str(v) for v in modules])}
    """

@haesleinhuepf
Copy link
Owner Author

Great! git-bob implement this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant