# This contains the MediaPipe LLM Inference Task.
#
# This task takes text input and performs text generation
#

# TODO: See if we can migrate to the new js_test_* rules eventually
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("//mediapipe/framework/port:build_config.bzl", "ts_declaration", "ts_library")

package(default_visibility = ["//mediapipe/tasks:internal"])

licenses(["notice"])

ts_library(
    name = "llm_inference",
    srcs = [
        "llm_inference.ts",
    ],
    visibility = ["//visibility:public"],
    deps = [
        ":llm_inference_types",
        ":model_loading_utils",
        "//mediapipe/framework:calculator_jspb_proto",
        "//mediapipe/tasks/cc/core/proto:base_options_jspb_proto",
        "//mediapipe/tasks/web/core",
        "//mediapipe/tasks/web/core:task_runner",
        "//mediapipe/tasks/web/genai/llm_inference/proto:detokenizer_calculator_jspb_proto",
        "//mediapipe/tasks/web/genai/llm_inference/proto:llm_gpu_calculator_jspb_proto",
        "//mediapipe/tasks/web/genai/llm_inference/proto:llm_inference_graph_options_jspb_proto",
        "//mediapipe/tasks/web/genai/llm_inference/proto:llm_params_jspb_proto",
        "//mediapipe/tasks/web/genai/llm_inference/proto:sampler_params_jspb_proto",
        "//mediapipe/tasks/web/genai/llm_inference/proto:tokenizer_calculator_jspb_proto",
        "//mediapipe/tasks/web/genai/llm_inference/proto:transformer_params_jspb_proto",
        "//mediapipe/web/graph_runner:graph_runner_llm_inference_lib_ts",
        "//mediapipe/web/graph_runner:graph_runner_streaming_reader_ts",
        "//mediapipe/web/graph_runner:graph_runner_ts",
        "//mediapipe/web/graph_runner:graph_runner_wasm_file_reference_ts",
        "//mediapipe/web/graph_runner:graph_runner_webgpu_ts",
    ],
)

ts_declaration(
    name = "llm_inference_types",
    srcs = [
        "llm_inference_options.d.ts",
    ],
    visibility = ["//visibility:public"],
    deps = [
        "//mediapipe/tasks/web/core",
    ],
)

ts_library(
    name = "model_loading_utils",
    srcs = [
        "model_loading_utils.ts",
    ],
    visibility = ["//visibility:public"],
)
