Skip to content

Commit

Permalink
add custom model
Browse files Browse the repository at this point in the history
  • Loading branch information
not-nullptr committed Apr 26, 2024
1 parent bebbeb8 commit 3c98a17
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/lib/ai/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Ollama } from "ollama/browser";

export const model = "llama3:8b";

export let ai = {
ollama: new Ollama({
host:
Expand Down
3 changes: 1 addition & 2 deletions src/lib/fncaller/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { browser } from "$app/environment";
import { host, model } from "$lib/ai";
import { settingsStore } from "$lib/settings";
import type { ChatResponse, Message } from "ollama";
import { get, writable } from "svelte/store";
Expand Down Expand Up @@ -66,7 +65,7 @@ export class FunctionCaller<T extends FunctionSchema> {
const res = await fetch(`${settings.ollamaUrl}/api/chat`, {
method: "POST",
body: JSON.stringify({
model,
model: settings.model,
messages: [
{
role: "system",
Expand Down
5 changes: 5 additions & 0 deletions src/lib/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export const settingsSchema = {
}
},
},
model: {
label: "Model",
type: "string",
default: "llama3:8b",
},
enforceJsonOutput: {
label: "Enforce JSON Output (slower but far more reliable)",
type: "boolean",
Expand Down
3 changes: 1 addition & 2 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
import { browser } from "$app/environment";
import { host, model, ai } from "$lib/ai";
import { FunctionCaller, messagesStore, toolsStore } from "$lib/fncaller";
import type { ChatResponse, Message } from "ollama/browser";
import { onMount, tick } from "svelte";
Expand Down Expand Up @@ -203,7 +202,7 @@
"Content-Type": "application/json",
},
body: JSON.stringify({
model,
model: $settingsStore.model,
messages: [...chatHistory.slice(0, -1)],
stream: true,
}),
Expand Down

0 comments on commit 3c98a17

Please sign in to comment.