diff --git a/.env.example b/.env.example index 3ed1486..f7ee7cd 100644 --- a/.env.example +++ b/.env.example @@ -9,7 +9,7 @@ ACTIONS_STEP_DEBUG=true # GitHub Actions inputs should follow `INPUT_` format (case-sensitive). # Hyphens should not be converted to underscores! -INPUT_PROMPT=hello +INPUT_prompt=hello # GitHub Actions default environment variables. These are set for every run of a # workflow and can be used in your actions. Setting the value here will override diff --git a/action.yml b/action.yml index 2656350..b5a88b7 100644 --- a/action.yml +++ b/action.yml @@ -16,7 +16,7 @@ inputs: model: description: The model to use required: false - default: 'gpt-4o' + default: 'openai/gpt-4o' endpoint: description: The endpoint to use required: false diff --git a/src/main.ts b/src/main.ts index ba9586f..4c11d37 100644 --- a/src/main.ts +++ b/src/main.ts @@ -25,7 +25,6 @@ export async function run(): Promise { const endpoint = core.getInput('endpoint') const client = ModelClient(endpoint, new AzureKeyCredential(token)) - core.debug('Endpoint: ' + endpoint) const response = await client.path('/chat/completions').post({ body: { @@ -44,14 +43,16 @@ export async function run(): Promise { }) if (isUnexpected(response)) { - core.debug('Unexpected response: ' + 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 + ) } - - core.debug('Response: ' + response.body) - core.debug('Choices: ' + response.body.choices) - core.debug('Message: ' + response.body.choices[0].message) - const modelResponse: string | null = response.body.choices[0].message.content @@ -59,6 +60,10 @@ export async function run(): Promise { core.setOutput('response', modelResponse || '') } catch (error) { // 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') + } } }