Skip to content

Commit 32ebbe7

Browse files
committed
Make token configurable
1 parent fbd6a39 commit 32ebbe7

File tree

5 files changed

+27
-18
lines changed

5 files changed

+27
-18
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ steps:
3131
Various inputs are defined in [`action.yml`](action.yml) to let you configure
3232
the action:
3333

34-
| Name | Description | Default |
35-
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
36-
| `token` | Token to use for inference. Typically the GITHUB_TOKEN secret | `github.token` |
37-
| `prompt` | The prompt to send to the model | N/A |
38-
| `model` | The model to use for inference. Must be available in the [GitHub Models](https://github.com/marketplace?type=models) catalog | `gpt-4o` |
39-
| `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` |
40-
| `max_tokens` | The max number of tokens to generate | 200 |
34+
| Name | Description | Default |
35+
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
36+
| `token` | Token to use for inference. Typically the GITHUB_TOKEN secret | `github.token` |
37+
| `prompt` | The prompt to send to the model | N/A |
38+
| `system-prompt` | The system prompt to send to the model | `""` |
39+
| `model` | The model to use for inference. Must be available in the [GitHub Models](https://github.com/marketplace?type=models) catalog | `gpt-4o` |
40+
| `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` |
41+
| `max-tokens` | The max number of tokens to generate | 200 |
4142

4243
## Outputs
4344

action.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ branding:
1010
# Define your inputs here.
1111
inputs:
1212
prompt:
13-
description: Your input description here
13+
description: The prompt for the model
1414
required: true
1515
default: ''
1616
model:
@@ -21,10 +21,18 @@ inputs:
2121
description: The endpoint to use
2222
required: false
2323
default: 'https://models.github.ai/inference'
24-
max_tokens:
24+
system-prompt:
25+
description: The system prompt for the model
26+
required: false
27+
default: 'You are a helpful assistant'
28+
max-tokens:
2529
description: The maximum number of tokens to generate
2630
required: false
2731
default: '200'
32+
token:
33+
description: The token to use
34+
required: false
35+
default: ${{ github.token }}
2836

2937
# Define your outputs here.
3038
outputs:

dist/index.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export async function run(): Promise<void> {
1414
throw new Error('prompt is not set')
1515
}
1616

17-
const systemPrompt: string = core.getInput('system_prompt')
17+
const systemPrompt: string = core.getInput('system-prompt')
1818
const modelName: string = core.getInput('model')
19-
const maxTokens: number = parseInt(core.getInput('max_tokens'), 10)
19+
const maxTokens: number = parseInt(core.getInput('max-tokens'), 10)
2020

21-
const token = process.env['GITHUB_TOKEN']
21+
const token = core.getInput('token') || process.env['GITHUB_TOKEN']
2222
if (token === undefined) {
2323
throw new Error('GITHUB_TOKEN is not set')
2424
}
@@ -31,7 +31,7 @@ export async function run(): Promise<void> {
3131
messages: [
3232
{
3333
role: 'system',
34-
content: systemPrompt || 'You are a helpful assistant.'
34+
content: systemPrompt
3535
},
3636
{ role: 'user', content: prompt }
3737
],

0 commit comments

Comments
 (0)