Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: choose model from "New session" view #42

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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