mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-10-18 21:38:14 +00:00
feat(app): lint & beautify
This commit is contained in:
@@ -2,9 +2,7 @@ import { Dialog, DialogPanel } from '@headlessui/react';
|
||||
import { Loader2, Trash2 } from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
import { AnimatePresence, motion } from 'framer-motion';
|
||||
import {
|
||||
ConfigModelProvider,
|
||||
} from '@/lib/config/types';
|
||||
import { ConfigModelProvider } from '@/lib/config/types';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
const DeleteProvider = ({
|
||||
@@ -83,8 +81,9 @@ const DeleteProvider = ({
|
||||
</div>
|
||||
<div className="border-t border-light-200 dark:border-dark-200" />
|
||||
<div className="flex-1 overflow-y-auto px-6 py-4">
|
||||
<p className='text-SM text-black/60 dark:text-white/60'>
|
||||
Are you sure you want to delete the provider "{modelProvider.name}"? This action cannot be undone.
|
||||
<p className="text-SM text-black/60 dark:text-white/60">
|
||||
Are you sure you want to delete the provider "
|
||||
{modelProvider.name}"? This action cannot be undone.
|
||||
</p>
|
||||
</div>
|
||||
<div className="px-6 py-6 flex justify-end space-x-2">
|
||||
|
@@ -129,7 +129,11 @@ const ModelProvider = ({
|
||||
<div className="flex flex-row items-center gap-2 text-sm text-red-500 dark:text-red-400 rounded-lg bg-red-50 dark:bg-red-950/20 px-3 py-2 border border-red-200 dark:border-red-900/30">
|
||||
<AlertCircle size={16} className="shrink-0" />
|
||||
<span className="break-words">
|
||||
{modelProvider.chatModels.find((m) => m.key === 'error')?.name}
|
||||
{
|
||||
modelProvider.chatModels.find(
|
||||
(m) => m.key === 'error',
|
||||
)?.name
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
) : (
|
||||
@@ -167,11 +171,17 @@ const ModelProvider = ({
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
{modelProvider.embeddingModels.some((m) => m.key === 'error') ? (
|
||||
{modelProvider.embeddingModels.some(
|
||||
(m) => m.key === 'error',
|
||||
) ? (
|
||||
<div className="flex flex-row items-center gap-2 text-sm text-red-500 dark:text-red-400 rounded-lg bg-red-50 dark:bg-red-950/20 px-3 py-2 border border-red-200 dark:border-red-900/30">
|
||||
<AlertCircle size={16} className="shrink-0" />
|
||||
<span className="break-words">
|
||||
{modelProvider.embeddingModels.find((m) => m.key === 'error')?.name}
|
||||
{
|
||||
modelProvider.embeddingModels.find(
|
||||
(m) => m.key === 'error',
|
||||
)?.name
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
) : (
|
||||
|
@@ -11,4 +11,5 @@ export const getConfiguredModelProviderById = (
|
||||
return getConfiguredModelProviders().find((p) => p.id === id) ?? undefined;
|
||||
};
|
||||
|
||||
export const getSearxngURL = () => configManager.getConfig('search.searxngURL', '')
|
||||
export const getSearxngURL = () =>
|
||||
configManager.getConfig('search.searxngURL', '');
|
||||
|
@@ -17,7 +17,6 @@ type StringUIConfigField = BaseUIConfigField & {
|
||||
|
||||
type SelectUIConfigFieldOptions = {
|
||||
name: string;
|
||||
key: string;
|
||||
value: string;
|
||||
};
|
||||
|
||||
@@ -56,8 +55,8 @@ type Config = {
|
||||
};
|
||||
modelProviders: ConfigModelProvider[];
|
||||
search: {
|
||||
[key: string]: any
|
||||
}
|
||||
[key: string]: any;
|
||||
};
|
||||
};
|
||||
|
||||
type EnvMap = {
|
||||
@@ -84,6 +83,8 @@ export type {
|
||||
Config,
|
||||
EnvMap,
|
||||
UIConfigSections,
|
||||
SelectUIConfigField,
|
||||
StringUIConfigField,
|
||||
ModelProviderUISection,
|
||||
ConfigModelProvider,
|
||||
};
|
||||
|
@@ -5,7 +5,7 @@ import OllamaProvider from './ollama';
|
||||
|
||||
export const providers: Record<string, ProviderConstructor<any>> = {
|
||||
openai: OpenAIProvider,
|
||||
ollama: OllamaProvider
|
||||
ollama: OllamaProvider,
|
||||
};
|
||||
|
||||
export const getModelProvidersUIConfigSection =
|
||||
|
@@ -18,7 +18,9 @@ const providerConfigFields: UIConfigField[] = [
|
||||
description: 'The base URL for the Ollama',
|
||||
required: true,
|
||||
placeholder: 'Ollama Base URL',
|
||||
default: process.env.DOCKER ? 'http://host.docker.internal:11434' : 'http://localhost:11434',
|
||||
default: process.env.DOCKER
|
||||
? 'http://host.docker.internal:11434'
|
||||
: 'http://localhost:11434',
|
||||
env: 'OLLAMA_BASE_URL',
|
||||
scope: 'server',
|
||||
},
|
||||
@@ -32,20 +34,20 @@ class OllamaProvider extends BaseModelProvider<OllamaConfig> {
|
||||
async getDefaultModels(): Promise<ModelList> {
|
||||
try {
|
||||
const res = await fetch(`${this.config.baseURL}/api/tags`, {
|
||||
method: "GET",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-type': 'application/json'
|
||||
}
|
||||
})
|
||||
'Content-type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
const data = await res.json()
|
||||
const data = await res.json();
|
||||
|
||||
const models: Model[] = data.models.map((m: any) => {
|
||||
return {
|
||||
name: m.name,
|
||||
key: m.model
|
||||
}
|
||||
})
|
||||
key: m.model,
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
embedding: models,
|
||||
@@ -53,7 +55,9 @@ class OllamaProvider extends BaseModelProvider<OllamaConfig> {
|
||||
};
|
||||
} catch (err) {
|
||||
if (err instanceof TypeError) {
|
||||
throw new Error('Error connecting to Ollama API. Please ensure the base URL is correct and the Ollama server is running.');
|
||||
throw new Error(
|
||||
'Error connecting to Ollama API. Please ensure the base URL is correct and the Ollama server is running.',
|
||||
);
|
||||
}
|
||||
|
||||
throw err;
|
||||
@@ -111,9 +115,7 @@ class OllamaProvider extends BaseModelProvider<OllamaConfig> {
|
||||
if (!raw || typeof raw !== 'object')
|
||||
throw new Error('Invalid config provided. Expected object');
|
||||
if (!raw.baseURL)
|
||||
throw new Error(
|
||||
'Invalid config provided. Base URL must be provided',
|
||||
);
|
||||
throw new Error('Invalid config provided. Base URL must be provided');
|
||||
|
||||
return {
|
||||
baseURL: String(raw.baseURL),
|
||||
|
@@ -67,7 +67,6 @@ class ModelRegistry {
|
||||
chatModels: m.chat,
|
||||
embeddingModels: m.embedding,
|
||||
});
|
||||
|
||||
}),
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user