2025-07-15 23:01:39 +03:00
|
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { describePromptVariable } from '../../labels';
|
|
|
|
|
import { PromptVariableType } from '../../models/prompting';
|
|
|
|
|
import { extractPromptVariables } from '../../models/prompting-api';
|
|
|
|
|
import { useAvailableVariables } from '../../stores/use-available-variables';
|
|
|
|
|
|
|
|
|
|
interface TabPromptVariablesProps {
|
2025-07-21 11:06:02 +03:00
|
|
|
|
template: string;
|
2025-07-15 23:01:39 +03:00
|
|
|
|
}
|
|
|
|
|
|
2025-07-21 11:06:02 +03:00
|
|
|
|
export function TabPromptVariables({ template }: TabPromptVariablesProps) {
|
|
|
|
|
const variables = extractPromptVariables(template);
|
2025-07-15 23:01:39 +03:00
|
|
|
|
const availableTypes = useAvailableVariables();
|
|
|
|
|
return (
|
|
|
|
|
<ul>
|
|
|
|
|
{variables.length === 0 && <li>Нет переменных</li>}
|
|
|
|
|
{variables.map(variable => {
|
|
|
|
|
const type = Object.values(PromptVariableType).find(t => t === variable);
|
|
|
|
|
const isAvailable = !!type && availableTypes.includes(type);
|
|
|
|
|
return (
|
|
|
|
|
<li key={variable} className={isAvailable ? 'text-green-700 font-bold' : 'text-gray-500'}>
|
|
|
|
|
{variable} — {type ? describePromptVariable(type) : 'Неизвестная переменная'}
|
|
|
|
|
{isAvailable ? ' (доступна)' : ' (нет в контексте)'}
|
|
|
|
|
</li>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</ul>
|
|
|
|
|
);
|
|
|
|
|
}
|