react to feedback

This commit is contained in:
Aiqiao Yan
2025-04-17 20:23:07 +00:00
parent f1591cfa68
commit 1c557cdc25
6 changed files with 23 additions and 16 deletions

View File

@@ -34,30 +34,37 @@ jobs:
run: echo "${{ steps.inference.outputs.response }}"
```
### Using a Prompt File
### Using a prompt file
You can also provide a prompt file instead of an inline prompt:
```yaml
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run AI Inference with Prompt File
id: inference
uses: actions/ai-inference@v1
with:
prompt-file: './path/to/prompt.txt'
```
### Read output from file instead of output
This can be useful when model response exceeds actions output limit
```yaml
steps:
- name: Test Local Action
id: inference
uses: actions/ai-inference@v1
with:
prompt: 'Hello!'
- name: Use Response File
run: |
echo "Response saved to: ${{ steps.inference.outputs.response-path }}"
cat "${{ steps.inference.outputs.response-path }}"
echo "Response saved to: ${{ steps.inference.outputs.response-file }}"
cat "${{ steps.inference.outputs.response-file }}"
```
This is particularly useful for longer prompts or when you need to use the file
path where the response is stored.
## Inputs
Various inputs are defined in [`action.yml`](action.yml) to let you configure
@@ -80,7 +87,7 @@ The AI inference action provides the following outputs:
| Name | Description |
| --------------- | ----------------------------------------------------------------------- |
| `response` | The response from the model |
| `response-path` | The file path where the response is saved (useful for larger responses) |
| `response-file` | The file path where the response is saved (useful for larger responses) |
## Required Permissions

View File

@@ -62,7 +62,7 @@ describe('main.ts', () => {
expect(core.setOutput).toHaveBeenNthCalledWith(
2,
'response-path',
'response-file',
expect.stringContaining('modelResponse.txt')
)
})
@@ -101,7 +101,7 @@ describe('main.ts', () => {
)
expect(core.setOutput).toHaveBeenNthCalledWith(
2,
'response-path',
'response-file',
expect.stringContaining('modelResponse.txt')
)
})

View File

@@ -42,7 +42,7 @@ inputs:
outputs:
response:
description: The response from the model
response-path:
response-file:
description: The file path where the response is saved
runs:

2
dist/index.js generated vendored
View File

@@ -33612,7 +33612,7 @@ async function run() {
coreExports.setOutput('response', modelResponse || '');
// Save the response to a file in case the response overflow the output limit
const responseFilePath = require$$1.join(tempDir(), RESPONSE_FILE);
coreExports.setOutput('response-path', responseFilePath);
coreExports.setOutput('response-file', responseFilePath);
if (modelResponse && modelResponse !== '') {
fs.writeFileSync(responseFilePath, modelResponse, 'utf-8');
}

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -78,7 +78,7 @@ export async function run(): Promise<void> {
// Save the response to a file in case the response overflow the output limit
const responseFilePath = path.join(tempDir(), RESPONSE_FILE)
core.setOutput('response-path', responseFilePath)
core.setOutput('response-file', responseFilePath)
if (modelResponse && modelResponse !== '') {
fs.writeFileSync(responseFilePath, modelResponse, 'utf-8')