Merge pull request #6 from actions/sgoedecke/configurable-token
Make token configurable
This commit is contained in:
@@ -31,13 +31,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
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -10,7 +10,7 @@ branding:
|
|||||||
# 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:
|
||||||
@@ -21,10 +21,18 @@ inputs:
|
|||||||
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:
|
||||||
|
|||||||
+4
-4
@@ -33559,10 +33559,10 @@ 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');
|
||||||
}
|
}
|
||||||
@@ -33573,7 +33573,7 @@ async function run() {
|
|||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: systemPrompt || 'You are a helpful assistant.'
|
content: systemPrompt
|
||||||
},
|
},
|
||||||
{ role: 'user', content: prompt }
|
{ role: 'user', content: prompt }
|
||||||
],
|
],
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+4
-4
@@ -14,11 +14,11 @@ 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')
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ export async function run(): Promise<void> {
|
|||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content: systemPrompt || 'You are a helpful assistant.'
|
content: systemPrompt
|
||||||
},
|
},
|
||||||
{ role: 'user', content: prompt }
|
{ role: 'user', content: prompt }
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user