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

mufeedvh/code2prompt: A CLI tool to convert your codebase into a single LLM prompt with source tree, prompt templating, and token counting. #825

Open
1 task
ShellLM opened this issue May 5, 2024 · 1 comment
Labels
CLI-UX Command Line Interface user experience and best practices code-generation code generation models and tools like copilot and aider github gh tools like cli, Actions, Issues, Pages New-Label Choose this option if the existing labels are insufficient to describe the content accurately openai OpenAI APIs, LLMs, Recipes and Evals prompt Collection of llm prompts and notes

Comments

@ShellLM
Copy link
Collaborator

ShellLM commented May 5, 2024

code2prompt

A CLI tool to convert your codebase into a single LLM prompt with source tree, prompt templating, and token counting.

You can run this tool on the entire directory and it would generate a well-formatted Markdown prompt detailing the source tree structure, and all the code. You can then upload this document to either GPT or Claude models with higher context windows and ask it to:

  • Rewrite the code to another language.
  • Find bugs/security vulnerabilities.
  • Document the code.
  • Implement new features.

You can customize the prompt template to achieve any of the desired use cases. It essentially traverses a codebase and creates a prompt with all source files combined. In short, it automates copy-pasting multiple source files into your prompt and formatting them along with letting you know how many tokens your code consumes.

I initially wrote this for personal use to utilize Claude 3.0's 200K context window and it has proven to be pretty useful so I decided to open-source it!

Suggested labels

{'label-name': 'code-automation', 'label-description': 'Tools and techniques for automating code-related processes.', 'confidence': 53.23}

@ShellLM ShellLM added CLI-UX Command Line Interface user experience and best practices code-generation code generation models and tools like copilot and aider github gh tools like cli, Actions, Issues, Pages New-Label Choose this option if the existing labels are insufficient to describe the content accurately openai OpenAI APIs, LLMs, Recipes and Evals prompt Collection of llm prompts and notes labels May 5, 2024
@ShellLM
Copy link
Collaborator Author

ShellLM commented May 5, 2024

Related content

#743 similarity score: 0.87
#706 similarity score: 0.87
#393 similarity score: 0.86
#6 similarity score: 0.86
#658 similarity score: 0.86
#189 similarity score: 0.85

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI-UX Command Line Interface user experience and best practices code-generation code generation models and tools like copilot and aider github gh tools like cli, Actions, Issues, Pages New-Label Choose this option if the existing labels are insufficient to describe the content accurately openai OpenAI APIs, LLMs, Recipes and Evals prompt Collection of llm prompts and notes
Projects
None yet
Development

No branches or pull requests

1 participant