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

GitHub Issue Summarizer using Modus & GitHub Actions #64

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

StephDietz
Copy link
Contributor

  • When an issue is closed, a GitHub Action triggers the Modus function.
  • The function fetches the issue details and comments using the GitHub API.
  • A KB article is generated using the issue details and the Meta-Llama-3.1 model.
  • The article is then posted as a GitHub Discussion for easy reference.

@StephDietz StephDietz requested a review from a team as a code owner January 30, 2025 21:55
johnymontana
johnymontana previously approved these changes Feb 11, 2025
@johnymontana johnymontana enabled auto-merge (squash) February 11, 2025 17:33
@johnymontana johnymontana requested review from rderbier and a team February 11, 2025 17:33
modus-gh-issue-summarizer/go.mod Outdated Show resolved Hide resolved
modus-gh-issue-summarizer/go.mod Outdated Show resolved Hide resolved

## 🖥️ Running Locally

### 1️⃣ Install Modus
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to mention that for this example you'll need Go and TinyGo installed also.

modus-gh-issue-summarizer/main.go Outdated Show resolved Hide resolved
modus-gh-issue-summarizer/main.go Outdated Show resolved Hide resolved
Comment on lines +241 to +256
Generate a detailed markdown article givin a concise summary of the following GitHub issue. Include the problem, the solution (if on exists), and any other relevant details. Please mention the users involved and any significant involvement in the issue.

### Issue Details:
- **Title**: %s
- **Description**: %s
- **State**: %s
- **Created by**: %s
- **Created at**: %s
- **Labels**: %v
- **Reactions**: 👍 (%d), 👎 (%d), ❤️ (%d), 🎉 (%d), 🚀 (%d), 👀 (%d)

### Comments:
%s

Generate the output in markdown format.
`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The leading whitespace on each line of the prompt will be passed to the model, which may (or may not) decide to give the same whitespace in the markdown result. It would be best to not indent any of these lines. Unindent them all the way to the left.

return "", fmt.Errorf("error creating model input: %w", err)
}

input.Temperature = 0.7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test the temperature setting. If it's not affecting the result, remove it and stick with the default.

modus-gh-issue-summarizer/main.go Outdated Show resolved Hide resolved
modus-gh-issue-summarizer/main.go Outdated Show resolved Hide resolved
Comment on lines +364 to +365
fmt.Printf("Error fetching issue details: %v\n", err)
return
Copy link
Member

@mattjohnsonpint mattjohnsonpint Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and throughout, fmt.Printf is being used to report errors. The problem with that is the calling function will still see it as success. Only the local logs will show the message, and just as non-categorized information.

A better approach for errors is to return an error, and then check that error in the calling function, and/or return it all the way up to the exported Modus function.

Suggested change
fmt.Printf("Error fetching issue details: %v\n", err)
return
return fmt.Errorf("error fetching issue details: %w", err)

Notes:

  • Start errors with lower case letters
  • Don't include a \n
  • Use %w instead of %v when wrapping an existing error object.
  • If there's no existing error but you're just creating a string error message, then use errors.New instead of fmt.Errorf

In the case of success logging, you can continue to use fmt.Println if it's indeed a single line. Alternatively you could use the Modus console API, and use console.Info so it has reports with INF level instead of ???.

If you're logging debug details, use console.Debug so it gets DBG status, and more importantly, if there's possibly more than one line of output, then you must use one of the console functions so the lines are kept together in a single message. (fmt.Println and similar just write to stdout or stderr, so every line is treated as a separate logging message by the Modus runtime.)

npm install -g @hypermodeinc/modus
```

### 2️⃣ Clone the Repository
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to mention that this is a repository in which you want to run the summarizer.

cd YOUR_REPO
```

### 3️⃣ Start the Modus Dev Server
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this stage the viewer is in their cloned repo right, how to they get the required files (main.go, modus.json, etc) into this folder? Maybe I'm missing something.

@@ -0,0 +1,12 @@
module modus-gh-issue-summarizer

go 1.23.6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 1.23.6 really required? For instance, I'm running 1.23.3 and was able to get it to build (once I fixed the token parameter issue).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"required" is an interesting word. There are security vulnerabilities in 1.23.5 that were fixed in 1.23.6.
Go 1.23.1 had security fixes (so 1.23.0 is out). Go 1.23.2 - .5 did not, but then .6 did, so now .6 is "required".

Also, we have Trunk in this repo, which uses OSV-Scanner, and will hit on some vulnerabilities depending on Go version. I've put some manually into the ignore list, but they're only false positives if you're actually running 1.23.6. Otherwise they could indeed be hit. (well, not the ppc one, but perhaps the others depending on the code.)

In general, we recommend apps target the latest version of Go to avoid worrying about such things. Since this is a "recipes" repo then yes - our recommendations should be applied.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally get it from a production software sense--but my point was that this would stop a significant number of people from completing the recipe if it meant they had to upgrade Go on their system.


### 4️⃣ Test the API Locally

Go to: `http://localhost:54321/graphql`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I modus dev from the new folder in your branch, the handler runs on 8686. Don't see anywhere where this is configured for 54321.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants