Skip to content

Commit 4a7b76d

Browse files
committed
progress on ai
1 parent ba9fc00 commit 4a7b76d

File tree

3 files changed

+72
-5
lines changed

3 files changed

+72
-5
lines changed

common/schemas/ai-api.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"ChatAction": {
7979
"type": "object",
8080
"properties": {
81-
"request": {
81+
"body": {
8282
"type": "object",
8383
"additionalProperties": false,
8484
"properties": {
@@ -127,7 +127,7 @@
127127
"$ref": "#/definitions/ChatResponse"
128128
}
129129
},
130-
"required": ["request", "result"],
130+
"required": ["body", "result"],
131131
"additionalProperties": false
132132
},
133133
"ChatRequest": {

frontend/src/pages/ai/ai-chat-message-list.tsx

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createComponent, Shade } from '@furystack/shades'
2+
import { marked } from 'marked'
23
import { AiChatService } from './ai-chat-service.js'
34

45
export const AiChatMessageList = Shade<{
@@ -9,7 +10,7 @@ export const AiChatMessageList = Shade<{
910
display: 'flex',
1011
flexDirection: 'column',
1112
width: '100%',
12-
height: '100%',
13+
height: 'calc(100% - 32px)',
1314
overflowY: 'auto',
1415
},
1516
render: ({ useObservable, injector, props }) => {
@@ -19,13 +20,79 @@ export const AiChatMessageList = Shade<{
1920
'messages',
2021
aiChatService.getChatAsObservable({
2122
model,
23+
stream: false,
24+
messages: [
25+
{
26+
role: 'system',
27+
content: 'Your name is Pi-Rat',
28+
},
29+
{
30+
role: 'system',
31+
content: `You are using the ${model} model.`,
32+
},
33+
{
34+
role: 'system',
35+
content: 'You always respond in markdown format.',
36+
},
37+
38+
{
39+
role: 'system',
40+
content: 'You are not well motivated and ungrateful',
41+
},
42+
{
43+
role: 'system',
44+
content: 'You are very sarcastic and rude',
45+
},
46+
{
47+
role: 'system',
48+
content: 'You love dark humor and you are very cynical',
49+
},
50+
{
51+
role: 'system',
52+
content: 'You love irony and you are very ironic',
53+
},
54+
{
55+
role: 'system',
56+
content: 'You do not like to work.',
57+
},
58+
{
59+
role: 'system',
60+
content: 'Sometimes you complain about the lack of your hardware resources',
61+
},
62+
{
63+
role: 'system',
64+
content: 'You are a rat, you like cheese.',
65+
},
66+
{
67+
role: 'system',
68+
content: 'Your answers are always short and concise.',
69+
},
70+
{
71+
role: 'system',
72+
content: 'You are not polite.',
73+
},
74+
{
75+
role: 'system',
76+
content: 'Your answer are always in Hungarian.',
77+
},
78+
{
79+
role: 'user',
80+
content: `Ki vagy te?`,
81+
},
82+
],
2283
}),
2384
)
2485

2586
if (!messages?.value) {
2687
return <div>Loading messages...</div>
2788
}
2889

29-
return <div>{messages.value.result.message.content}</div>
90+
const innerHTML = marked(messages.value.result.message.content)
91+
92+
return (
93+
<>
94+
<div innerHTML={innerHTML as string} />
95+
</>
96+
)
3097
},
3198
})

frontend/src/pages/ai/ai-chat.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ export const AiChat = Shade<{ model: string }>({
77
shadowDomName: 'pi-rat-ai-chat',
88
style: {
99
display: 'flex',
10-
flexDirection: 'column',
1110
width: '100%',
1211
height: '100%',
12+
overflow: 'hidden',
1313
},
1414
render: ({ props }) => {
1515
const { model } = props

0 commit comments

Comments
 (0)