Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python
1.7 KB
Raw Blame
import { useFormContext } from "react-hook-form";
import { LabelWrapper } from "@/components/label-wrapper";
import { Input } from "@/components/ui/input";

export interface OllamaSettingsFormData {
  endpoint: string;
}

export function OllamaSettingsForm({
  modelsError,
  isLoadingModels,
}: {
  modelsError?: Error | null;
  isLoadingModels?: boolean;
}) {
  const {
    register,
    formState: { errors },
  } = useFormContext<OllamaSettingsFormData>();

  const endpointError = modelsError?.message || errors.endpoint?.message;

  return (
    <div className="min-w-0 space-y-4">
      <div className="min-w-0 space-y-2">
        <LabelWrapper
          label="Ollama Base URL"
          helperText="Base URL of your Ollama server"
          required
          id="endpoint"
        >
          <Input
            {...register("endpoint", {
              required: "Ollama base URL is required",
            })}
            className={endpointError ? "border-destructive!" : ""}
            id="endpoint"
            type="text"
            placeholder="http://localhost:11434"
          />
        </LabelWrapper>
        {endpointError && (
          <p
            data-testid="provider-connection-error"
            className="text-sm text-destructive min-w-0 wrap-anywhere"
          >
            {endpointError}
          </p>
        )}
        {isLoadingModels && (
          <p className="text-sm text-muted-foreground">
            Validating connection...
          </p>
        )}
      </div>
      <p className="text-sm text-muted-foreground">
        Configure language and embedding models in the Settings page after
        saving your endpoint.
      </p>
    </div>
  );
}