mirror of
https://github.com/likelovewant/ollama-for-amd.git
synced 2025-12-21 22:33:56 +00:00
app/ui: fix to point ollama client to ui backend in dev mode (#13079)
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
|||||||
import { parseJsonlFromResponse } from "./util/jsonl-parsing";
|
import { parseJsonlFromResponse } from "./util/jsonl-parsing";
|
||||||
import { ollamaClient as ollama } from "./lib/ollama-client";
|
import { ollamaClient as ollama } from "./lib/ollama-client";
|
||||||
import type { ModelResponse } from "ollama/browser";
|
import type { ModelResponse } from "ollama/browser";
|
||||||
|
import { API_BASE } from "./lib/config";
|
||||||
|
|
||||||
// Extend Model class with utility methods
|
// Extend Model class with utility methods
|
||||||
declare module "@/gotypes" {
|
declare module "@/gotypes" {
|
||||||
@@ -27,8 +28,6 @@ Model.prototype.isCloud = function (): boolean {
|
|||||||
return this.model.endsWith("cloud");
|
return this.model.endsWith("cloud");
|
||||||
};
|
};
|
||||||
|
|
||||||
const API_BASE = import.meta.env.DEV ? "http://127.0.0.1:3001" : "";
|
|
||||||
|
|
||||||
// Helper function to convert Uint8Array to base64
|
// Helper function to convert Uint8Array to base64
|
||||||
function uint8ArrayToBase64(uint8Array: Uint8Array): string {
|
function uint8ArrayToBase64(uint8Array: Uint8Array): string {
|
||||||
const chunkSize = 0x8000; // 32KB chunks to avoid stack overflow
|
const chunkSize = 0x8000; // 32KB chunks to avoid stack overflow
|
||||||
|
|||||||
10
app/ui/app/src/lib/config.ts
Normal file
10
app/ui/app/src/lib/config.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
// API configuration
|
||||||
|
const DEV_API_URL = "http://127.0.0.1:3001";
|
||||||
|
|
||||||
|
// Base URL for fetch API calls (can be relative in production)
|
||||||
|
export const API_BASE = import.meta.env.DEV ? DEV_API_URL : "";
|
||||||
|
|
||||||
|
// Full host URL for Ollama client (needs full origin in production)
|
||||||
|
export const OLLAMA_HOST = import.meta.env.DEV
|
||||||
|
? DEV_API_URL
|
||||||
|
: window.location.origin;
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Ollama } from "ollama/browser";
|
import { Ollama } from "ollama/browser";
|
||||||
|
import { OLLAMA_HOST } from "./config";
|
||||||
|
|
||||||
let _ollamaClient: Ollama | null = null;
|
let _ollamaClient: Ollama | null = null;
|
||||||
|
|
||||||
@@ -6,7 +7,7 @@ export const ollamaClient = new Proxy({} as Ollama, {
|
|||||||
get(_target, prop) {
|
get(_target, prop) {
|
||||||
if (!_ollamaClient) {
|
if (!_ollamaClient) {
|
||||||
_ollamaClient = new Ollama({
|
_ollamaClient = new Ollama({
|
||||||
host: window.location.origin,
|
host: OLLAMA_HOST,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const value = _ollamaClient[prop as keyof Ollama];
|
const value = _ollamaClient[prop as keyof Ollama];
|
||||||
|
|||||||
Reference in New Issue
Block a user