AI works here
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
const axios = require('axios');
|
||||
|
||||
axios.defaults.timeout = 0;
|
||||
|
||||
class OllamaProvider {
|
||||
constructor(config) {
|
||||
this.config = config;
|
||||
@@ -25,11 +27,13 @@ class OllamaProvider {
|
||||
top_p: this.config.topP || 0.95,
|
||||
top_k: this.config.topK || 64,
|
||||
num_predict: this.config.maxOutputTokens || 2048,
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
__jsonFormat() {
|
||||
return {
|
||||
return 'json'
|
||||
/* return {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object',
|
||||
@@ -39,7 +43,7 @@ class OllamaProvider {
|
||||
},
|
||||
required: ['text', 'delay']
|
||||
}
|
||||
};
|
||||
};*/
|
||||
}
|
||||
|
||||
async chat(message, retryCount = 0) {
|
||||
@@ -65,6 +69,7 @@ class OllamaProvider {
|
||||
model: this.model,
|
||||
messages: messages,
|
||||
stream: false,
|
||||
think: false,
|
||||
format: this.__jsonFormat(),
|
||||
options: this.__settings()
|
||||
};
|
||||
@@ -74,7 +79,7 @@ class OllamaProvider {
|
||||
`${this.baseUrl}/api/chat`,
|
||||
requestBody,
|
||||
{
|
||||
timeout: this.config.timeout || 30000,
|
||||
// timeout: this.config.timeout || 30000,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
@@ -83,6 +88,7 @@ class OllamaProvider {
|
||||
|
||||
// Log raw response for debugging
|
||||
const rawContent = response.data.message.content;
|
||||
console.log('Ollama response', rawContent)
|
||||
// console.log('Ollama raw response:', JSON.stringify(rawContent));
|
||||
// console.log('Ollama raw response length:', rawContent?.length);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user