Merge pull request #44 from TarekS93/main

Enhance Ollama Model Integration and Type Definitions
This commit is contained in:
Cole Medin 2024-10-24 08:07:34 -05:00 committed by GitHub
commit 65cf12dca0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
import type { ModelInfo } from './types'; import type { ModelInfo, OllamaApiResponse, OllamaModel } from './types';
export const WORK_DIR_NAME = 'project'; export const WORK_DIR_NAME = 'project';
export const WORK_DIR = `/home/${WORK_DIR_NAME}`; export const WORK_DIR = `/home/${WORK_DIR_NAME}`;
@ -48,9 +48,9 @@ export let MODEL_LIST: ModelInfo[] = [...staticModels];
async function getOllamaModels(): Promise<ModelInfo[]> { async function getOllamaModels(): Promise<ModelInfo[]> {
try { try {
const response = await fetch(`http://localhost:11434/api/tags`); const response = await fetch(`http://localhost:11434/api/tags`);
const data = await response.json(); const data = await response.json() as OllamaApiResponse;
return data.models.map((model: any) => ({ return data.models.map((model: OllamaModel) => ({
name: model.name, name: model.name,
label: `${model.name} (${model.details.parameter_size})`, label: `${model.name} (${model.details.parameter_size})`,
provider: 'Ollama', provider: 'Ollama',

View File

@ -8,7 +8,7 @@ interface OllamaModelDetails {
quantization_level: string; quantization_level: string;
} }
interface OllamaModel { export interface OllamaModel {
name: string; name: string;
model: string; model: string;
modified_at: string; modified_at: string;