Skip to content

Commit

Permalink
add new github summarizor example
Browse files Browse the repository at this point in the history
  • Loading branch information
StephDietz committed Jan 30, 2025
1 parent 0f97492 commit b2e6710
Show file tree
Hide file tree
Showing 7 changed files with 588 additions and 0 deletions.
16 changes: 16 additions & 0 deletions modus-gh-issue-summarizer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Ignore macOS system files
.DS_Store

# Ignore environment variable files
.env
.env.*

# Ignore build output directories
build/

# Ignore Go debuger and generated files
__debug_bin*
*_generated.go
*.generated.go

.modusdb/
108 changes: 108 additions & 0 deletions modus-gh-issue-summarizer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# GitHub Issue Knowledge Base Generator (Modus + Hypermode) 🚀

Check failure on line 1 in modus-gh-issue-summarizer/README.md

View check run for this annotation

Trunk.io / Trunk Check

prettier

Incorrect formatting, autoformat by running 'trunk fmt'

This project automatically generates a Knowledge Base (KB) article when a GitHub issue is closed. It utilizes Hypermode and Modus (a serverless Go framework) to process issue data and generate a structured KB article using an LLM. The article is then posted as a GitHub Discussion.

Check notice on line 3 in modus-gh-issue-summarizer/README.md

View check run for this annotation

Trunk.io / Trunk Check

markdownlint(MD013)

[new] Line length

## 🛠 Features

- Fetches GitHub issue details and comments upon issue closure.
- Uses LLM (Hugging Face model via Hypermode) to generate a detailed KB article.
- Posts the generated KB article as a GitHub Discussion.
- Can be triggered manually or via GitHub Actions.

--

## 🖥️ Running Locally

### 1️⃣ Install Modus

First, install Modus CLI:

```

Check notice on line 20 in modus-gh-issue-summarizer/README.md

View check run for this annotation

Trunk.io / Trunk Check

markdownlint(MD040)

[new] Fenced code blocks should have a language specified
npm install -g @hypermodeinc/modus
```

### 2️⃣ Clone the Repository

```

Check notice on line 26 in modus-gh-issue-summarizer/README.md

View check run for this annotation

Trunk.io / Trunk Check

markdownlint(MD040)

[new] Fenced code blocks should have a language specified
git clone https://github.com/YOUR_USERNAME/YOUR_REPO.git
cd YOUR_REPO
```

### 3️⃣ Start the Modus Dev Server

```

Check notice on line 33 in modus-gh-issue-summarizer/README.md

View check run for this annotation

Trunk.io / Trunk Check

markdownlint(MD040)

[new] Fenced code blocks should have a language specified
modus dev
```

### 4️⃣ Test the API Locally

Go to:

```

Check notice on line 41 in modus-gh-issue-summarizer/README.md

View check run for this annotation

Trunk.io / Trunk Check

markdownlint(MD040)

[new] Fenced code blocks should have a language specified
http://localhost:54321/graphql
```

You'll see an exported function `issueClosedHandler`. Test the KB Article Generation. Enter the repository name and issue number and run the query. The API will return a formatted KB article. You can also post the KB Article as a Discussion. To do so, pass a GitHub API token as well.

Check notice on line 45 in modus-gh-issue-summarizer/README.md

View check run for this annotation

Trunk.io / Trunk Check

markdownlint(MD013)

[new] Line length

--

## 🚀 Deploying to Hypermode

To deploy the function to Hypermode:

```

Check notice on line 53 in modus-gh-issue-summarizer/README.md

View check run for this annotation

Trunk.io / Trunk Check

markdownlint(MD040)

[new] Fenced code blocks should have a language specified
modus deploy
```

Once deployed, copy your Hypermode endpoint, which will be used in the GitHub Action.

--

## 🔧 Setting Up the GitHub Action

This action allows the KB article to be generated automatically when an issue is closed.

### 1️⃣ Clone the Project & Deploy to Hypermode

If you haven't already:

```

Check notice on line 69 in modus-gh-issue-summarizer/README.md

View check run for this annotation

Trunk.io / Trunk Check

markdownlint(MD040)

[new] Fenced code blocks should have a language specified
git clone https://github.com/YOUR_USERNAME/YOUR_REPO.git
cd YOUR_REPO
modus deploy
```

Copy your Hypermode endpoint.

### 2️⃣ Add the GitHub Action

Copy the issue-summarizer.yml file into in your repository:

### 3️⃣ Add Your Hypermode API Key to GitHub Secrets

1. Go to your GitHub repository.
2. Navigate to Settings → Secrets and variables → Actions.
3. Click New repository secret.
4. Name it: `HYPERMODE_API_KEY`
5. Paste your Hypermode API key.
6. Save.

### 4️⃣ Done! 🎉

Now, every time a GitHub issue is closed, a KB article will be generated and posted as a GitHub Discussion.

--

## 🛠 Troubleshooting

GitHub Discussion Not Created?

Ensure:

- You have enabled Discussions under Repository Settings → Features.
- Your GitHub token has the discussions: write permission.

No Response from the API?

- Check if your Modus function is deployed (modus deploy).
- Verify that your Hypermode API key is correct in GitHub Secrets.
14 changes: 14 additions & 0 deletions modus-gh-issue-summarizer/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module modus-gh-issue-summarizer

Check failure on line 1 in modus-gh-issue-summarizer/go.mod

View check run for this annotation

Trunk.io / Trunk Check

osv-scanner(CVE-2024-45336)

[new] Sensitive headers incorrectly sent after cross-domain redirect in net/http. Current version of 'stdlib' is vulnerable: 1.23.3.

Check failure on line 1 in modus-gh-issue-summarizer/go.mod

View check run for this annotation

Trunk.io / Trunk Check

osv-scanner(CVE-2024-45341)

[new] Usage of IPv6 zone IDs can bypass URI name constraints in crypto/x509. Current version of 'stdlib' is vulnerable: 1.23.3.

go 1.23.3

toolchain go1.23.5

require github.com/hypermodeinc/modus/sdk/go v0.17.0

require (
github.com/tidwall/gjson v1.18.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tidwall/sjson v1.2.5 // indirect
)
12 changes: 12 additions & 0 deletions modus-gh-issue-summarizer/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
github.com/hypermodeinc/modus/sdk/go v0.17.0 h1:vyS82iw31xuxqQKxiVtwrSNuF6hkMEJoynlcxthAeYM=
github.com/hypermodeinc/modus/sdk/go v0.17.0/go.mod h1:UzVpTQDjloJuErOiNP3Tma3N8crE5qwYfKQyX1ecKlA=
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
Loading

0 comments on commit b2e6710

Please sign in to comment.