Setting up OpenAI API Key for Folder Analysis Project To configure your OpenAI API key and run the folder analysis project, follow the steps below.
Environment Setup
root@DESKTOP-4N2JHAU ~/a/analysisproj (master)# tree -L 2 -a
.
├── .env
.env File
OPENAI_API_KEY=sk-*************
Install code LLAMA3-8B
./llama-server --port 9090 --hf-repo hugging-quants/Llama-3.2-3B-Instruct-Q4_K_M-GGUF --hf-file llama-3.2-3b-instruct-q4_k_m.gguf -c 4096 --n-gpu-layers 28
Custom Configuration
In your Rust project, configure the following constants for folder analysis and code summary generation:
main.rs
// Server port configuration
const SERVER_PORT: u16 = 3030;
// List of code file extensions to filter
const CODE_FILE_EXTENSIONS: &[&str] = &[
"rs", "py", "js", "ts", "java", "cpp", "c", "go", "sh", "rb", "bat", "cs", "resx", "h", "md",
];
// GPT prompt for folder analysis (includes placeholders {})
const FOLDER_ANALYSIS_PROMPT: &str = "Based on the following folder names, identify potential source code directories written by the user. Return a JSON structure with the key 'analysis_key' and a list of directories that match the criteria:\n{folders}\n{extra_folders}";
// GPT prompt for code summarization
const FILE_SUMMARY_PROMPT: &str = "Generate a concise summary for the following code (no more than 100 words). Use professional software engineering terminology and retain the original variable names for easy analysis. Please describe in Traditional Chinese:\n{}";
// Project directory path
const PROJECT_PATH: &str = "/root/Ghost";
Running the Project
To execute the project, use the following command:
cargo run
This will start the folder analysis process, leveraging the OpenAI API for generating summaries and insights.
Demo Output Here are example outputs from running the analysis:
By following these instructions, you can run the project and analyze folder structures with automated code summaries.