Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lucianoayres/cypher
Cypher is an AI model that creates optimized summaries of source code, reducing prompt size and saving tokens when submitting to LLMs. By leveraging Ollama, Cypher captures essential relationships and dependencies, enabling efficient, architecture-aware insights with ease.
https://github.com/lucianoayres/cypher
ai coding llama llm modelfile ollama prompt-engineering
Last synced: 14 days ago
JSON representation
Cypher is an AI model that creates optimized summaries of source code, reducing prompt size and saving tokens when submitting to LLMs. By leveraging Ollama, Cypher captures essential relationships and dependencies, enabling efficient, architecture-aware insights with ease.
- Host: GitHub
- URL: https://github.com/lucianoayres/cypher
- Owner: lucianoayres
- License: mit
- Created: 2024-11-02T16:04:08.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-09T09:38:08.000Z (about 2 months ago)
- Last Synced: 2024-12-03T16:42:12.121Z (about 1 month ago)
- Topics: ai, coding, llama, llm, modelfile, ollama, prompt-engineering
- Homepage:
- Size: 8.07 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ฆ Cypher
![Cypher Banner](https://github.com/lucianoayres/cypher/blob/main/images/banner_cypher.png?raw=true)
## Smart Code Summaries for Token-Efficient LLM Power
[๐ฆพ Overview](#overview) ยท [๐ง Why Use Cypher](#why-use-cypher) ยท [โจ Features](#features) ยท [๐ How It Works](#how-it-works) ยท [๐งฉ Method](#method) ยท [๐ ๏ธ How to Use](#how-to-use) ยท [๐ Examples](#examples) ยท [๐ Template](#template-) ยท [๐ License](#license) ยท [๐ค Contribution](#contribution)
---
### ๐ฆพ Overview
Cypher is an AI-powered code summarizer tailored for efficient navigation of large codebases. Using a dedicated [Modelfile](./modelfiles/Cypher1.0), Cypher captures essential code relationships and dependencies, generating optimized, architecture-aware summaries that enable AI to offer insightful support for architectural decisions without analyzing the entire source code.
### ๐ง Why Use Cypher
- ๐ฆ **Unique Summarization Method**: Uses a specialized approach that organizes summaries by focusing on roles, interfaces, dependencies, and execution flow.
- ๐ป **Token-Efficient**: Optimizes prompt size, allowing AI models to handle extensive projects.
- ๐งฉ **Architectural Insight**: Captures essential code relationships and dependencies, enhancing AI's decision-making.
- ๐ **Flexible**: Works with projects of any size, from small modules to large enterprise systems.
- โฒ๏ธ **Time-Saving**: Automates summarization to provide critical context with minimal user input.### โจ Features
- ๐งฌ **Token-Efficient Summarization**: Generates summaries within LLM token limits, retaining essential architectural context.
- ๐ ๏ธ **Architecture-Aware Analysis**: Identifies code relationships and dependencies for high-level insights.
- ๐ **Versatile Usage**: Operates as both a custom Modelfile and a flexible prompt for any LLM.
- ๐ **Decision Support**: Empowers LLMs to offer informed suggestions without requiring the entire codebase.---
### ๐ How It Works
1. **Input Code** ๐: Cypher is provided with the project code, focusing on architecture and structure.
2. **Summarization Process** ๐งฌ: Cypher analyzes code, creating a structured summary of relationships and dependencies.
3. **Model File or Prompt Generation** ๐ฆพ: This summary serves as a Modelfile or prompt, delivering a comprehensive project overview.
4. **AI-Enhanced Insights** ๐ง โจ: With Cypher's summary, AI offers targeted advice without the full code, ideal for architecture decisions.---
### ๐งฉ Method
Cypher uses a unique and original **Integrated Summarization Method** that combines multiple summarization techniques to provide a multi-layered, concise overview of complex codebases. This method organizes the summary by focusing on **Roles**, **Interfaces**, **Dependencies**, **Execution Flow**, and **Hierarchy**, creating a comprehensive yet token-efficient representation.
- ๐ฆ **Role-Based Overview and Dependencies**: Groups code into functional roles, summarizing each fileโs purpose and listing primary dependencies.
- ๐ **Interface Summarization**: Lists key functions, their parameters, return types, and dependencies to show how each function interfaces with others.
- ๐ **Execution Flow Summary**: Provides a step-by-step breakdown of the applicationโs execution flow, illustrating module interactions.
- ๐ **Dependency Graph and Hierarchical Structure**: Visualizes file dependencies and organizes the project hierarchy, showing modularity and connections.
- ๐ก **Comment Extraction and Key Logic Details**: Highlights important comments, constants, unique logic, and edge-case handling, capturing key design decisions.This approach integrates multiple summarization techniques for a comprehensive, structured overview of the codebase.
---
### ๐ ๏ธ How to Use
Cypher smartly summarizes your code, providing a concise output for further use with any LLM of your choice.
#### 1. Select Your Source Code
Choose the code or snippet youโd like summarized. Cypher will analyze it and generate an efficient overview.
#### 2. Clone the Cypher Repository
Clone the Cypher repository:
```bash
git clone https://github.com/lucianoayres/cypher.git
cd cypher
```#### 3. Set Up the Cypher Modelfile
Ensure [Ollama](https://github.com/ollama/ollama) is installed, then create the Cypher model:
```bash
ollama create cypher -f ./modelfiles/Cypher1.0
```#### 4. Run Cypher
Execute Cypher to generate a summary of your code:
```bash
ollama run cypher
```#### 5. Input Your Code
Provide the source code when prompted. Cypher will process the code and output a smart summary, completing its task.
#### 6. Save the Summary (Optional)
To save the Cypher output automatically, use [Nino](https://github.com/lucianoayres/nino-cli). This allows you to save the summary locally for easy reference.
---
### ๐ Examples
Find various sample source code files in different programming languages [in the examples](./examples). These samples help you easily evaluate how Cypher handles different languages and coding styles.
#### Using Examples with Nino CLI
Users can utilize these example files as prompts for Cypher to generate summaries. Below are sample commands using the [Nino CLI](https://github.com/lucianoayres/nino-cli):
##### Python Example:
```bash
nino -model cypher -prompt-file ./examples/text_to_morse.py
```##### Java Example:
```bash
nino -model cypher -prompt-file ./examples/Payment.java
```##### JavaScript Example:
```bash
nino -model cypher -prompt-file ./examples/tic-tac-toe.js
```##### C# Example:
```bash
nino -model cypher -prompt-file ./examples/TaskTrackerApp.cs
```### ๐ Recommendations for Better Results
To achieve more accurate summaries, follow these guidelines:
๐ **Use Specific Code Snippets**: Instead of submitting entire files or projects, provide focused code snippets that highlight the areas you want to summarize.
๐ **Handle Large Files Appropriately**: If a source file is too large, extract the relevant parts and save them in a separate text file. Use this smaller file as the input prompt for the model.
๐งฉ **Break Down Extensive Codebases**: Divide large codebases into smaller, manageable sections. Process each section in separate interactions with Cypher to ensure detailed and precise analysis without overwhelming the system.
๐ก **HINT**: Use [**Taco**](https://github.com/lucianoayres/taco) ๐ฎ to selectively choose source code project files and merge them into a single text file. This makes it easy to create prompts for Cypher with specific files from your project, enhancing the efficiency of your summarization process.
### Template ๐
Cypher's primary focus is the [Cypher Modelfile](./modelfiles/Cypher1.0), but prompt examples for usage are available in the [prompts directory](./prompts). These templates offer guidance for crafting tailored summaries and help illustrate Cypherโs flexibility.
**Structure**:
1. **Objective and Rules** ๐: Defines the summary purpose and guidelines to ensure effective analysis.
2. **Command Specification** ๐ ๏ธ: Core Modelfile commands, such as:
- **META**: Adds metadata and model info.
- **FROM**: Specifies the base model (e.g., `llama3.2`).
- **PARAMETER**: Sets key parameters for summary generation.
- **SYSTEM**: Sets the model system prompt.
- **MESSAGE**: Provides initial prompts for effective summarization.
- **LICENSE**: Includes licensing details.---
### ๐ฆ Create Custom AI Models with Modelzilla
Looking to build your own AI models? Use [**Modelzilla**](https://github.com/lucianoayres/modelzilla) ๐ฆ to effortlessly generate customized Modelfiles.
---
### ๐ License
Cypher is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
---
### ๐ค Contribution
Your input is welcome! Feel free to open an issue or submit a pull request with suggestions, improvements, or new features.