Skip to content

Commit

Permalink
Merge pull request #578 from linear-b/Ask-AI-plugin-integrations
Browse files Browse the repository at this point in the history
Add AI usage examples
  • Loading branch information
vim-zz committed Sep 3, 2024
2 parents 0e68012 + 853e050 commit 68ff21e
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 9 deletions.
12 changes: 6 additions & 6 deletions docs/automations/automation-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ This library of gitStream examples is meant to serve as a starting point for you
### Quality Checks
* [Enforce Semantic PR Titles](standard/enforce-pr-title/README.md) - Enforce PR naming conventions.
* [Enforce Changelog Updates](standard/review-changelog/README.md) - Require changelog updates for PRs that meet specific criteria.
* [Request screenshot](request-screenshot/README.md) - Request a screenshot in the PR description if none exist.
* [Request screenshot](request-screenshot/README.md) - Request a screenshot in the PR description if none exists.
* [Welcome newcomer](welcome-newcomer/README.md) - Post a welcome message when someone makes their first PR to a repo, and provide context to help them know what's next.
* [Remove TODO comments](standard/review-todo-comments/README.md) - Detect TODO comments in PRs and ask the author to remove or fix them.

Expand All @@ -56,18 +56,18 @@ These examples help you follow your team's security best practices.
* [Change deprecated components](change-deprecated-components/README.md) - Request changes when a PR includes one or more deprecated components.
* [Enforce copyright headers](standard/enforce-copyright-header/README.md) - Enforce the use of copyright headers when publishing open source code.

## Third-party Integrations
# Integrations

--8<-- "docs/integrations/README.md:integrations"

## Utilities
These examples provide useful components to use in other automations. These aren't intended to be used on their own; instead they act as a reference point for improving other automations.
# Utilities
These examples provide useful components to use in other automations. These aren't intended to be used on their own; instead, they act as a reference point for improving other automations.

* [Colors custom expression](utilities/colors-custom-expression/README.md) - A custom expression that implements all of GitHub's default label colors in a custom expression.
* [CM File Header](utilities/cm-header/README.md) - A header to copy/paste to the top of your CM files to help yourself, and others, understand the purpose of the file.
* [CM File Header](utilities/cm-header/README.md) - A header to copy/paste to the top of your CM files to help yourself and others understand the purpose of the file.


## Contribute Your Idea

