generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
883e673
commit 3f05479
Showing
11 changed files
with
137 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,48 @@ | ||
import { | ||
prompt, | ||
jiraPrompt, | ||
acSummariesPrompt, | ||
compareOldSummaryTemplate | ||
} from './prompts.js' | ||
jiraPrompt, | ||
acSummariesPrompt, | ||
compareOldSummaryTemplate | ||
} from './constants.js' | ||
import core from '@actions/core' | ||
import OpenAI from 'openai' | ||
import { Logger } from './utils.js' | ||
|
||
|
||
export class Ai { | ||
constructor() { | ||
const openAiKey = core.getInput('openAIKey') || process.env.OPENAI_API_KEY | ||
if (!openAiKey) { | ||
throw new Error('OpenAI key is required') | ||
} | ||
this.model = new OpenAI({ | ||
apiKey: openAiKey | ||
}) | ||
} | ||
configuration = { | ||
model: 'gpt-3.5-turbo' | ||
} | ||
model: OpenAI | ||
basePromptTemplate = prompt | ||
jiraPromptTemplate = jiraPrompt | ||
acSummariesPromptTemplate = acSummariesPrompt | ||
compareOldSummaryTemplate(oldSummary: string, newSummary: string): string { | ||
return compareOldSummaryTemplate(oldSummary, newSummary) | ||
constructor() { | ||
const openAiKey = core.getInput('openAIKey') || process.env.OPENAI_API_KEY | ||
if (!openAiKey) { | ||
throw new Error('OpenAI key is required') | ||
} | ||
execute = async (prompt: string) => { | ||
try { | ||
const response = await this.model.chat.completions.create({ | ||
messages: [ | ||
{ | ||
role: 'user', | ||
content: prompt | ||
} | ||
], | ||
...this.configuration | ||
}) | ||
Logger.log('ai response', { response }) | ||
return response.choices[0].message.content | ||
} catch (e) { | ||
Logger.error('error summarizing changes', e) | ||
return null | ||
} | ||
this.model = new OpenAI({ | ||
apiKey: openAiKey | ||
}) | ||
} | ||
configuration = { | ||
model: 'gpt-3.5-turbo' | ||
} | ||
model: OpenAI | ||
basePromptTemplate = prompt | ||
jiraPromptTemplate = jiraPrompt | ||
acSummariesPromptTemplate = acSummariesPrompt | ||
compareOldSummaryTemplate(oldSummary: string, newSummary: string): string { | ||
return compareOldSummaryTemplate(oldSummary, newSummary) | ||
} | ||
execute = async (prompt: string) => { | ||
try { | ||
const response = await this.model.chat.completions.create({ | ||
messages: [ | ||
{ | ||
role: 'user', | ||
content: prompt | ||
} | ||
], | ||
...this.configuration | ||
}) | ||
Logger.log('ai response', { response }) | ||
return response.choices[0].message.content | ||
} catch (e) { | ||
Logger.error('error summarizing changes', e) | ||
return null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './jira.js' | ||
export * from './github.js' | ||
export * from './github.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.