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

Option to include external libraries into context #437

Open
ztxtz opened this issue Jan 2, 2024 · 4 comments
Open

Option to include external libraries into context #437

ztxtz opened this issue Jan 2, 2024 · 4 comments

Comments

@ztxtz
Copy link

ztxtz commented Jan 2, 2024

When implementing something, it happens a lot (>20% of cases) that the LLM tries to use outdated function names of an external library.

When this happens, there should be an option to include the external library in the context as well in order for the LLM to understand how to use it properly.

For example, a Ruby project might have a few files in it, one of which would try to use an external library Eth::Utils.bin_to_hex. But since the LLM was trained, the naming has changed slightly and now it's Eth::Util.bin_to_hex (no "s"). Since Eth is an external library and is not placed in the project directory, mentat has no access to it and doesn't inject it into the context.

To fix it, we can add some way to access the external library (which is already on the local drive but not inside of the current directory) into context.

@jakethekoenig
Copy link
Member

If you know the path you should be able to do this yourself with /include. For instance I've run /include node_modules/path/to/file and /include venv/path/to/file. I'm not sure how we could have it happen automagically in an ergonomic way. Most of the time you wouldn't want it because it eats up context and the LLM actually does know the right function name.

@jasonhildebrand
Copy link

I've tried using /include to do this, but the library I'm trying to include is within a vendor directory (installed by composer), and therefore is also in .gitignore.

Mentat appears to accept the /include command, but doesn't actually add the file to the context. IMO it would solve a big usability issue if it were possible to explicitly /include files even if they are being git ignored.

@jakethekoenig
Copy link
Member

jakethekoenig commented Feb 26, 2024

@jasonhildebrand What version of mentat are you using? It appears to work to me. I have venv gitignored. If I create venv/a and run /include venv/a I see mentat add it to context and when I make a query and run /viewer I can see the content of venv/a is correctly added.

What won't work is adding directories recursively. e.g. if you run /include venv no files will be added to context.

@jasonhildebrand
Copy link

I'm using 1.0.10 - the latest release.

Thanks for clarifying. I did a different test and tried to include a single file, and that worked. I had only ever tried this on a directory, which doesn't work.

That's helpful that this at least work for single files. In the future it would be great if it worked on directories too.

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

No branches or pull requests

3 participants