Skip to content

Commit 7ed557f

Browse files
committed
dev: add fake chat service, for testing
1 parent 8678992 commit 7ed557f

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const BaseService = require("../../services/BaseService");
2+
3+
class FakeChatService extends BaseService {
4+
static IMPLEMENTS = {
5+
['puter-chat-completion']: {
6+
async list () {
7+
return ['fake'];
8+
},
9+
async complete ({ messages, stream, model }) {
10+
return {
11+
message: {
12+
"id": "00000000-0000-0000-0000-000000000000",
13+
"type": "message",
14+
"role": "assistant",
15+
"model": "fake",
16+
"content": [
17+
{
18+
"type": "text",
19+
"text": "I am a fake AI, I don't know how to respond to anything."
20+
}
21+
],
22+
"stop_reason": "end_turn",
23+
"stop_sequence": null,
24+
"usage": {
25+
"input_tokens": 0,
26+
"output_tokens": 1
27+
}
28+
}
29+
}
30+
}
31+
}
32+
}
33+
}
34+
35+
module.exports = {
36+
FakeChatService,
37+
};

src/backend/src/modules/puterai/PuterAIModule.js

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ class PuterAIModule extends AdvancedBase {
5353
const { XAIService } = require('./XAIService');
5454
services.registerService('xai', XAIService);
5555
}
56+
57+
const { FakeChatService } = require('./FakeChatService');
58+
services.registerService('fake-chat', FakeChatService);
5659
}
5760
}
5861

0 commit comments

Comments
 (0)