!!! tip "Have a great idea for an automation that should be included in this library?"
!!! tip "Do you Have a great idea for an automation that should be included in this library?"
[Submit your configuration](https://github.com/linear-b/gitStream/issues/new?assignees=&labels=new-example&template=new_automation_example.md&title=New+Example%3A+) on GitHub. We'll recognize your contribution publicly (if you want) and might even send you some special swag for your contribution.
13 changes: 13 additions & 0 deletions docs/automations/integrations/AI/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: Integrate gitStream with AI
description: Use gitStream to integrate with AI services for Review, describe and add tests.
---
# Integrate gitStream with AI

--8<-- "docs/automations/integrations/AI/askAI/README.md:examples"

## Additional Resources

--8<-- "docs/snippets/general.md"

--8<-- "docs/snippets/automation-footer.md"
88 changes: 88 additions & 0 deletions docs/automations/integrations/AI/askAI/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
title: Integrate gitStream with AI
description: Use gitStream to integrate with AI services for Review, describe and add tests.
category: [quality, genai, copilot, tests, efficiency]
---
# Integrate gitStream with AI

<!-- --8<-- [start:examples]-->
## Use askAI plugin to interact with AI chatbots

!!! warning "Required gitStream Plugins"
This example requires you to install the [`askAI`](/filter-function-plugins/#askai) plugin.

[Learn more about gitStream plugins](/plugins/).


=== "Code Review"
!!! info "Configuration Description"

Conditions (all must be true):

* A PR is created or new code has been committed to the PR.
* The PR has a label "AskAI CR"

Automation Actions:

* Add a comment with the code review generated by an AI model

!!! example "Configuration Example"
```yaml+jinja
--8<-- "docs/downloads/automation-library/integrations/askAI/askAI_CR.cm"
```
<div class="result" markdown>
<span>
[:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/integrations/askAI/askAI-CR.cm){ .md-button }
</span>
</div>
=== "Describe PR"
!!! info "Configuration Description"

Conditions (all must be true):

* A PR is created or new code has been committed to the PR.
* The PR has a label "AskAI Describe"

Automation Actions:

* Add a comment with the code review generated by an AI model

!!! example "Configuration Example"
```yaml+jinja
--8<-- "docs/downloads/automation-library/integrations/askAI/askAI_describe.cm"
```
<div class="result" markdown>
<span>
[:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/integrations/askAI/askAI-Describe.cm){ .md-button }
</span>
</div>
=== "QA tests"
!!! info "Configuration Description"

Conditions (all must be true):

* A PR is created or new code has been committed to the PR.
* The PR has a label "AskAI QA"

Automation Actions:

* Add a comment with the code review generated by an AI model

!!! example "Configuration Example"
```yaml+jinja
--8<-- "docs/downloads/automation-library/integrations/askAI/askAI_QA.cm"
```
<div class="result" markdown>
<span>
[:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/integrations/askAI/askAI-QA.cm){ .md-button }
</span>
</div>



<!-- --8<-- [end:examples]-->
## Additional Resources

--8<-- "docs/snippets/general.md"

--8<-- "docs/snippets/automation-footer.md"
18 changes: 18 additions & 0 deletions docs/downloads/automation-library/integrations/askAI/askAI_CR.cm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
manifest:
version: 1.0

triggers:
on:
- commit
- pr_created

automations:
ask_ai_describe:
if:
- {{ pr.labels | match(term="askai cr") | some }}
run:
- action: add-comment@v1
args:
comment: |
# ✨ gitStream Review ✨
{{ source | askAI("Based on the given context, can you write a few bullet points about how I can improve my code? Please relate only to code diff, if it exists.", env.OPEN_AI_TOKEN) | encode }}
18 changes: 18 additions & 0 deletions docs/downloads/automation-library/integrations/askAI/askAI_QA.cm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
manifest:
version: 1.0

triggers:
on:
- commit
- pr_created

automations:
ask_ai_describe:
if:
- {{ pr.labels | match(term="askai qa") | some }}
run:
- action: add-comment@v1
args:
comment: |
# ✨ gitStream QA ✨
{{ source | askAI("Based on the given context, search for new functions without tests and suggest the tests to add. If all functions are covered completely, return 'no tests to suggest.'", env.OPEN_AI_TOKEN) | encode }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
manifest:
version: 1.0

triggers:
on:
- commit
- pr_created

automations:
ask_ai_describe:
if:
- {{ pr.labels | match(term="askai describe") | some }}
run:
- action: add-comment@v1
args:
comment: |
# ✨ gitStream Describe PR ✨
{{ source | askAI("based on the given context, describe in plain english the changes introduced in this PR.", env.OPEN_AI_TOKEN) | encode }}
1 change: 0 additions & 1 deletion docs/filter-function-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ description: Implement custom gitStream filter functions with JavaScript.

JavaScript plugins that enable custom filter functions for gitStream. To learn how to use these examples, read our [guide on how to use gitStream plugins](/plugins).

askAI-plugin
--8<-- "plugins/filters/askAI/README.md"

--8<-- "plugins/filters/checklist/README.md"
Expand Down
10 changes: 8 additions & 2 deletions docs/integrations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ visible: false
# gitStream Integrations
<!-- --8<-- [start:integrations]-->
<div class="integrations-list" markdown="1">

<div class="integrations-card" markdown="1">
<div class="integrations-card-title" markdown="1">
[AI](/automations/integrations/AI)
</div>
</div>

<div class="integrations-card" markdown="1">
<div class="integrations-card-title" markdown="1">
Expand All @@ -19,13 +25,13 @@ visible: false

<div class="integrations-card" markdown="1">
<div class="integrations-card-title" markdown="1">
[::simple-githubactions:: GitHub Actions](/integrations/github-actions)
[:simple-githubactions: GitHub Actions](/integrations/github-actions)
</div>
</div>

<div class="integrations-card" markdown="1">
<div class="integrations-card-title" markdown="1">
[::octicons-copilot-16:: GitHub Copilot](/integrations/github-copilot)
[:octicons-copilot-16: GitHub Copilot](/integrations/github-copilot)
</div>
</div>

Expand Down

0 comments on commit 68ff21e

Please sign in to comment.