-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathollama.js
More file actions
36 lines (33 loc) · 1.04 KB
/
ollama.js
File metadata and controls
36 lines (33 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import Ollama from 'ollama'; // Import the Ollama model
import config from '../utils/config.json';
async function ollamaModel(model, flags, diffContent) {
try {
// Use the prompt from the config file emoji and send to Ollama
const categoryResponse = await Ollama.chat({
messages: [
{role: 'system', content: config.commitConfig.emoji},
{role: 'user', content: diffContent},
],
model,
});
// Use the prompt from the config file message and send to Ollama
const messageResponse = await Ollama.chat({
messages: [
{role: 'system', content: config.commitConfig.message},
{role: 'user', content: diffContent},
],
model,
});
console.log('categoryResponse', categoryResponse);
console.log('messageResponse', messageResponse);
return {
category: categoryResponse?.message?.content,
message: messageResponse?.message?.content,
};
} catch (error) {
throw new Error(
'Failed to connect to local Ollama instance. To start Ollama, first download it at https://ollama.ai.',
);
}
}
export default ollamaModel;