support read OCO_OLLAMA_API_URL from env to OllamaAiEngine and fix bug in getting ollma model name when slash exists (#375)

This commit is contained in:
XIAOTIAN LIU
2024-08-18 19:22:30 +08:00
committed by GitHub
parent c425878f21
commit 07f7a05c4b
4 changed files with 34 additions and 18 deletions
+2 -1
View File
@@ -396,7 +396,8 @@ export const getConfig = ({
OCO_ONE_LINE_COMMIT:
process.env.OCO_ONE_LINE_COMMIT === 'true' ? true : false,
OCO_AZURE_ENDPOINT: process.env.OCO_AZURE_ENDPOINT || undefined,
OCO_TEST_MOCK_TYPE: process.env.OCO_TEST_MOCK_TYPE || 'commit-message'
OCO_TEST_MOCK_TYPE: process.env.OCO_TEST_MOCK_TYPE || 'commit-message',
OCO_OLLAMA_API_URL: process.env.OCO_OLLAMA_API_URL || undefined,
};
const configExists = existsSync(configPath);
+5 -3
View File
@@ -13,9 +13,11 @@ export function getEngine(): AiEngine {
if (provider?.startsWith('ollama')) {
const ollamaAi = new OllamaAi();
const model = provider.split('/')[1];
if (model) ollamaAi.setModel(model);
const model = provider.substring('ollama/'.length);
if (model) {
ollamaAi.setModel(model);
ollamaAi.setUrl(config?.OCO_OLLAMA_API_URL);
}
return ollamaAi;
} else if (provider == 'anthropic') {
return new AnthropicAi();