import React from "react"; import { Trans } from "react-i18next"; import { ChevronDown, ChevronRight } from "lucide-react"; import { useModelStore } from "#/stores/model-store"; import { I18nKey } from "#/i18n/declaration"; import InfoCircleIcon from "#/icons/info-circle.svg?react"; import type { ProfileInfo } from "#/api/profiles-service/profiles-service.api"; import { useFreeModels } from "#/hooks/query/use-free-models"; import { formatModelNameForDisplay } from "#/utils/format-model-name"; import { GenericEventMessage } from "./generic-event-message"; interface ProfileRowProps { profile: ProfileInfo; } function ProfileRow({ profile }: ProfileRowProps) { const [expanded, setExpanded] = React.useState(false); const freeModels = useFreeModels(); const displayModel = formatModelNameForDisplay(profile.model, freeModels); return (
{expanded && ( <>
{`model: ${displayModel ?? "—"}\n` + `base_url: ${profile.base_url ?? "—"}\n` + // eslint-disable-next-line i18next/no-literal-string -- diagnostic readout; field labels are intentionally untranslated `api_key: ${profile.api_key_set ? "set" : "not set"}`}
)}
); } export interface ModelMessagesProps { conversationId: string | null | undefined; /** * Render only entries anchored to this event id. Use `null` to render the * "no events at the time of /model" entries (top of the chat history). */ anchorEventId: string | null; } export function ModelMessages({ conversationId, anchorEventId, }: ModelMessagesProps) { const entriesById = useModelStore((s) => s.entriesByConversation); const allEntries = conversationId ? (entriesById[conversationId] ?? []) : []; const entries = allEntries.filter((e) => e.anchorEventId === anchorEventId); if (!conversationId || entries.length === 0) return null; return (
{entries.map((entry) => { if (entry.switchedTo) { return ( ), }} /> } details="" /> ); } const isEmpty = entry.profiles.length === 0; return ( {isEmpty ? ( ) : ( )} } details={ isEmpty ? ( ) : (
{entry.profiles.map((p) => ( ))}
) } initiallyExpanded={isEmpty} /> ); })}
); }