Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

1.1 KB
Raw Blame
/* Copyright 2026 Marimo. All rights reserved. */
import React from "react";
import { AiModelId, type QualifiedModelId } from "@/core/ai/ids/ids";
import { Banner } from "@/plugins/impl/common/error-banner";

interface IncorrectModelIdProps {
  value: string | null | undefined;
  includeSuggestion?: boolean;
}

export const IncorrectModelId: React.FC<IncorrectModelIdProps> = ({
  value,
  includeSuggestion = true,
}) => {
  if (!value) {
    return null;
  }

  // Only incorrect if missing a slash
  if (value.includes("/")) {
    return null;
  }

  // Try to "correct" by guessing provider
  const parsed = AiModelId.parse(value as QualifiedModelId);
  const suggestion = parsed.id;

  return (
    <Banner kind="danger" className="mt-1">
      <span>
        Model id should be in the form{" "}
        <code className="font-bold">provider/model</code>. {value} is missing a
        provider.
      </span>
      <br />
      {includeSuggestion && suggestion && (
        <span>
          Did you mean <code className="font-bold">{suggestion}</code>?
        </span>
      )}
    </Banner>
  );
};