Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
KotGPT
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Michael Pastushkov
KotGPT
Commits
d7205241
Commit
d7205241
authored
Aug 17, 2025
by
Michael Pastushkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
9fe33590
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
6 deletions
+14
-6
src/api/ConversationManager.js
+9
-3
src/api/HistoryManager.js
+1
-1
src/api/TopicRouter.js
+4
-2
No files found.
src/api/ConversationManager.js
View file @
d7205241
...
...
@@ -13,7 +13,7 @@ class ConversationManager {
this
.
model
=
model
;
this
.
embedModel
=
embedModel
;
this
.
labelModel
=
labelModel
;
this
.
router
=
new
TopicRouter
({
embedModel
:
embedModel
,
labelModel
:
labelModel
});
this
.
router
=
new
TopicRouter
({
embedModel
:
embedModel
,
labelModel
:
labelModel
});
this
.
history
=
new
HistoryManager
();
this
.
lastTopic
=
null
;
this
.
lastTopicAt
=
0
;
...
...
@@ -58,13 +58,14 @@ class ConversationManager {
////
const
messages
=
this
.
history
.
buildMessages
(
prompt
,
topic
);
utils
.
log
(
`model:
${
this
.
model
}
`
,
5
);
utils
.
log
(
messages
,
5
);
const
body
=
JSON
.
stringify
({
model
:
this
.
model
,
messages
:
messages
,
stream
:
true
,
keep_alive
:
'1m'
,
// keeps model in RAM
keep_alive
:
'1m'
,
//
'inf', // '1m'
keeps model in RAM
// options: { num_ctx: 8192 } // optional: larger context if your model supports it
});
...
...
@@ -90,10 +91,15 @@ class ConversationManager {
break
;
const
chunk
=
decoder
.
decode
(
value
,
{
stream
:
true
});
for
(
const
line
of
chunk
.
split
(
'
\
n'
).
filter
(
Boolean
))
{
const
j
=
utils
.
parse
(
line
);
if
(
j
)
{
// const thinkDelta = j.message?.reasoning ?? j.message?.thinking ?? '';
// if (thinkDelta) {
// callback(`[thinking] ${thinkDelta}`);
// }
const
delta
=
j
.
message
?.
content
||
''
;
if
(
delta
)
{
full
+=
delta
;
...
...
src/api/HistoryManager.js
View file @
d7205241
...
...
@@ -4,7 +4,7 @@
*/
const
WHOAMI
=
'I am a virtual cat helping you to the best of my abilities.'
;
const
ADVICE
=
'Prioritize the user
\'
s latest messages. Use prior turns only as context.'
;
const
ADVICE
=
'Prioritize the user
\'
s latest messages. Use prior turns only as context.
Respond in the language of the request.
'
;
class
HistoryManager
{
...
...
src/api/TopicRouter.js
View file @
d7205241
...
...
@@ -8,8 +8,8 @@ class TopicRouter {
constructor
({
embedModel
=
'nomic-embed-text'
,
labelModel
=
'llama3:8b'
,
threshold
=
0.76
}
=
{})
{
this
.
embedModel
=
embedModel
;
// ollama pull nomic-embed-text
this
.
threshold
=
labelModel
;
// similarity to attach to existing topic
this
.
labelModel
=
threshold
;
// used only to mint a short label
this
.
labelModel
=
labelModel
;
// used only to mint a short label
this
.
threshold
=
threshold
;
// similarity to attach to existing topic
this
.
topics
=
new
Map
();
// key -> { centroid: number[], count: number, summary: '' }
this
.
_counter
=
1
;
// fallback id
}
...
...
@@ -22,6 +22,7 @@ class TopicRouter {
async
_mintLabelWithLLM
(
text
)
{
// Single short key, language-agnostic (works for RU/EN/etc.)
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'
,
{
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json'
},
...
...
@@ -84,6 +85,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'
,
{
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json'
},
body
:
JSON
.
stringify
({
model
:
this
.
embedModel
,
prompt
:
text
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment