use publisher
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ ACTIONS_STEP_DEBUG=true
|
||||
|
||||
# GitHub Actions inputs should follow `INPUT_<name>` 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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+14
-9
@@ -25,7 +25,6 @@ export async function run(): Promise<void> {
|
||||
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<void> {
|
||||
})
|
||||
|
||||
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<void> {
|
||||
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')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user