feat: add provider abstraction for review backends
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// OpenAI chat provider adapter.
|
||||
// Wraps src/openai/client.js + src/openai/responses.js into the provider interface.
|
||||
|
||||
import { createOpenAIClient } from "../openai/client.js";
|
||||
import { sendOpenAIResponse } from "../openai/responses.js";
|
||||
|
||||
/**
|
||||
* Chat provider backed by OpenAI Responses API.
|
||||
* Implements { send(input, config) => Promise<{ content: string }> }.
|
||||
*/
|
||||
export const openaiProvider = {
|
||||
/**
|
||||
* @param {object} input - validated tool input (post-budget check).
|
||||
* @param {object} config - full config from loadConfig().
|
||||
* @returns {Promise<{ content: string }>}
|
||||
*/
|
||||
async send(input, config) {
|
||||
const client = createOpenAIClient(config);
|
||||
|
||||
const result = await sendOpenAIResponse(client, {
|
||||
input: [{ role: "system", content: input }],
|
||||
model: config.openaiModel,
|
||||
temperature: config.temperature,
|
||||
maxOutputTokens: config.maxOutputTokens,
|
||||
});
|
||||
|
||||
return { content: result.content };
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user