Commit 81741ae5 by Michael Pastushkov

config

parent 527ec633
......@@ -12,6 +12,13 @@
"port": 3011
},
"ai": {
"endpoint": "http://127.0.0.1:11434",
"model": "gpt-oss:120b",
"embed_model": "nomic-embed-text",
"label_model": "llama3:8b"
},
"housekeeping": {
"cronTime": "0 0 * * * *",
"on_start": false
......
......@@ -3,6 +3,7 @@
* Created by: Michael Pastushkov <michael@pastushkov.com>
*/
const config = require('config');
const HistoryManager = require('./HistoryManager');
const TopicRouter = require('./TopicRouter');
const utils = require('../utils/utils');
......@@ -75,7 +76,7 @@ class ConversationManager {
});
// Making the main request to model
const res = await fetch('http://127.0.0.1:11434/api/chat', {
const res = await fetch(`${config.ai.endpoint}/api/chat`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: body
......
......@@ -3,13 +3,14 @@
* Created by: Michael Pastushkov <michael@pastushkov.com>
*/
const config = require('config');
const { v4: uuidv4 } = require('uuid');
const utils = require('../utils/utils');
const ConversationManager = require('./ConversationManager');
const MODEL = 'gpt-oss:20b'; // 'llama3:8b'; // 'gpt-oss:20b';
const EMBED_MODEL = 'nomic-embed-text';
const LABEL_MODEL = 'llama3:8b';
const MODEL = config.ai.model || 'gpt-oss:20b';
const EMBED_MODEL = config.ai.embed_model || 'nomic-embed-text';
const LABEL_MODEL = config.ai.label_model || 'llama3:8b';
const sessions = new Map(); // cookie -> ConversationManager
//const queues = new Map(); // cookie -> Promise (to serialize)
......
......@@ -3,6 +3,7 @@
* Created by: Michael Pastushkov <michael@pastushkov.com>
*/
const config = require('config');
const utils = require('../utils/utils');
class TopicRouter {
......@@ -24,7 +25,7 @@ class TopicRouter {
utils.log('_mintLabelWithLLM', 5);
utils.log(`model: ${this.labelModel}`, 5);
const sys = `Return a short topic key (1–3 words, lowercase, hyphenated). Only the key.`;
const r = await fetch('http://127.0.0.1:11434/api/chat', {
const r = await fetch(`${config.ai.endpoint}/api/chat`, {
method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: this.labelModel,
......@@ -92,7 +93,7 @@ class TopicRouter {
async embed(text) {
utils.log(`Embed ${text}`, 5);
utils.log(`model: ${this.embedModel}`, 5);
const r = await fetch('http://127.0.0.1:11434/api/embeddings', {
const r = await fetch(`${config.ai.endpoint}/api/embeddings`, {
method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: this.embedModel,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment