Make token configurable

This commit is contained in:
Sean Goedecke
2025-04-07 04:53:19 +00:00
parent fbd6a39716
commit 32ebbe708a
5 changed files with 27 additions and 18 deletions

View File

@@ -31,13 +31,14 @@ steps:
Various inputs are defined in [`action.yml`](action.yml) to let you configure
the action:
| Name | Description | Default |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| `token` | Token to use for inference. Typically the GITHUB_TOKEN secret | `github.token` |
| `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` |
| `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 |
| Name | Description | Default |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| `token` | Token to use for inference. Typically the GITHUB_TOKEN secret | `github.token` |
| `prompt` | The prompt to send to the model | N/A |
| `system-prompt` | The system prompt to send to the model | `""` |
| `model` | The model to use for inference. Must be available in the [GitHub Models](https://github.com/marketplace?type=models) catalog | `gpt-4o` |
| `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

View File

@@ -10,7 +10,7 @@ branding:
# Define your inputs here.
inputs:
prompt:
description: Your input description here
description: The prompt for the model
required: true
default: ''
model:
@@ -21,10 +21,18 @@ inputs:
description: The endpoint to use
required: false
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
required: false
default: '200'
token:
description: The token to use
required: false
default: ${{ github.token }}
# Define your outputs here.
outputs:

8
dist/index.js generated vendored
View File

@@ -33559,10 +33559,10 @@ async function run() {
if (prompt === undefined || prompt === '') {
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 maxTokens = parseInt(coreExports.getInput('max_tokens'), 10);
const token = process.env['GITHUB_TOKEN'];
const maxTokens = parseInt(coreExports.getInput('max-tokens'), 10);
const token = coreExports.getInput('token') || process.env['GITHUB_TOKEN'];
if (token === undefined) {
throw new Error('GITHUB_TOKEN is not set');
}
@@ -33573,7 +33573,7 @@ async function run() {
messages: [
{
role: 'system',
content: systemPrompt || 'You are a helpful assistant.'
content: systemPrompt
},
{ role: 'user', content: prompt }
],

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -14,11 +14,11 @@ export async function run(): Promise<void> {
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 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) {
throw new Error('GITHUB_TOKEN is not set')
}
@@ -31,7 +31,7 @@ export async function run(): Promise<void> {
messages: [
{
role: 'system',
content: systemPrompt || 'You are a helpful assistant.'
content: systemPrompt
},
{ role: 'user', content: prompt }
],