refactor: Naming & Enums
This commit is contained in:
parent
2562dc50bd
commit
6daa39994c
|
|
@ -8,7 +8,7 @@
|
|||
} from '$lib/components/app';
|
||||
import { INPUT_CLASSES } from '$lib/constants/css-classes';
|
||||
import { SETTING_CONFIG_DEFAULT } from '$lib/constants/settings-config';
|
||||
import { MimeTypeText } from '$lib/enums';
|
||||
import { MimeTypeText, SpecialFileType } from '$lib/enums';
|
||||
import { config } from '$lib/stores/settings.svelte';
|
||||
import { modelOptions, selectedModelId } from '$lib/stores/models.svelte';
|
||||
import { isRouterMode } from '$lib/stores/server.svelte';
|
||||
|
|
@ -189,7 +189,7 @@
|
|||
id: placeholderId,
|
||||
name: promptName,
|
||||
size: 0,
|
||||
type: 'mcp-prompt',
|
||||
type: SpecialFileType.MCP_PROMPT,
|
||||
file: new File([], 'loading'),
|
||||
isLoading: true,
|
||||
mcpPrompt: {
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@
|
|||
side = 'top',
|
||||
children,
|
||||
arrowClasses,
|
||||
usePortal = true,
|
||||
noPortal = false,
|
||||
...restProps
|
||||
}: TooltipPrimitive.ContentProps & {
|
||||
arrowClasses?: string;
|
||||
usePortal?: boolean;
|
||||
noPortal?: boolean;
|
||||
} = $props();
|
||||
|
||||
const contentClass = $derived(
|
||||
|
|
@ -52,10 +52,10 @@
|
|||
</TooltipPrimitive.Content>
|
||||
{/snippet}
|
||||
|
||||
{#if usePortal}
|
||||
{#if noPortal}
|
||||
{@render tooltipContent()}
|
||||
{:else}
|
||||
<TooltipPrimitive.Portal>
|
||||
{@render tooltipContent()}
|
||||
</TooltipPrimitive.Portal>
|
||||
{:else}
|
||||
{@render tooltipContent()}
|
||||
{/if}
|
||||
|
|
|
|||
|
|
@ -1 +1,8 @@
|
|||
export const PROCESSING_INFO_TIMEOUT = 2000;
|
||||
|
||||
/**
|
||||
* Statistics units labels
|
||||
*/
|
||||
export const STATS_UNITS = {
|
||||
TOKENS_PER_SECOND: 't/s'
|
||||
} as const;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,14 @@ export enum ChatMessageStatsView {
|
|||
SUMMARY = 'summary'
|
||||
}
|
||||
|
||||
/**
|
||||
* Reasoning format options for API requests.
|
||||
*/
|
||||
export enum ReasoningFormat {
|
||||
NONE = 'none',
|
||||
AUTO = 'auto'
|
||||
}
|
||||
|
||||
/**
|
||||
* Message roles for chat messages.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -11,6 +11,13 @@ export enum FileTypeCategory {
|
|||
TEXT = 'text'
|
||||
}
|
||||
|
||||
/**
|
||||
* Special file types for internal use (not MIME types)
|
||||
*/
|
||||
export enum SpecialFileType {
|
||||
MCP_PROMPT = 'mcp-prompt'
|
||||
}
|
||||
|
||||
// Specific file type enums for each category
|
||||
export enum FileTypeImage {
|
||||
JPEG = 'jpeg',
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ export { AttachmentType } from './attachment';
|
|||
|
||||
export { AgenticSectionType } from './agentic';
|
||||
|
||||
export { ChatMessageStatsView, MessageRole, MessageType } from './chat';
|
||||
export { ChatMessageStatsView, MessageRole, MessageType, ReasoningFormat } from './chat';
|
||||
|
||||
export {
|
||||
FileTypeCategory,
|
||||
|
|
@ -17,7 +17,8 @@ export {
|
|||
MimeTypeApplication,
|
||||
MimeTypeAudio,
|
||||
MimeTypeImage,
|
||||
MimeTypeText
|
||||
MimeTypeText,
|
||||
SpecialFileType
|
||||
} from './files';
|
||||
|
||||
export { MCPConnectionPhase, MCPLogLevel, MCPTransportType, HealthCheckStatus } from './mcp';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { activeProcessingState } from '$lib/stores/chat.svelte';
|
||||
import { config } from '$lib/stores/settings.svelte';
|
||||
import { STATS_UNITS } from '$lib/constants/processing-info';
|
||||
|
||||
export interface LiveProcessingStats {
|
||||
tokensProcessed: number;
|
||||
|
|
@ -163,7 +164,7 @@ export function useProcessingState(): UseProcessingStateReturn {
|
|||
}
|
||||
|
||||
if (stateToUse.tokensPerSecond && stateToUse.tokensPerSecond > 0) {
|
||||
details.push(`${stateToUse.tokensPerSecond.toFixed(1)} t/s`);
|
||||
details.push(`${stateToUse.tokensPerSecond.toFixed(1)} ${STATS_UNITS.TOKENS_PER_SECOND}`);
|
||||
}
|
||||
|
||||
if (stateToUse.speculative) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import type { Root as HastRoot } from 'hast';
|
||||
import { visit } from 'unist-util-visit';
|
||||
import type { DatabaseMessage, DatabaseMessageExtraImageFile } from '$lib/types/database';
|
||||
import { AttachmentType } from '$lib/enums';
|
||||
|
||||
/**
|
||||
* Rehype plugin to resolve attachment image sources.
|
||||
|
|
@ -19,7 +20,8 @@ export function rehypeResolveAttachmentImages(options: { message?: DatabaseMessa
|
|||
|
||||
// Find matching attachment
|
||||
const attachment = options.message?.extra?.find(
|
||||
(a): a is DatabaseMessageExtraImageFile => a.type === 'IMAGE' && a.name === src
|
||||
(a): a is DatabaseMessageExtraImageFile =>
|
||||
a.type === AttachmentType.IMAGE && a.name === src
|
||||
);
|
||||
|
||||
// Replace with base64 URL if found
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { getJsonHeaders } from '$lib/utils';
|
||||
import { AGENTIC_REGEX } from '$lib/constants/agentic';
|
||||
import { AttachmentType, MessageRole } from '$lib/enums';
|
||||
import { AttachmentType, MessageRole, ReasoningFormat } from '$lib/enums';
|
||||
import type { ApiChatMessageContentPart } from '$lib/types/api';
|
||||
import type { DatabaseMessageExtraMcpPrompt } from '$lib/types';
|
||||
|
||||
|
|
@ -169,7 +169,9 @@ export class ChatService {
|
|||
requestBody.model = options.model;
|
||||
}
|
||||
|
||||
requestBody.reasoning_format = disableReasoningParsing ? 'none' : 'auto';
|
||||
requestBody.reasoning_format = disableReasoningParsing
|
||||
? ReasoningFormat.NONE
|
||||
: ReasoningFormat.AUTO;
|
||||
|
||||
if (temperature !== undefined) requestBody.temperature = temperature;
|
||||
if (max_tokens !== undefined) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { AttachmentType, FileTypeCategory } from '$lib/enums';
|
||||
import { AttachmentType, FileTypeCategory, SpecialFileType } from '$lib/enums';
|
||||
import { getFileTypeCategory, getFileTypeCategoryByExtension, isImageFile } from '$lib/utils';
|
||||
|
||||
export interface AttachmentDisplayItemsOptions {
|
||||
|
|
@ -10,7 +10,7 @@ export interface AttachmentDisplayItemsOptions {
|
|||
* Check if an uploaded file is an MCP prompt
|
||||
*/
|
||||
function isMcpPromptUpload(file: ChatUploadedFile): boolean {
|
||||
return file.type === 'mcp-prompt' && !!file.mcpPrompt;
|
||||
return file.type === SpecialFileType.MCP_PROMPT && !!file.mcpPrompt;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { convertPDFToImage, convertPDFToText } from './pdf-processing';
|
||||
import { isSvgMimeType, svgBase64UrlToPngDataURL } from './svg-to-png';
|
||||
import { isWebpMimeType, webpBase64UrlToPngDataURL } from './webp-to-png';
|
||||
import { FileTypeCategory, AttachmentType } from '$lib/enums';
|
||||
import { FileTypeCategory, AttachmentType, SpecialFileType } from '$lib/enums';
|
||||
import { config, settingsStore } from '$lib/stores/settings.svelte';
|
||||
import { modelsStore } from '$lib/stores/models.svelte';
|
||||
import { getFileTypeCategory } from '$lib/utils';
|
||||
|
|
@ -38,7 +38,7 @@ export async function parseFilesToMessageExtras(
|
|||
const emptyFiles: string[] = [];
|
||||
|
||||
for (const file of files) {
|
||||
if (file.type === 'mcp-prompt' && file.mcpPrompt) {
|
||||
if (file.type === SpecialFileType.MCP_PROMPT && file.mcpPrompt) {
|
||||
extras.push({
|
||||
type: AttachmentType.MCP_PROMPT,
|
||||
name: file.name,
|
||||
|
|
|
|||
Loading…
Reference in New Issue