Skip to content

Commit

Permalink
fix: choose model from "New session" view
Browse files Browse the repository at this point in the history
Closes #41
  • Loading branch information
fmaclen committed Jun 6, 2024
1 parent d22541f commit 88b91e0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
Binary file modified docs/session-new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/session.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/routes/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
$: isNewSession = !session?.messages.length;
$: isLastMessageFromUser = session?.messages[session.messages.length - 1]?.role === 'user';
$: session && scrollToBottom();
$: if ($settingsStore?.ollamaModel) { session.model = $settingsStore.ollamaModel };
async function scrollToBottom() {
if (!messageWindow) return;
Expand Down
10 changes: 6 additions & 4 deletions tests/session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,24 +205,25 @@ test('copies the raw text of a message to clipboard', async ({ page }) => {
expect(await page.evaluate(() => navigator.clipboard.readText())).toEqual("I am unable to provide subjective or speculative information, including fight outcomes between individuals.");
});

test('can stop a completion in progress', async ({ page }) => {
test('can start a new session, choose a model and stop a completion in progress', async ({ page }) => {
const promptTextarea = page.getByLabel('Prompt');
const sendButton = page.getByText('Send');
const stopButton = page.getByTitle('Stop response');
const userMessage = page.locator('article', { hasText: "You" })
const aiMessage = page.locator('article', { hasText: "AI" })
const modelName = page.getByTestId('model-name');

await page.goto('/');
await chooseModelFromSettings(page, 'gemma:7b');
await page.getByText("New session").click();
await expect(userMessage).not.toBeVisible();
await expect(aiMessage).not.toBeVisible();

await expect(modelName).toHaveText('New session');

// Mock a response that takes a while to generate
await page.getByLabel('Model').selectOption('gemma:7b');
await page.route('**/generate', () => {});
await promptTextarea.fill('Hello world!');
await sendButton.click();

await expect(userMessage).toBeVisible();
await expect(userMessage).toContainText('Hello world!')
await expect(aiMessage).toBeVisible();
Expand All @@ -231,6 +232,7 @@ test('can stop a completion in progress', async ({ page }) => {
await expect(sendButton).toBeDisabled();
await expect(stopButton).toBeVisible();
await expect(page.getByText("Write a prompt to start a new session")).not.toBeVisible();
await expect(modelName).toHaveText('gemma:7b');

await stopButton.click();
await expect(page.getByText("Write a prompt to start a new session")).toBeVisible();
Expand Down

0 comments on commit 88b91e0

Please sign in to comment.