Elffuss BraidHub

kikocis/continue public

main · 2.3 KiBRawPermalink
1import { ChatMessage, CompletionOptions, ModelProvider } from "../../index.js";
2import { BaseLLM } from "../index.js";
3
4class Mock extends BaseLLM {
5 static Completion = "Test Completion";
6 static providerName: ModelProvider = "mock";
7
8 protected async *_streamComplete(
9 prompt: string,
10 options: CompletionOptions,
11 ): AsyncGenerator<string> {
12 yield Mock.Completion;
13 }
14
15 protected async *_streamChat(
16 messages: ChatMessage[],
17 options: CompletionOptions,
18 ): AsyncGenerator<ChatMessage> {
19 yield {
20 role: "assistant",
21 content: Mock.Completion,
22 };
23 }
24}
25
26export default Mock;
27
28---
29
30import { ChatMessage, CompletionOptions, ModelProvider } from "../../index.js";
31import { BaseLLM } from "../index.js";
32
33class Mock extends BaseLLM {
34 private static _completion: string = "Test Completion";
35 static providerName: ModelProvider = "mock";
36
37 static get completion(): string {
38 return Mock._completion;
39 }
40
41 static set completion(value: string) {
42 Mock._completion = value;
43 }
44
45 protected async *_streamComplete(
46 prompt: string,
47 options: CompletionOptions,
48 ): AsyncGenerator<string> {
49 yield Mock.completion;
50 }
51
52 protected async *_streamChat(
53 messages: ChatMessage[],
54 options: CompletionOptions,
55 ): AsyncGenerator<ChatMessage> {
56 yield {
57 role: "assistant",
58 content: Mock.completion,
59 };
60 }
61}
62
63export default Mock;
64
65---
66
67 import { ChatMessage, CompletionOptions, ModelProvider } from "../../index.js";
68 import { BaseLLM } from "../index.js";
69
70 class Mock extends BaseLLM {
71- static Completion = "Test Completion";
72+ private static _completion: string = "Test Completion";
73 static providerName: ModelProvider = "mock";
74
75+ static get completion(): string {
76+ return Mock._completion;
77+ }
78+
79+ static set completion(value: string) {
80+ Mock._completion = value;
81+ }
82+
83 protected async *_streamComplete(
84 prompt: string,
85 options: CompletionOptions,
86 ): AsyncGenerator<string> {
87- yield Mock.Completion;
88+ yield Mock.completion;
89 }
90
91 protected async *_streamChat(
92 messages: ChatMessage[],
93 options: CompletionOptions,
94 ): AsyncGenerator<ChatMessage> {
95 yield {
96 role: "assistant",
97- content: Mock.Completion,
98+ content: Mock.completion,
99 };
100 }
101 }
102
103 export default Mock;