Skip to content

Fix streamlit app error #9

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
GEMINI_PROJECT_ID=<GEMINI_PROJECT_ID>
GITHUB_TOKEN=<GITHUB_TOKEN>
# Google Gemini API Configuration
GEMINI_PROJECT_ID=<your-project-id>
GEMINI_LOCATION=us-central1
GEMINI_MODEL=gemini-2.5-pro-exp-03-25
# Uncomment if using API key instead of project ID
# GEMINI_API_KEY=<your-api-key>

# Alternative LLM APIs (uncomment to use)
# ANTHROPIC_API_KEY=<your-anthropic-api-key>
# OPENAI_API_KEY=<your-openai-api-key>

# GitHub API Configuration
GITHUB_TOKEN=<your-github-token>

# Logging Configuration
LOG_DIR=logs

# Cache Configuration
CACHE_ENABLED=true
CACHE_FILE=llm_cache.json

# Streamlit Configuration
STREAMLIT_SERVER_PORT=8501
STREAMLIT_SERVER_HEADLESS=true
STREAMLIT_SERVER_ADDRESS=0.0.0.0
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
45 changes: 45 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM python:3.10-slim

WORKDIR /app

# Install system dependencies including Git, bash, and PDF conversion tools
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
bash \
pandoc \
wkhtmltopdf \
texlive-xetex \
texlive-fonts-recommended \
texlive-plain-generic \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Copy requirements first for better caching
COPY requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application
COPY . .

# Create necessary directories with proper permissions
RUN mkdir -p logs output && chmod -R 777 logs output

# Expose the Streamlit port
EXPOSE 8501

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV STREAMLIT_SERVER_PORT=8501
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
ENV STREAMLIT_SERVER_HEADLESS=true
ENV LOG_DIR=/app/logs
ENV CACHE_FILE=/app/llm_cache.json
ENV CACHE_ENABLED=true
ENV GIT_PYTHON_REFRESH=quiet
ENV OUTPUT_DIR=/app/output

# Default command (can be overridden by docker-compose)
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
55 changes: 39 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,29 @@ This is a tutorial project of [Pocket Flow](https://github.com/The-Pocket/Pocket

## 🚀 Getting Started

### Option 1: Using Docker (Recommended)

1. Clone this repository

2. Configure your environment variables in the `.env` file:
```bash
# Copy the sample .env file
cp .env.sample .env

# Edit the .env file with your credentials
# GEMINI_PROJECT_ID=your-project-id
# GITHUB_TOKEN=your-github-token
```

3. Run the application using Docker Compose:
```bash
docker-compose up -d
```

4. Access the Streamlit web interface at http://localhost:8501

### Option 2: Manual Installation

1. Clone this repository

2. Install dependencies:
Expand All @@ -82,22 +105,22 @@ This is a tutorial project of [Pocket Flow](https://github.com/The-Pocket/Pocket
```bash
python utils/call_llm.py
```

7. Generate a complete codebase tutorial by running the main script:
```bash
# Analyze a GitHub repository
python main.py --repo https://github.com/username/repo --include "*.py" "*.js" --exclude "tests/*" --max-size 50000

# Or, analyze a local directory
python main.py --dir /path/to/your/codebase --include "*.py" --exclude "*test*"
```
- `--repo` or `--dir` - Specify either a GitHub repo URL or a local directory path (required, mutually exclusive)
- `-n, --name` - Project name (optional, derived from URL/directory if omitted)
- `-t, --token` - GitHub token (or set GITHUB_TOKEN environment variable)
- `-o, --output` - Output directory (default: ./output)
- `-i, --include` - Files to include (e.g., "*.py" "*.js")
- `-e, --exclude` - Files to exclude (e.g., "tests/*" "docs/*")
- `-s, --max-size` - Maximum file size in bytes (default: 100KB)
4. Run the Streamlit web interface:
```bash
streamlit run app.py
```

Or generate a complete codebase tutorial directly using the command line:
```bash
python main.py https://github.com/username/repo --include "*.py" "*.js" --exclude "tests/*" --max-size 50000
```
- `repo_url` - URL of the GitHub repository (required)
- `-n, --name` - Project name (optional, derived from URL if omitted)
- `-t, --token` - GitHub token (or set GITHUB_TOKEN environment variable)
- `-o, --output` - Output directory (default: ./output)
- `-i, --include` - Files to include (e.g., "*.py" "*.js")
- `-e, --exclude` - Files to exclude (e.g., "tests/*" "docs/*")
- `-s, --max-size` - Maximum file size in bytes (default: 100KB)

The application will crawl the repository, analyze the codebase structure, generate tutorial content, and save the output in the specified directory (default: ./output).

Expand Down
Loading