fix: Context info fixes & improvements
This commit is contained in:
parent
7881cf00c9
commit
6d0c86f8b4
|
|
@ -59,7 +59,12 @@
|
||||||
<span class="font-medium">Prompt tokens:</span>
|
<span class="font-medium">Prompt tokens:</span>
|
||||||
{contextInfo.n_prompt_tokens.toLocaleString()}
|
{contextInfo.n_prompt_tokens.toLocaleString()}
|
||||||
</p>
|
</p>
|
||||||
<p><span class="font-medium">Context size:</span> {contextInfo.n_ctx.toLocaleString()}</p>
|
{#if contextInfo.n_ctx}
|
||||||
|
<p>
|
||||||
|
<span class="font-medium">Context size:</span>
|
||||||
|
{contextInfo.n_ctx.toLocaleString()}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -105,12 +105,21 @@
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
|
|
||||||
<!-- Context Size -->
|
<!-- Context Size -->
|
||||||
<Table.Row>
|
{#if serverProps?.default_generation_settings?.n_ctx}
|
||||||
<Table.Cell class="h-10 align-middle font-medium">Context Size</Table.Cell>
|
<Table.Row>
|
||||||
<Table.Cell
|
<Table.Cell class="h-10 align-middle font-medium">Context Size</Table.Cell>
|
||||||
>{formatNumber(serverProps.default_generation_settings.n_ctx)} tokens</Table.Cell
|
<Table.Cell
|
||||||
>
|
>{formatNumber(serverProps.default_generation_settings.n_ctx)} tokens</Table.Cell
|
||||||
</Table.Row>
|
>
|
||||||
|
</Table.Row>
|
||||||
|
{:else}
|
||||||
|
<Table.Row>
|
||||||
|
<Table.Cell class="h-10 align-middle font-medium text-red-500"
|
||||||
|
>Context Size</Table.Cell
|
||||||
|
>
|
||||||
|
<Table.Cell class="text-red-500">Not available</Table.Cell>
|
||||||
|
</Table.Row>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<!-- Training Context -->
|
<!-- Training Context -->
|
||||||
{#if modelMeta?.n_ctx_train}
|
{#if modelMeta?.n_ctx_train}
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export const DEFAULT_CONTEXT = 4096;
|
|
||||||
|
|
@ -197,7 +197,11 @@ export function useProcessingState(): UseProcessingStateReturn {
|
||||||
const details: string[] = [];
|
const details: string[] = [];
|
||||||
|
|
||||||
// Always show context info when we have valid data
|
// Always show context info when we have valid data
|
||||||
if (stateToUse.contextUsed >= 0 && stateToUse.contextTotal > 0) {
|
if (
|
||||||
|
typeof stateToUse.contextTotal === 'number' &&
|
||||||
|
stateToUse.contextUsed >= 0 &&
|
||||||
|
stateToUse.contextTotal > 0
|
||||||
|
) {
|
||||||
const contextPercent = Math.round((stateToUse.contextUsed / stateToUse.contextTotal) * 100);
|
const contextPercent = Math.round((stateToUse.contextUsed / stateToUse.contextTotal) * 100);
|
||||||
|
|
||||||
details.push(
|
details.push(
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ import {
|
||||||
findLeafNode,
|
findLeafNode,
|
||||||
isAbortError
|
isAbortError
|
||||||
} from '$lib/utils';
|
} from '$lib/utils';
|
||||||
import { DEFAULT_CONTEXT } from '$lib/constants/default-context';
|
|
||||||
import { SYSTEM_MESSAGE_PLACEHOLDER } from '$lib/constants/ui';
|
import { SYSTEM_MESSAGE_PLACEHOLDER } from '$lib/constants/ui';
|
||||||
import { REASONING_TAGS } from '$lib/constants/agentic';
|
import { REASONING_TAGS } from '$lib/constants/agentic';
|
||||||
import {
|
import {
|
||||||
|
|
@ -1252,17 +1251,22 @@ class ChatStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getContextTotal(): number {
|
private getContextTotal(): number | null {
|
||||||
const activeConvId = this.activeConversationId;
|
const activeConvId = this.activeConversationId;
|
||||||
const activeState = activeConvId ? this.getProcessingState(activeConvId) : null;
|
const activeState = activeConvId ? this.getProcessingState(activeConvId) : null;
|
||||||
if (activeState && activeState.contextTotal > 0) return activeState.contextTotal;
|
|
||||||
|
if (activeState && typeof activeState.contextTotal === 'number' && activeState.contextTotal > 0)
|
||||||
|
return activeState.contextTotal;
|
||||||
|
|
||||||
if (isRouterMode()) {
|
if (isRouterMode()) {
|
||||||
const modelContextSize = selectedModelContextSize();
|
const modelContextSize = selectedModelContextSize();
|
||||||
if (modelContextSize && modelContextSize > 0) return modelContextSize;
|
if (typeof modelContextSize === 'number' && modelContextSize > 0) return modelContextSize;
|
||||||
|
} else {
|
||||||
|
const propsContextSize = contextSize();
|
||||||
|
if (typeof propsContextSize === 'number' && propsContextSize > 0) return propsContextSize;
|
||||||
}
|
}
|
||||||
const propsContextSize = contextSize();
|
|
||||||
if (propsContextSize && propsContextSize > 0) return propsContextSize;
|
return null;
|
||||||
return DEFAULT_CONTEXT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateProcessingStateFromTimings(
|
updateProcessingStateFromTimings(
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,9 @@ class ModelsStore {
|
||||||
*/
|
*/
|
||||||
getModelContextSize(modelId: string): number | null {
|
getModelContextSize(modelId: string): number | null {
|
||||||
const props = this.getModelProps(modelId);
|
const props = this.getModelProps(modelId);
|
||||||
return props?.default_generation_settings?.n_ctx ?? null;
|
const nCtx = props?.default_generation_settings?.n_ctx;
|
||||||
|
|
||||||
|
return typeof nCtx === 'number' ? nCtx : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,9 @@ class ServerStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
get contextSize(): number | null {
|
get contextSize(): number | null {
|
||||||
return this.props?.default_generation_settings?.n_ctx ?? null;
|
const nCtx = this.props?.default_generation_settings?.n_ctx;
|
||||||
|
|
||||||
|
return typeof nCtx === 'number' ? nCtx : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get webuiSettings(): Record<string, string | number | boolean> | undefined {
|
get webuiSettings(): Record<string, string | number | boolean> | undefined {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue