Compare commits
26
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7105a4c1e | ||
|
|
b75b177af3 | ||
|
|
a3d57cc6dc | ||
|
|
9239ab5d65 | ||
|
|
5ac68dad30 | ||
|
|
3f8bae9a6e | ||
|
|
6baaaac50c | ||
|
|
e8a0bebb73 | ||
|
|
ba8a6b0374 | ||
|
|
e670dd5178 | ||
|
|
84fee7a0e6 | ||
|
|
83d9668e82 | ||
|
|
2de3b6e872 | ||
|
|
40b430b284 | ||
|
|
e5b826567d | ||
|
|
4738a2d212 | ||
|
|
606ea175ce | ||
|
|
afaedf6677 | ||
|
|
78d6b91d0b | ||
|
|
1a66a5968c | ||
|
|
efbbaa2667 | ||
|
|
a57b52eccd | ||
|
|
32ebbe708a | ||
|
|
213eb60e28 | ||
|
|
fbd6a39716 | ||
|
|
7ae29e4a7c |
@@ -38,7 +38,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Lint Codebase
|
- name: Lint Codebase
|
||||||
id: super-linter
|
id: super-linter
|
||||||
uses: super-linter/super-linter/slim@v7
|
uses: super-linter/super-linter/slim@4e8a7c2bf106c4c766c816b35ec612638dc9b6b2
|
||||||
env:
|
env:
|
||||||
DEFAULT_BRANCH: main
|
DEFAULT_BRANCH: main
|
||||||
FILTER_REGEX_EXCLUDE: dist/**/*
|
FILTER_REGEX_EXCLUDE: dist/**/*
|
||||||
|
|||||||
+1
-1
@@ -4,4 +4,4 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
# Default owners, unless a later match takes precedence.
|
# Default owners, unless a later match takes precedence.
|
||||||
* @actions/actions-oss-maintainers
|
* @actions/models
|
||||||
|
|||||||
@@ -14,16 +14,24 @@ your actions.
|
|||||||
Create a workflow to use the AI inference action:
|
Create a workflow to use the AI inference action:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
name: 'AI inference'
|
||||||
- name: Test Local Action
|
on: workflow_dispatch
|
||||||
id: inference
|
|
||||||
uses: actions/ai-inference@v1
|
|
||||||
with:
|
|
||||||
prompt: 'Hello!'
|
|
||||||
|
|
||||||
- name: Print Output
|
jobs:
|
||||||
id: output
|
inference:
|
||||||
run: echo "${{ steps.test-action.outputs.response }}"
|
permissions:
|
||||||
|
models: read
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Test Local Action
|
||||||
|
id: inference
|
||||||
|
uses: actions/ai-inference@v1
|
||||||
|
with:
|
||||||
|
prompt: 'Hello!'
|
||||||
|
|
||||||
|
- name: Print Output
|
||||||
|
id: output
|
||||||
|
run: echo "${{ steps.inference.outputs.response }}"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
@@ -31,13 +39,14 @@ steps:
|
|||||||
Various inputs are defined in [`action.yml`](action.yml) to let you configure
|
Various inputs are defined in [`action.yml`](action.yml) to let you configure
|
||||||
the action:
|
the action:
|
||||||
|
|
||||||
| Name | Description | Default |
|
| Name | Description | Default |
|
||||||
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
|
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
|
||||||
| `token` | Token to use for inference. Typically the GITHUB_TOKEN secret | `github.token` |
|
| `token` | Token to use for inference. Typically the GITHUB_TOKEN secret | `github.token` |
|
||||||
| `prompt` | The prompt to send to the model | N/A |
|
| `prompt` | The prompt to send to the model | N/A |
|
||||||
| `model` | The model to use for inference. Must be available in the [GitHub Models](https://github.com/marketplace?type=models) catalog | `gpt-4o` |
|
| `system-prompt` | The system prompt to send to the model | `""` |
|
||||||
| `endpoint` | The endpoint to use for inference. If you're running this as part of an org, you should probably use the org-specific Models endpoint | `https://models.github.ai/inference` |
|
| `model` | The model to use for inference. Must be available in the [GitHub Models](https://github.com/marketplace?type=models) catalog | `gpt-4o` |
|
||||||
| `max_tokens` | The max number of tokens to generate | 200 |
|
| `endpoint` | The endpoint to use for inference. If you're running this as part of an org, you should probably use the org-specific Models endpoint | `https://models.github.ai/inference` |
|
||||||
|
| `max-tokens` | The max number of tokens to generate | 200 |
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
@@ -87,6 +96,11 @@ following steps:
|
|||||||
to create a new release in GitHub so users can easily reference the new tags
|
to create a new release in GitHub so users can easily reference the new tags
|
||||||
in their workflows.
|
in their workflows.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is licensed under the terms of the MIT open source license. Please
|
||||||
|
refer to [MIT](./LICENSE.txt) for the full terms.
|
||||||
|
|
||||||
## Contributions
|
## Contributions
|
||||||
|
|
||||||
Contributions are welcome! See the [Contributor's Guide](CONTRIBUTING.md).
|
Contributions are welcome! See the [Contributor's Guide](CONTRIBUTING.md).
|
||||||
|
|||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
# Security
|
||||||
|
|
||||||
|
GitHub takes the security of our software products and services seriously,
|
||||||
|
including all of the open source code repositories managed through our GitHub
|
||||||
|
organizations, such as [GitHub](https://github.com/GitHub).
|
||||||
|
|
||||||
|
Even though
|
||||||
|
[open source repositories are outside of the scope of our bug bounty program](https://bounty.github.com/index.html#scope)
|
||||||
|
and therefore not eligible for bounty rewards, we will ensure that your finding
|
||||||
|
gets passed along to the appropriate maintainers for remediation.
|
||||||
|
|
||||||
|
## Reporting Security Issues
|
||||||
|
|
||||||
|
If you believe you have found a security vulnerability in any GitHub-owned
|
||||||
|
repository, please report it to us through coordinated disclosure.
|
||||||
|
|
||||||
|
**Please do not report security vulnerabilities through public GitHub issues,
|
||||||
|
discussions, or pull requests.**
|
||||||
|
|
||||||
|
Instead, please send an email to opensource-security[@]github.com.
|
||||||
|
|
||||||
|
Please include as much of the information listed below as you can to help us
|
||||||
|
better understand and resolve the issue:
|
||||||
|
|
||||||
|
- The type of issue (e.g., buffer overflow, SQL injection, or cross-site
|
||||||
|
scripting)
|
||||||
|
- Full paths of source file(s) related to the manifestation of the issue
|
||||||
|
- The location of the affected source code (tag/branch/commit or direct URL)
|
||||||
|
- Any special configuration required to reproduce the issue
|
||||||
|
- Step-by-step instructions to reproduce the issue
|
||||||
|
- Proof-of-concept or exploit code (if possible)
|
||||||
|
- Impact of the issue, including how an attacker might exploit the issue
|
||||||
|
|
||||||
|
This information will help us triage your report more quickly.
|
||||||
|
|
||||||
|
## Policy
|
||||||
|
|
||||||
|
See
|
||||||
|
[GitHub's Safe Harbor Policy](https://docs.github.com/en/site-policy/security-policies/github-bug-bounty-program-legal-safe-harbor#1-safe-harbor-terms)
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
# Support
|
||||||
|
|
||||||
|
## How to file issues and get help
|
||||||
|
|
||||||
|
This project uses GitHub issues to track bugs and feature requests. Please
|
||||||
|
search the existing issues before filing new issues to avoid duplicates. For new
|
||||||
|
issues, file your bug or feature request as a new issue.
|
||||||
|
|
||||||
|
For help or questions about using this project, please file an issue.
|
||||||
|
|
||||||
|
This project is under active development and maintained by GitHub staff and the
|
||||||
|
community. We will do our best to respond to support, feature requests, and
|
||||||
|
community questions in a timely manner.
|
||||||
|
|
||||||
|
## GitHub Support Policy
|
||||||
|
|
||||||
|
Support for this project is limited to the resources listed above.
|
||||||
+12
-4
@@ -4,27 +4,35 @@ author: 'GitHub'
|
|||||||
|
|
||||||
# Add your action's branding here. This will appear on the GitHub Marketplace.
|
# Add your action's branding here. This will appear on the GitHub Marketplace.
|
||||||
branding:
|
branding:
|
||||||
icon: 'play-circle'
|
icon: 'message-square'
|
||||||
color: red
|
color: red
|
||||||
|
|
||||||
# Define your inputs here.
|
# Define your inputs here.
|
||||||
inputs:
|
inputs:
|
||||||
prompt:
|
prompt:
|
||||||
description: Your input description here
|
description: The prompt for the model
|
||||||
required: true
|
required: true
|
||||||
default: ''
|
default: ''
|
||||||
model:
|
model:
|
||||||
description: The model to use
|
description: The model to use
|
||||||
required: false
|
required: false
|
||||||
default: 'gpt-4o'
|
default: 'openai/gpt-4o'
|
||||||
endpoint:
|
endpoint:
|
||||||
description: The endpoint to use
|
description: The endpoint to use
|
||||||
required: false
|
required: false
|
||||||
default: 'https://models.github.ai/inference'
|
default: 'https://models.github.ai/inference'
|
||||||
max_tokens:
|
system-prompt:
|
||||||
|
description: The system prompt for the model
|
||||||
|
required: false
|
||||||
|
default: 'You are a helpful assistant'
|
||||||
|
max-tokens:
|
||||||
description: The maximum number of tokens to generate
|
description: The maximum number of tokens to generate
|
||||||
required: false
|
required: false
|
||||||
default: '200'
|
default: '200'
|
||||||
|
token:
|
||||||
|
description: The token to use
|
||||||
|
required: false
|
||||||
|
default: ${{ github.token }}
|
||||||
|
|
||||||
# Define your outputs here.
|
# Define your outputs here.
|
||||||
outputs:
|
outputs:
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="116" height="20" role="img" aria-label="Coverage: 89.47%"><title>Coverage: 89.47%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="116" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="53" height="20" fill="#dfb317"/><rect width="116" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="885" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">89.47%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">89.47%</text></g></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="116" height="20" role="img" aria-label="Coverage: 77.27%"><title>Coverage: 77.27%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="116" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="53" height="20" fill="#e05d44"/><rect width="116" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="885" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">77.27%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">77.27%</text></g></svg>
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
+19
-9
@@ -33559,32 +33559,38 @@ async function run() {
|
|||||||
if (prompt === undefined || prompt === '') {
|
if (prompt === undefined || prompt === '') {
|
||||||
throw new Error('prompt is not set');
|
throw new Error('prompt is not set');
|
||||||
}
|
}
|
||||||
const systemPrompt = coreExports.getInput('system_prompt');
|
const systemPrompt = coreExports.getInput('system-prompt');
|
||||||
const modelName = coreExports.getInput('model');
|
const modelName = coreExports.getInput('model');
|
||||||
const maxTokens = parseInt(coreExports.getInput('max_tokens'), 10);
|
const maxTokens = parseInt(coreExports.getInput('max-tokens'), 10);
|
||||||
const token = process.env['GITHUB_TOKEN'];
|
const token = coreExports.getInput('token') || process.env['GITHUB_TOKEN'];
|
||||||
if (token === undefined) {
|
if (token === undefined) {
|
||||||
throw new Error('GITHUB_TOKEN is not set');
|
throw new Error('GITHUB_TOKEN is not set');
|
||||||
}
|
}
|
||||||
const endpoint = coreExports.getInput('endpoint');
|
const endpoint = coreExports.getInput('endpoint');
|
||||||
const client = createClient(endpoint, new AzureKeyCredential(token));
|
const client = createClient(endpoint, new AzureKeyCredential(token), {
|
||||||
|
userAgentOptions: { userAgentPrefix: 'github-actions-ai-inference' }
|
||||||
|
});
|
||||||
const response = await client.path('/chat/completions').post({
|
const response = await client.path('/chat/completions').post({
|
||||||
body: {
|
body: {
|
||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: systemPrompt || 'You are a helpful assistant.'
|
content: systemPrompt
|
||||||
},
|
},
|
||||||
{ role: 'user', content: prompt }
|
{ role: 'user', content: prompt }
|
||||||
],
|
],
|
||||||
temperature: 1.0,
|
|
||||||
top_p: 1.0,
|
|
||||||
max_tokens: maxTokens,
|
max_tokens: maxTokens,
|
||||||
model: modelName
|
model: modelName
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (isUnexpected(response)) {
|
if (isUnexpected(response)) {
|
||||||
throw response.body.error;
|
if (response.body.error) {
|
||||||
|
throw response.body.error;
|
||||||
|
}
|
||||||
|
throw new Error('An error occurred while fetching the response (' +
|
||||||
|
response.status +
|
||||||
|
'): ' +
|
||||||
|
response.body);
|
||||||
}
|
}
|
||||||
const modelResponse = response.body.choices[0].message.content;
|
const modelResponse = response.body.choices[0].message.content;
|
||||||
// Set outputs for other workflow steps to use
|
// Set outputs for other workflow steps to use
|
||||||
@@ -33592,8 +33598,12 @@ async function run() {
|
|||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
// Fail the workflow run if an error occurs
|
// Fail the workflow run if an error occurs
|
||||||
if (error instanceof Error)
|
if (error instanceof Error) {
|
||||||
coreExports.setFailed(error.message);
|
coreExports.setFailed(error.message);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
coreExports.setFailed('An unexpected error occurred');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+58
-23
@@ -804,25 +804,27 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@babel/helpers": {
|
"node_modules/@babel/helpers": {
|
||||||
"version": "7.26.9",
|
"version": "7.27.0",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.26.9.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.27.0.tgz",
|
||||||
"integrity": "sha512-Mz/4+y8udxBKdmzt/UjPACs4G3j5SshJJEFFKxlCGPydG4JAHXxjWjAwjd09tf6oINvl1VfMJo+nB7H2YKQ0dA==",
|
"integrity": "sha512-U5eyP/CTFPuNE3qk+WZMxFkp/4zUzdceQlfzf7DdGdhp+Fezd7HD+i8Y24ZuTMKX3wQBld449jijbGq6OdGNQg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/template": "^7.26.9",
|
"@babel/template": "^7.27.0",
|
||||||
"@babel/types": "^7.26.9"
|
"@babel/types": "^7.27.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.9.0"
|
"node": ">=6.9.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@babel/parser": {
|
"node_modules/@babel/parser": {
|
||||||
"version": "7.26.9",
|
"version": "7.27.0",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.9.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.27.0.tgz",
|
||||||
"integrity": "sha512-81NWa1njQblgZbQHxWHpxxCzNsa3ZwvFqpUg7P+NNUU6f3UU2jBEg4OlF/J6rl8+PQGh1q6/zWScd001YwcA5A==",
|
"integrity": "sha512-iaepho73/2Pz7w2eMS0Q5f83+0RKI7i4xmiYeBmDzfRVbQtTOG7Ts0S4HzJVsTMGI9keU8rNfuZr8DKfSt7Yyg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/types": "^7.26.9"
|
"@babel/types": "^7.27.0"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"parser": "bin/babel-parser.js"
|
"parser": "bin/babel-parser.js"
|
||||||
@@ -1054,14 +1056,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@babel/template": {
|
"node_modules/@babel/template": {
|
||||||
"version": "7.26.9",
|
"version": "7.27.0",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.26.9.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.0.tgz",
|
||||||
"integrity": "sha512-qyRplbeIpNZhmzOysF/wFMuP9sctmh2cFzRAZOn1YapxBsE1i9bJIY586R/WBLfLcmcBlM8ROBiQURnnNy+zfA==",
|
"integrity": "sha512-2ncevenBqXI6qRMukPlXwHKHchC7RyMuu4xv5JBXRfOGVcTy1mXCD12qrp7Jsoxll1EV3+9sE4GugBVRjT2jFA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/code-frame": "^7.26.2",
|
"@babel/code-frame": "^7.26.2",
|
||||||
"@babel/parser": "^7.26.9",
|
"@babel/parser": "^7.27.0",
|
||||||
"@babel/types": "^7.26.9"
|
"@babel/types": "^7.27.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.9.0"
|
"node": ">=6.9.0"
|
||||||
@@ -1095,10 +1098,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@babel/types": {
|
"node_modules/@babel/types": {
|
||||||
"version": "7.26.9",
|
"version": "7.27.0",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.9.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.27.0.tgz",
|
||||||
"integrity": "sha512-Y3IR1cRnOxOCDvMmNiym7XpXQ93iGDDPHx+Zj+NM+rg0fBaShfQLkg+hKPaZCEvg5N/LeCo4+Rj/i3FuJsIQaw==",
|
"integrity": "sha512-H45s8fVLYjbhFH62dIJ3WtmJ6RSPt/3DRO0ZcT2SUiYiQyz3BLVb9ADEnLl91m74aQPS3AzzeajZHYOalWe3bg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/helper-string-parser": "^7.25.9",
|
"@babel/helper-string-parser": "^7.25.9",
|
||||||
"@babel/helper-validator-identifier": "^7.25.9"
|
"@babel/helper-validator-identifier": "^7.25.9"
|
||||||
@@ -1730,9 +1734,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@github/local-action": {
|
"node_modules/@github/local-action": {
|
||||||
"version": "3.1.3",
|
"version": "3.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/@github/local-action/-/local-action-3.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/@github/local-action/-/local-action-3.1.4.tgz",
|
||||||
"integrity": "sha512-Pi2Mf7bIiFN30xgDtaQf0Yvm2fZ1QnMGZmNHAKimW/ntCLFVJQsWXmNo3GqzsENbyXcsb2ziZ6DJI5b9TmWYig==",
|
"integrity": "sha512-PwA4w5jsjbyK+DNFNnFc4htu0iBOngi8g+O7NV8eGo9wm5YpIxf9kKgLJgVDIZlT32rfOVre5XZzGdPLTfggHQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -1746,6 +1750,7 @@
|
|||||||
"@octokit/plugin-request-log": "^5.3.1",
|
"@octokit/plugin-request-log": "^5.3.1",
|
||||||
"@octokit/plugin-rest-endpoint-methods": "^13.3.1",
|
"@octokit/plugin-rest-endpoint-methods": "^13.3.1",
|
||||||
"@octokit/plugin-retry": "^7.1.2",
|
"@octokit/plugin-retry": "^7.1.2",
|
||||||
|
"@octokit/rest": "^21.1.1",
|
||||||
"archiver": "^7.0.1",
|
"archiver": "^7.0.1",
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.3.0",
|
||||||
"commander": "^13.0.0",
|
"commander": "^13.0.0",
|
||||||
@@ -2657,6 +2662,22 @@
|
|||||||
"node": ">= 18"
|
"node": ">= 18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@octokit/rest": {
|
||||||
|
"version": "21.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-21.1.1.tgz",
|
||||||
|
"integrity": "sha512-sTQV7va0IUVZcntzy1q3QqPm/r8rWtDCqpRAmb8eXXnKkjoQEtFe3Nt5GTVsHft+R6jJoHeSiVLcgcvhtue/rg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@octokit/core": "^6.1.4",
|
||||||
|
"@octokit/plugin-paginate-rest": "^11.4.2",
|
||||||
|
"@octokit/plugin-request-log": "^5.3.1",
|
||||||
|
"@octokit/plugin-rest-endpoint-methods": "^13.3.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 18"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@octokit/types": {
|
"node_modules/@octokit/types": {
|
||||||
"version": "13.8.0",
|
"version": "13.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.8.0.tgz",
|
||||||
@@ -3076,9 +3097,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-x64-gnu": {
|
"node_modules/@rollup/rollup-linux-x64-gnu": {
|
||||||
"version": "4.38.0",
|
"version": "4.39.0",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.38.0.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.39.0.tgz",
|
||||||
"integrity": "sha512-vPvNgFlZRAgO7rwncMeE0+8c4Hmc+qixnp00/Uv3ht2x7KYrJ6ERVd3/R0nUtlE6/hu7/HiiNHJ/rP6knRFt1w==",
|
"integrity": "sha512-t9jqYw27R6Lx0XKfEFe5vUeEJ5pF3SGIM6gTfONSMb7DuG6z6wfj2yjcoZxHg129veTqU7+wOhY6GX8wmf90dA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@@ -9693,6 +9714,20 @@
|
|||||||
"fsevents": "~2.3.2"
|
"fsevents": "~2.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/rollup/node_modules/@rollup/rollup-linux-x64-gnu": {
|
||||||
|
"version": "4.38.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.38.0.tgz",
|
||||||
|
"integrity": "sha512-vPvNgFlZRAgO7rwncMeE0+8c4Hmc+qixnp00/Uv3ht2x7KYrJ6ERVd3/R0nUtlE6/hu7/HiiNHJ/rP6knRFt1w==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
"node_modules/run-parallel": {
|
"node_modules/run-parallel": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "typescript-action",
|
"name": "typescript-action",
|
||||||
"description": "GitHub Actions TypeScript template",
|
"description": "GitHub Actions TypeScript template",
|
||||||
"version": "0.0.0",
|
"version": "1.0.0",
|
||||||
"author": "",
|
"author": "",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
+22
-9
@@ -14,36 +14,45 @@ export async function run(): Promise<void> {
|
|||||||
throw new Error('prompt is not set')
|
throw new Error('prompt is not set')
|
||||||
}
|
}
|
||||||
|
|
||||||
const systemPrompt: string = core.getInput('system_prompt')
|
const systemPrompt: string = core.getInput('system-prompt')
|
||||||
const modelName: string = core.getInput('model')
|
const modelName: string = core.getInput('model')
|
||||||
const maxTokens: number = parseInt(core.getInput('max_tokens'), 10)
|
const maxTokens: number = parseInt(core.getInput('max-tokens'), 10)
|
||||||
|
|
||||||
const token = process.env['GITHUB_TOKEN']
|
const token = core.getInput('token') || process.env['GITHUB_TOKEN']
|
||||||
if (token === undefined) {
|
if (token === undefined) {
|
||||||
throw new Error('GITHUB_TOKEN is not set')
|
throw new Error('GITHUB_TOKEN is not set')
|
||||||
}
|
}
|
||||||
|
|
||||||
const endpoint = core.getInput('endpoint')
|
const endpoint = core.getInput('endpoint')
|
||||||
|
|
||||||
const client = ModelClient(endpoint, new AzureKeyCredential(token))
|
const client = ModelClient(endpoint, new AzureKeyCredential(token), {
|
||||||
|
userAgentOptions: { userAgentPrefix: 'github-actions-ai-inference' }
|
||||||
|
})
|
||||||
|
|
||||||
const response = await client.path('/chat/completions').post({
|
const response = await client.path('/chat/completions').post({
|
||||||
body: {
|
body: {
|
||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: systemPrompt || 'You are a helpful assistant.'
|
content: systemPrompt
|
||||||
},
|
},
|
||||||
{ role: 'user', content: prompt }
|
{ role: 'user', content: prompt }
|
||||||
],
|
],
|
||||||
temperature: 1.0,
|
|
||||||
top_p: 1.0,
|
|
||||||
max_tokens: maxTokens,
|
max_tokens: maxTokens,
|
||||||
model: modelName
|
model: modelName
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (isUnexpected(response)) {
|
if (isUnexpected(response)) {
|
||||||
throw response.body.error
|
if (response.body.error) {
|
||||||
|
throw response.body.error
|
||||||
|
}
|
||||||
|
throw new Error(
|
||||||
|
'An error occurred while fetching the response (' +
|
||||||
|
response.status +
|
||||||
|
'): ' +
|
||||||
|
response.body
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const modelResponse: string | null =
|
const modelResponse: string | null =
|
||||||
@@ -53,6 +62,10 @@ export async function run(): Promise<void> {
|
|||||||
core.setOutput('response', modelResponse || '')
|
core.setOutput('response', modelResponse || '')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Fail the workflow run if an error occurs
|
// Fail the workflow run if an error occurs
|
||||||
if (error instanceof Error) core.setFailed(error.message)
|
if (error instanceof Error) {
|
||||||
|
core.setFailed(error.message)
|
||||||
|
} else {
|
||||||
|
core.setFailed('An unexpected error occurred')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user