Skip to content
Closed
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 tools/server/public/index.html.gz
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { base } from '$app/paths';
import { goto } from '$app/navigation';
import { page } from '$app/state';
import { ChatSidebarConversationItem } from '$lib/components/app';
Expand Down Expand Up @@ -64,13 +65,13 @@
searchQuery = '';
}

await goto(`/chat/${id}`);
await goto(`${base}/chat/${id}`);
}
</script>

<ScrollArea class="h-[100vh]">
<Sidebar.Header class=" top-0 z-10 gap-6 bg-sidebar/50 px-4 pt-4 pb-2 backdrop-blur-lg md:sticky">
<a href="/" onclick={handleMobileSidebarItemClick}>
<a href="{base}/" onclick={handleMobileSidebarItemClick}>
<h1 class="inline-flex items-center gap-1 px-2 text-xl font-semibold">llama.cpp</h1>
</a>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { base } from '$app/paths';
import { Search, SquarePen, X } from '@lucide/svelte';
import { KeyboardShortcutInfo } from '$lib/components/app';
import { Button } from '$lib/components/ui/button';
Expand Down Expand Up @@ -51,7 +52,7 @@
{:else}
<Button
class="w-full justify-between hover:[&>kbd]:opacity-100"
href="/?new_chat=true"
href="{base}/?new_chat=true"
onclick={handleMobileSidebarItemClick}
variant="ghost"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { base } from '$app/paths';
import { AlertTriangle, RefreshCw, Key, CheckCircle, XCircle } from '@lucide/svelte';
import { goto } from '$app/navigation';
import { Button } from '$lib/components/ui/button';
Expand Down Expand Up @@ -64,7 +65,7 @@
updateConfig('apiKey', apiKeyInput.trim());

