Skip to content

Commit

Permalink
Fix scrolling again, add default system message
Browse files Browse the repository at this point in the history
  • Loading branch information
cephalization committed Oct 20, 2023
1 parent 69ada74 commit 54b682e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
11 changes: 9 additions & 2 deletions apps/messages/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export default class Agent implements Party.Server {

async onRequest(req: Party.Request) {
try {
console.log(req.url);
if (req.method === 'POST') {
const body = await req.json();
const result = valibot.safeParse(requests, body);
Expand Down Expand Up @@ -188,7 +187,15 @@ export default class Agent implements Party.Server {
invariant(openai);
const stream = await openai.chat.completions.create({
model: 'gpt-3.5-turbo-16k',
messages: [...systemMessages, ...messages],
messages: [
{
role: 'system',
content:
'You are a chat LLM whose responses are parsed as markdown and rendered in a web UI.'
},
...systemMessages,
...messages
],
stream: true
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
const lastMessageEl = messagesEl.lastElementChild;
if (lastMessageEl instanceof HTMLElement) {
// select the last message's element with the .prose class
const lastMessageContent = lastMessageEl.querySelector('.prose');
const lastMessageContent = lastMessageEl.querySelector('.prose > article');
if (lastMessageContent instanceof HTMLElement) {
lastMessageContent.scrollIntoView({ behavior: smooth ? 'smooth' : undefined });
// get the last, deepest nested child element of lastMessageContent and then scroll to it
lastMessageContent.lastElementChild?.scrollIntoView({
behavior: smooth ? 'smooth' : undefined
});
}
}
}
Expand Down

0 comments on commit 54b682e

Please sign in to comment.