File tree Expand file tree Collapse file tree 3 files changed +16
-11
lines changed
examples/server/webui/src/utils Expand file tree Collapse file tree 3 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 1
1
import { useEffect, useState } from 'react';
2
- import { MessageExtraTextFile } from './types';
2
+ import { MessageExtraContext } from './types';
3
3
4
4
// Extra context when using llama.cpp WebUI from llama-vscode, inside an iframe
5
5
// Ref: https://github.com/ggml-org/llama.cpp/pull/11940
@@ -18,7 +18,7 @@ export const useVSCodeContext = (
18
18
inputRef: React.RefObject<HTMLTextAreaElement>,
19
19
setInputMsg: (text: string) => void
20
20
) => {
21
- const [extraContext, setExtraContext] = useState<MessageExtraTextFile | null>(
21
+ const [extraContext, setExtraContext] = useState<MessageExtraContext | null>(
22
22
null
23
23
);
24
24
console.log({ extraContext });
@@ -29,11 +29,12 @@ export const useVSCodeContext = (
29
29
if (event.data?.command === 'setText') {
30
30
const data: SetTextEvData = event.data;
31
31
setInputMsg(data?.text);
32
- setExtraContext({
33
- type: 'textFile',
34
- name: '(context)', // TODO: set filename
35
- content: data?.context ?? '(no context)',
36
- });
32
+ if (data?.context && data.context.length > 0) {
33
+ setExtraContext({
34
+ type: 'context',
35
+ content: data.context,
36
+ });
37
+ }
37
38
inputRef.current?.focus();
38
39
}
39
40
};
Original file line number Diff line number Diff line change @@ -60,9 +60,8 @@ export function normalizeMsgsForAPI(messages: Readonly<Message[]>) {
60
60
let newContent = '';
61
61
62
62
for (const extra of msg.extra ?? []) {
63
- if (extra.type === 'textFile') {
64
- // TODO: allow user to customize this via Settings
65
- newContent += `\n===\nExtra file: ${extra.name}\n${extra.content}\n\n===\n`;
63
+ if (extra.type === 'context') {
64
+ newContent += `${extra.content}\n\n`;
66
65
}
67
66
}
68
67
Original file line number Diff line number Diff line change @@ -48,14 +48,19 @@ export interface Message {
48
48
children: Message['id'][];
49
49
}
50
50
51
- type MessageExtra = MessageExtraTextFile; // TODO: will add more in the future
51
+ type MessageExtra = MessageExtraTextFile | MessageExtraContext ; // TODO: will add more in the future
52
52
53
53
export interface MessageExtraTextFile {
54
54
type: 'textFile';
55
55
name: string;
56
56
content: string;
57
57
}
58
58
59
+ export interface MessageExtraContext {
60
+ type: 'context';
61
+ content: string;
62
+ }
63
+
59
64
export type APIMessage = Pick<Message, 'role' | 'content'>;
60
65
61
66
export interface Conversation {
You can’t perform that action at this time.
0 commit comments