// Test the API key by making a real request to the server
const response = await fetch('/props', {
const response = await fetch('${base}/props', {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${apiKeyInput.trim()}`
Expand All @@ -77,7 +78,7 @@

// Show success state briefly, then navigate to home
setTimeout(() => {
goto('/');
goto(`${base}/`);
}, 1000);
} else {
// API key is invalid - User Story A
Expand Down
5 changes: 3 additions & 2 deletions tools/server/webui/src/lib/services/chat.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { base } from '$app/paths';
import { config } from '$lib/stores/settings.svelte';
import { slotsService } from './slots';
/**
Expand Down Expand Up @@ -164,7 +165,7 @@ export class ChatService {
const currentConfig = config();
const apiKey = currentConfig.apiKey?.toString().trim();

const response = await fetch(`/v1/chat/completions`, {
const response = await fetch(`${base}/v1/chat/completions`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -531,7 +532,7 @@ export class ChatService {
const currentConfig = config();
const apiKey = currentConfig.apiKey?.toString().trim();

const response = await fetch(`/props`, {
const response = await fetch(`${base}/props`, {
headers: {
'Content-Type': 'application/json',
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {})
Expand Down
3 changes: 2 additions & 1 deletion tools/server/webui/src/lib/services/slots.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { base } from '$app/paths';
import { config } from '$lib/stores/settings.svelte';

/**
Expand Down Expand Up @@ -138,7 +139,7 @@ export class SlotsService {
const currentConfig = config();
const apiKey = currentConfig.apiKey?.toString().trim();

const response = await fetch('/slots', {
const response = await fetch(`${base}/slots`, {
headers: {
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {})
}
Expand Down
5 changes: 3 additions & 2 deletions tools/server/webui/src/lib/stores/chat.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { base } from '$app/paths';
import { DatabaseStore } from '$lib/stores/database';
import { chatService, slotsService } from '$lib/services';
import { serverStore } from '$lib/stores/server.svelte';
Expand Down Expand Up @@ -100,7 +101,7 @@ class ChatStore {

this.maxContextError = null;

await goto(`/chat/${conversation.id}`);
await goto(`${base}/chat/${conversation.id}`);

return conversation.id;
}
Expand Down Expand Up @@ -910,7 +911,7 @@ class ChatStore {
if (this.activeConversation?.id === convId) {
this.activeConversation = null;
this.activeMessages = [];
await goto('/?new_chat=true');
await goto(`${base}/?new_chat=true`);
}
} catch (error) {
console.error('Failed to delete conversation:', error);
Expand Down
3 changes: 2 additions & 1 deletion tools/server/webui/src/lib/stores/server.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { base } from '$app/paths';
import { ChatService } from '$lib/services/chat';
import { config } from '$lib/stores/settings.svelte';

Expand Down Expand Up @@ -98,7 +99,7 @@ class ServerStore {
const currentConfig = config();
const apiKey = currentConfig.apiKey?.toString().trim();

const response = await fetch('/slots', {
const response = await fetch(`${base}/slots`, {
headers: {
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {})
}
Expand Down
3 changes: 2 additions & 1 deletion tools/server/webui/src/lib/utils/api-key-validation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { base } from '$app/paths';
import { error } from '@sveltejs/kit';
import { browser } from '$app/environment';
import { config } from '$lib/stores/settings.svelte';
Expand All @@ -22,7 +23,7 @@ export async function validateApiKey(fetch: typeof globalThis.fetch): Promise<vo
headers.Authorization = `Bearer ${apiKey}`;
}

const response = await fetch('/props', { headers });
const response = await fetch(`${base}/props`, { headers });

if (!response.ok) {
if (response.status === 401 || response.status === 403) {
Expand Down
5 changes: 3 additions & 2 deletions tools/server/webui/src/routes/+error.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { base } from '$app/paths';
import { page } from '$app/stores';
import { goto } from '$app/navigation';
import { ServerErrorSplash } from '$lib/components/app';
Expand All @@ -17,7 +18,7 @@

function handleRetry() {
// Navigate back to home page after successful API key validation
goto('/');
goto(`${base}/`);
}
</script>

Expand Down Expand Up @@ -60,7 +61,7 @@
</p>
</div>
<button
onclick={() => goto('/')}
onclick={() => goto(`${base}/`)}
class="rounded-md bg-primary px-4 py-2 text-primary-foreground hover:bg-primary/90"
>
Go Home
Expand Down
5 changes: 3 additions & 2 deletions tools/server/webui/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { base } from '$app/paths';
import '../app.css';
import { page } from '$app/state';
import {
Expand Down Expand Up @@ -49,7 +50,7 @@

if (isCtrlOrCmd && event.shiftKey && event.key === 'o') {
event.preventDefault();
goto('/?new_chat=true');
goto(`${base}/?new_chat=true`);
}

if (event.shiftKey && isCtrlOrCmd && event.key === 'e') {
Expand Down Expand Up @@ -115,7 +116,7 @@
headers.Authorization = `Bearer ${apiKey.trim()}`;
}

fetch('/props', { headers })
fetch(`${base}/props`, { headers })
.then((response) => {
if (response.status === 401 || response.status === 403) {
window.location.reload();
Expand Down
3 changes: 2 additions & 1 deletion tools/server/webui/src/routes/chat/[id]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { base } from '$app/paths';
import { goto } from '$app/navigation';
import { page } from '$app/state';
import { beforeNavigate } from '$app/navigation';
Expand Down Expand Up @@ -44,7 +45,7 @@
const success = await chatStore.loadConversation(chatId);

if (!success) {
await goto('/');
await goto(`${base}/`);
}
})();
}
Expand Down
5 changes: 5 additions & 0 deletions tools/server/webui/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const config = {
// for more information about preprocessors
preprocess: [vitePreprocess(), mdsvex()],
kit: {
paths: {
// Base path for deployment in subdirectories (e.g., '/llama' for hosting at example.com/llama)
// Leave empty ('') for root deployment (default behavior)
base: process.env.BASE_PATH || ''
},
adapter: adapter({
pages: '../public',
assets: '../public',
Expand Down