text stringlengths 96 319k | id stringlengths 14 178 | metadata dict |
|---|---|---|
# coding=utf-8
# Copyright 2024 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | transformers/tests/models/siglip/test_tokenization_siglip.py/0 | {
"file_path": "transformers/tests/models/siglip/test_tokenization_siglip.py",
"repo_id": "transformers",
"token_count": 9594
} |
# coding=utf-8
# Copyright 2021 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless r... | transformers/tests/models/splinter/test_modeling_splinter.py/0 | {
"file_path": "transformers/tests/models/splinter/test_modeling_splinter.py",
"repo_id": "transformers",
"token_count": 9653
} |
# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless r... | transformers/tests/models/swiftformer/test_modeling_swiftformer.py/0 | {
"file_path": "transformers/tests/models/swiftformer/test_modeling_swiftformer.py",
"repo_id": "transformers",
"token_count": 4745
} |
# coding=utf-8
# Copyright 2021 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless r... | transformers/tests/models/unispeech/test_modeling_unispeech.py/0 | {
"file_path": "transformers/tests/models/unispeech/test_modeling_unispeech.py",
"repo_id": "transformers",
"token_count": 10589
} |
# coding=utf-8
# Copyright 2022 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless r... | transformers/tests/models/vilt/test_modeling_vilt.py/0 | {
"file_path": "transformers/tests/models/vilt/test_modeling_vilt.py",
"repo_id": "transformers",
"token_count": 12181
} |
# coding=utf-8
# Copyright 2021 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | transformers/tests/models/vit/test_image_processing_vit.py/0 | {
"file_path": "transformers/tests/models/vit/test_image_processing_vit.py",
"repo_id": "transformers",
"token_count": 1680
} |
# coding=utf-8
# Copyright 2024 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless r... | transformers/tests/models/vitpose/test_modeling_vitpose.py/0 | {
"file_path": "transformers/tests/models/vitpose/test_modeling_vitpose.py",
"repo_id": "transformers",
"token_count": 5394
} |
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | transformers/tests/models/whisper/test_processor_whisper.py/0 | {
"file_path": "transformers/tests/models/whisper/test_processor_whisper.py",
"repo_id": "transformers",
"token_count": 2869
} |
# coding=utf-8
# Copyright 2020 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requir... | transformers/tests/models/xlm_roberta/test_modeling_xlm_roberta.py/0 | {
"file_path": "transformers/tests/models/xlm_roberta/test_modeling_xlm_roberta.py",
"repo_id": "transformers",
"token_count": 1771
} |
# coding=utf-8
# Copyright 2024 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless r... | transformers/tests/models/zamba/test_modeling_zamba.py/0 | {
"file_path": "transformers/tests/models/zamba/test_modeling_zamba.py",
"repo_id": "transformers",
"token_count": 12980
} |
# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | transformers/tests/pipelines/test_pipelines_text_to_audio.py/0 | {
"file_path": "transformers/tests/pipelines/test_pipelines_text_to_audio.py",
"repo_id": "transformers",
"token_count": 4480
} |
# coding=utf-8
# Copyright 2024 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requir... | transformers/tests/quantization/higgs/test_higgs.py/0 | {
"file_path": "transformers/tests/quantization/higgs/test_higgs.py",
"repo_id": "transformers",
"token_count": 3092
} |
# we define a fixture function below and it will be "used" by
# referencing its name from tests
import os
import pytest
from attr import dataclass
os.environ["AWS_DEFAULT_REGION"] = "us-east-1" # defaults region
@dataclass
class SageMakerTestEnvironment:
framework: str
role = "arn:aws:iam::558105141721:r... | transformers/tests/sagemaker/conftest.py/0 | {
"file_path": "transformers/tests/sagemaker/conftest.py",
"repo_id": "transformers",
"token_count": 1035
} |
# Copyright 2020 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | transformers/tests/test_modeling_flax_common.py/0 | {
"file_path": "transformers/tests/test_modeling_flax_common.py",
"repo_id": "transformers",
"token_count": 25289
} |
# coding=utf-8
# Copyright 2020 the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | transformers/tests/trainer/test_trainer_seq2seq.py/0 | {
"file_path": "transformers/tests/trainer/test_trainer_seq2seq.py",
"repo_id": "transformers",
"token_count": 3785
} |
# coding=utf-8
# Copyright 2019 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | transformers/tests/utils/test_configuration_utils.py/0 | {
"file_path": "transformers/tests/utils/test_configuration_utils.py",
"repo_id": "transformers",
"token_count": 5685
} |
# Copyright 2020 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | transformers/tests/utils/test_modeling_flax_utils.py/0 | {
"file_path": "transformers/tests/utils/test_modeling_flax_utils.py",
"repo_id": "transformers",
"token_count": 7105
} |
# coding=utf-8
# Copyright 2020 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | transformers/utils/check_copies.py/0 | {
"file_path": "transformers/utils/check_copies.py",
"repo_id": "transformers",
"token_count": 20623
} |
"""
Script which deprecates a list of given models
Example usage:
python utils/deprecate_models.py --models bert distilbert
"""
import argparse
import os
from collections import defaultdict
from pathlib import Path
from typing import Optional, Tuple
import requests
from custom_init_isort import sort_imports_in_all_i... | transformers/utils/deprecate_models.py/0 | {
"file_path": "transformers/utils/deprecate_models.py",
"repo_id": "transformers",
"token_count": 5241
} |
# coding=utf-8
# Copyright 2024 The HuggingFace Inc. team. All rights reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | transformers/utils/patch_helper.py/0 | {
"file_path": "transformers/utils/patch_helper.py",
"repo_id": "transformers",
"token_count": 1505
} |
import torch
from transformers import PreTrainedModel
from .custom_configuration import CustomConfig, NoSuperInitConfig
class CustomModel(PreTrainedModel):
config_class = CustomConfig
def __init__(self, config):
super().__init__(config)
self.linear = torch.nn.Linear(config.hidden_size, conf... | transformers/utils/test_module/custom_modeling.py/0 | {
"file_path": "transformers/utils/test_module/custom_modeling.py",
"repo_id": "transformers",
"token_count": 289
} |
# Aligning Text-to-Image Diffusion Models with Reward Backpropagation
[](https://huggingface.co/models?other=alignprop,trl)
## The why
If your reward function is differentiable, directly backpropagating gradients from the reward models to the diffusion model... | trl/docs/source/alignprop_trainer.md/0 | {
"file_path": "trl/docs/source/alignprop_trainer.md",
"repo_id": "trl",
"token_count": 1570
} |
# PPO Trainer
[](https://huggingface.co/models?other=ppo,trl)
TRL supports training LLMs with [Proximal Policy Optimization (PPO)](https://huggingface.co/papers/1707.06347).
References:
- [Fine-Tuning Language Models from Human Preferences](https://github.com/open... | trl/docs/source/ppo_trainer.md/0 | {
"file_path": "trl/docs/source/ppo_trainer.md",
"repo_id": "trl",
"token_count": 8409
} |
# Copyright 2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | trl/examples/datasets/ultrafeedback.py/0 | {
"file_path": "trl/examples/datasets/ultrafeedback.py",
"repo_id": "trl",
"token_count": 2242
} |
# Copyright 2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | trl/examples/research_projects/tools/python_interpreter.py/0 | {
"file_path": "trl/examples/research_projects/tools/python_interpreter.py",
"repo_id": "trl",
"token_count": 2631
} |
# Copyright 2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | trl/scripts/generate_tiny_models.py/0 | {
"file_path": "trl/scripts/generate_tiny_models.py",
"repo_id": "trl",
"token_count": 3444
} |
# Copyright 2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | trl/tests/test_cli_utils.py/0 | {
"file_path": "trl/tests/test_cli_utils.py",
"repo_id": "trl",
"token_count": 2734
} |
# Copyright 2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | trl/tests/test_modeling_value_head.py/0 | {
"file_path": "trl/tests/test_modeling_value_head.py",
"repo_id": "trl",
"token_count": 10199
} |
# Copyright 2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | trl/trl/__init__.py/0 | {
"file_path": "trl/trl/__init__.py",
"repo_id": "trl",
"token_count": 3079
} |
# Copyright 2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | trl/trl/models/sd_utils.py/0 | {
"file_path": "trl/trl/models/sd_utils.py",
"repo_id": "trl",
"token_count": 2508
} |
# Copyright 2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | trl/trl/trainer/callbacks.py/0 | {
"file_path": "trl/trl/trainer/callbacks.py",
"repo_id": "trl",
"token_count": 10326
} |
# Copyright 2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | trl/trl/trainer/nash_md_config.py/0 | {
"file_path": "trl/trl/trainer/nash_md_config.py",
"repo_id": "trl",
"token_count": 621
} |
# Copyright 2025 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | trl/trl/trainer/utils.py/0 | {
"file_path": "trl/trl/trainer/utils.py",
"repo_id": "trl",
"token_count": 31293
} |
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | accelerate/benchmarks/big_model_inference/big_model_inference.py/0 | {
"file_path": "accelerate/benchmarks/big_model_inference/big_model_inference.py",
"repo_id": "accelerate",
"token_count": 2241
} |
# Builds GPU docker image of PyTorch specifically
# Uses multi-staged approach to reduce size
# Stage 1
# Use base conda image to reduce time
FROM continuumio/miniconda3:latest AS compile-image
# Specify py version
# Note: DeepSpeed beyond v0.12.6 requires py 3.10
ENV PYTHON_VERSION=3.10
# Install apt libs
RUN apt-get ... | accelerate/docker/accelerate-gpu-deepspeed/Dockerfile/0 | {
"file_path": "accelerate/docker/accelerate-gpu-deepspeed/Dockerfile",
"repo_id": "accelerate",
"token_count": 560
} |
<!--Copyright 2022 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed... | accelerate/docs/source/concept_guides/gradient_synchronization.md/0 | {
"file_path": "accelerate/docs/source/concept_guides/gradient_synchronization.md",
"repo_id": "accelerate",
"token_count": 2834
} |
<!--Copyright 2021 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed... | accelerate/docs/source/package_reference/kwargs.md/0 | {
"file_path": "accelerate/docs/source/package_reference/kwargs.md",
"repo_id": "accelerate",
"token_count": 384
} |
<!--Copyright 2022 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed... | accelerate/docs/source/usage_guides/fsdp.md/0 | {
"file_path": "accelerate/docs/source/usage_guides/fsdp.md",
"repo_id": "accelerate",
"token_count": 3344
} |
# Copyright 2024 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | accelerate/examples/inference/distributed/distributed_image_generation.py/0 | {
"file_path": "accelerate/examples/inference/distributed/distributed_image_generation.py",
"repo_id": "accelerate",
"token_count": 1495
} |
#!/bin/bash
#SBATCH --job-name=multigpu
#SBATCH -D .
#SBATCH --output=O-%x.%j
#SBATCH --error=E-%x.%j
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1 # number of MP tasks
#SBATCH --gres=gpu:4 # number of GPUs per node
#SBATCH --cpus-per-task=160 # number of cores per tasks
#SBATCH --time=0... | accelerate/examples/slurm/submit_multigpu.sh/0 | {
"file_path": "accelerate/examples/slurm/submit_multigpu.sh",
"repo_id": "accelerate",
"token_count": 355
} |
[tool.ruff]
line-length = 119
target-version = "py38"
[tool.ruff.lint]
preview = true
extend-select = [
"B009", # static getattr
"B010", # static setattr
"CPY", # Copyright
"E", # PEP8 errors
"F", # PEP8 formatting
"I", # Import sorting
"TID251", # Banned API
"UP", # Pyupgrade
"W", ... | accelerate/pyproject.toml/0 | {
"file_path": "accelerate/pyproject.toml",
"repo_id": "accelerate",
"token_count": 416
} |
#!/usr/bin/env python
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unles... | accelerate/src/accelerate/commands/env.py/0 | {
"file_path": "accelerate/src/accelerate/commands/env.py",
"repo_id": "accelerate",
"token_count": 1464
} |
# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | accelerate/src/accelerate/launchers.py/0 | {
"file_path": "accelerate/src/accelerate/launchers.py",
"repo_id": "accelerate",
"token_count": 6039
} |
# Copyright 2024 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appl... | accelerate/src/accelerate/test_utils/scripts/external_deps/test_pippy.py/0 | {
"file_path": "accelerate/src/accelerate/test_utils/scripts/external_deps/test_pippy.py",
"repo_id": "accelerate",
"token_count": 1697
} |
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | accelerate/src/accelerate/utils/dataclasses.py/0 | {
"file_path": "accelerate/src/accelerate/utils/dataclasses.py",
"repo_id": "accelerate",
"token_count": 50957
} |
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | accelerate/src/accelerate/utils/transformer_engine.py/0 | {
"file_path": "accelerate/src/accelerate/utils/transformer_engine.py",
"repo_id": "accelerate",
"token_count": 2373
} |
compute_environment: LOCAL_MACHINE
debug: false
distributed_type: MULTI_GPU
downcast_bf16: 'no'
enable_cpu_affinity: false
fp8_config:
amax_compute_algorithm: max
amax_history_length: 1024
backend: TE
fp8_format: E4M3
interval: 1
margin: 0
override_linear_precision: false
use_autocast_during_eval: false... | accelerate/tests/test_configs/0_34_0_fp8.yaml/0 | {
"file_path": "accelerate/tests/test_configs/0_34_0_fp8.yaml",
"repo_id": "accelerate",
"token_count": 216
} |
# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | accelerate/tests/test_offload.py/0 | {
"file_path": "accelerate/tests/test_offload.py",
"repo_id": "accelerate",
"token_count": 1981
} |
use crate::benchmarks::{BenchDevice, BenchDeviceHandler};
use candle_core::{DType, Device, Tensor};
use criterion::{black_box, criterion_group, Criterion, Throughput};
use std::time::Instant;
fn run(a: &Tensor) {
a.affine(12.34, 56.78).unwrap();
}
fn run_affine_benchmark(c: &mut Criterion, device: &Device, dtype:... | candle/candle-core/benches/benchmarks/affine.rs/0 | {
"file_path": "candle/candle-core/benches/benchmarks/affine.rs",
"repo_id": "candle",
"token_count": 590
} |
//! 1D and 2D Convolutions
//!
use crate::{op::BackpropOp, op::Op, Error, Result, Tensor};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParamsConv1D {
pub(crate) b_size: usize,
// Maybe we should have a version without l_in as this bit depends on the input and not only on
// the weights.
pub(crate... | candle/candle-core/src/conv.rs/0 | {
"file_path": "candle/candle-core/src/conv.rs",
"repo_id": "candle",
"token_count": 5821
} |
use crate::backend::BackendDevice;
use crate::cpu_backend::CpuDevice;
use crate::{CpuStorage, DType, Result, Shape, Storage, WithDType};
/// A `DeviceLocation` represents a physical device whereas multiple `Device`
/// can live on the same location (typically for cuda devices).
#[derive(Debug, Copy, Clone, PartialEq, ... | candle/candle-core/src/device.rs/0 | {
"file_path": "candle/candle-core/src/device.rs",
"repo_id": "candle",
"token_count": 6435
} |
use super::{GgmlDType, QStorage};
use crate::quantized::k_quants::GgmlType;
use crate::{backend::BackendDevice, cuda_backend::WrapErr};
use crate::{CudaDevice, CudaStorage, Result};
use half::f16;
use cudarc::driver::{CudaSlice, CudaView, DeviceSlice};
#[derive(Clone, Debug)]
struct PaddedCudaSlice {
inner: CudaS... | candle/candle-core/src/quantized/cuda.rs/0 | {
"file_path": "candle/candle-core/src/quantized/cuda.rs",
"repo_id": "candle",
"token_count": 14789
} |
//! StreamTensror useful for streaming ops.
//!
use crate::{Result, Shape, Tensor};
pub trait Dim: crate::shape::Dim + Copy {}
impl<T: crate::shape::Dim + Copy> Dim for T {}
/// A stream tensor is used in streaming module. It can either contain an actual tensor or be
/// empty.
#[derive(Clone)]
pub struct StreamTenso... | candle/candle-core/src/streaming.rs/0 | {
"file_path": "candle/candle-core/src/streaming.rs",
"repo_id": "candle",
"token_count": 3130
} |
use candle_core::{test_device, test_utils, Device, IndexOp, Result, Tensor};
// https://github.com/huggingface/candle/issues/364
fn avg_pool2d(dev: &Device) -> Result<()> {
let data: Vec<f32> = vec![
1., 1., 1., 1., 0., 0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
];
let t = Tensor::from_vec(data, (... | candle/candle-core/tests/pool_tests.rs/0 | {
"file_path": "candle/candle-core/tests/pool_tests.rs",
"repo_id": "candle",
"token_count": 2112
} |
//! Helper functions for the tinystories dataset. This uses the pre-tokenized version as generated
//! by the tools from https://github.com/karpathy/llama2.c
use candle::{Device, Result, Tensor};
pub struct Dataset {
valid_tokens: Vec<memmap2::Mmap>,
train_tokens: Vec<memmap2::Mmap>,
}
fn mmap_file(p: &std::p... | candle/candle-datasets/src/nlp/tinystories.rs/0 | {
"file_path": "candle/candle-datasets/src/nlp/tinystories.rs",
"repo_id": "candle",
"token_count": 2092
} |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use anyhow::Error as E;
use clap::Parser;
use candle::{DType, Device, Result, Tensor};
use candle_examples::token_output_stream::TokenOutputStream;
use candle_nn::VarBuilder;
use candle_transformers::model... | candle/candle-examples/examples/blip/main.rs/0 | {
"file_path": "candle/candle-examples/examples/blip/main.rs",
"repo_id": "candle",
"token_count": 2436
} |
pub enum SeparatorStyle {
Two,
Mpt,
}
pub struct Conversation {
pub system: String,
pub roles: Vec<String>,
pub messages: Vec<(String, Option<String>)>,
pub offset: i32,
pub sep_style: SeparatorStyle,
pub sep: String,
pub sep2: Option<String>,
pub version: String,
}
impl Convers... | candle/candle-examples/examples/llava/conversation.rs/0 | {
"file_path": "candle/candle-examples/examples/llava/conversation.rs",
"repo_id": "candle",
"token_count": 1910
} |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use anyhow::Result;
use candle::{DType, IndexOp, Tensor};
use candle_nn::VarBuilder;
use candle_transformers::models::mimi::{Config, Model};
use clap::{Parser, ValueEnum};
use hf_hub::api::sync::Api;
mod a... | candle/candle-examples/examples/mimi/main.rs/0 | {
"file_path": "candle/candle-examples/examples/mimi/main.rs",
"repo_id": "candle",
"token_count": 3353
} |
#![allow(dead_code)]
// https://huggingface.co/facebook/musicgen-small/tree/main
// https://github.com/huggingface/transformers/blob/cd4584e3c809bb9e1392ccd3fe38b40daba5519a/src/transformers/models/musicgen/modeling_musicgen.py
// TODO: Add an offline mode.
// TODO: Add a KV cache.
#[cfg(feature = "mkl")]
extern crate... | candle/candle-examples/examples/musicgen/main.rs/0 | {
"file_path": "candle/candle-examples/examples/musicgen/main.rs",
"repo_id": "candle",
"token_count": 1151
} |
use std::collections::VecDeque;
use candle::{DType, Device, Error, Module, Result, Tensor, Var};
use candle_nn::{
func, linear, sequential::seq, Activation, AdamW, Optimizer, ParamsAdamW, Sequential,
VarBuilder, VarMap,
};
use rand::{distributions::Uniform, thread_rng, Rng};
use super::gym_env::GymEnv;
pub s... | candle/candle-examples/examples/reinforcement-learning/ddpg.rs/0 | {
"file_path": "candle/candle-examples/examples/reinforcement-learning/ddpg.rs",
"repo_id": "candle",
"token_count": 8541
} |
[
{
"index": 1,
"color": "#787878",
"label": "wall"
},
{
"index": 2,
"color": "#B47878",
"label": "building;edifice"
},
{
"index": 3,
"color": "#06E6E6",
"label": "sky"
},
{
"index": 4,
"color": "#503232",
"label": "floor;flooring"
},
{
"index": 5,
... | candle/candle-examples/examples/segformer/assets/labels.json/0 | {
"file_path": "candle/candle-examples/examples/segformer/assets/labels.json",
"repo_id": "candle",
"token_count": 6397
} |
mod clip;
mod sampling;
mod vae;
use candle::{DType, IndexOp, Tensor};
use candle_transformers::models::mmdit::model::{Config as MMDiTConfig, MMDiT};
use crate::clip::StableDiffusion3TripleClipWithTokenizer;
use crate::vae::{build_sd3_vae_autoencoder, sd3_vae_vb_rename};
use anyhow::{Ok, Result};
use clap::Parser;
... | candle/candle-examples/examples/stable-diffusion-3/main.rs/0 | {
"file_path": "candle/candle-examples/examples/stable-diffusion-3/main.rs",
"repo_id": "candle",
"token_count": 4715
} |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use anyhow::Error as E;
use clap::{Parser, ValueEnum};
use candle::{DType, Tensor};
use candle_examples::token_output_stream::TokenOutputStream;
use candle_nn::VarBuilder;
use candle_transformers::models::... | candle/candle-examples/examples/trocr/main.rs/0 | {
"file_path": "candle/candle-examples/examples/trocr/main.rs",
"repo_id": "candle",
"token_count": 2167
} |
#include "kernels.h"
#include "kernel_helpers.h"
#include "flash_fwd_launch_template.h"
void run_mha_fwd(Flash_fwd_params ¶ms, cudaStream_t stream) {
FP16_SWITCH(!params.is_bf16, [&] {
HEADDIM_SWITCH(params.d, [&] {
BOOL_SWITCH(params.is_causal, Is_causal, [&] {
run_mha_fwd_<elem_ty... | candle/candle-flash-attn/kernels/flash_api.cu/0 | {
"file_path": "candle/candle-flash-attn/kernels/flash_api.cu",
"repo_id": "candle",
"token_count": 1818
} |
use anyhow::Result;
use candle::{DType, Device, IndexOp, Tensor, D};
fn to_vec3_round(t: Tensor, digits: i32) -> Result<Vec<Vec<Vec<f32>>>> {
let b = 10f32.powi(digits);
let t = t.to_vec3::<f32>()?;
let t = t
.iter()
.map(|t| {
t.iter()
.map(|t| t.iter().map(|t| ... | candle/candle-flash-attn/tests/flash_attn_tests.rs/0 | {
"file_path": "candle/candle-flash-attn/tests/flash_attn_tests.rs",
"repo_id": "candle",
"token_count": 3779
} |
// Adapted from https://github.com/ggerganov/llama.cpp/blob/master/ggml-cuda/argsort.cu
#define SORT_ORDER_ASC 1
#define SORT_ORDER_DESC 0
#include "cuda_utils.cuh"
#include<stdint.h>
template<typename T>
static inline __device__ void ggml_cuda_swap(T & a, T & b) {
T tmp = a;
a = b;
b = tmp;
}
template<in... | candle/candle-kernels/src/sort.cu/0 | {
"file_path": "candle/candle-kernels/src/sort.cu",
"repo_id": "candle",
"token_count": 1469
} |
// Imported from https://github.com/ggerganov/llama.cpp/blob/master/ggml-metal.metal
#include <metal_stdlib>
using namespace metal;
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define SWAP(x, y) { auto tmp = (x); (x) = (y); (y) = tmp; }
#define QK4_0 32
#define QR4_0 2
typedef... | candle/candle-metal-kernels/src/quantized.metal/0 | {
"file_path": "candle/candle-metal-kernels/src/quantized.metal",
"repo_id": "candle",
"token_count": 97299
} |
//! Cache Implementations
//!
use candle::{Device, Result, Tensor};
#[derive(Debug, Clone)]
pub struct Cache {
// all_data is an option on a Tensor, this makes it possible to only create the actual tensor
// on the first call where the batch size is easily known.
// Also this makes it safe to clone a KvCac... | candle/candle-nn/src/kv_cache.rs/0 | {
"file_path": "candle/candle-nn/src/kv_cache.rs",
"repo_id": "candle",
"token_count": 5654
} |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use candle::test_utils::to_vec0_round;
use candle::{Device, Result, Tensor};
/* Equivalent python code:
import torch
import torch.nn.functional as F
input = torch.tensor([
[ 1.1050, 0.3013, -1.5394, -... | candle/candle-nn/tests/loss.rs/0 | {
"file_path": "candle/candle-nn/tests/loss.rs",
"repo_id": "candle",
"token_count": 1344
} |
from .module import Module
from typing import Optional, Tuple, Any
from candle import Tensor
import candle
class Embedding(Module):
"""A simple lookup table that stores embeddings of a fixed dictionary and size.
This module is often used to store word embeddings and retrieve them using indices.
The input... | candle/candle-pyo3/py_src/candle/nn/sparse.py/0 | {
"file_path": "candle/candle-pyo3/py_src/candle/nn/sparse.py",
"repo_id": "candle",
"token_count": 590
} |
//! Implementation of BLIP text encoder/decoder.
//!
//! - 📝 [Paper](https://arxiv.org/abs/2201.12086). BLIP: Bootstrapping Language-Image Pre-training for Unified Vision-Language Understanding and Generation"
//!
//! - ⚡ [Interactive Wasm Example](https://huggingface.co/spaces/radames/Candle-BLIP-Image-Captioning)
//... | candle/candle-transformers/src/models/blip_text.rs/0 | {
"file_path": "candle/candle-transformers/src/models/blip_text.rs",
"repo_id": "candle",
"token_count": 7345
} |
//! Implementation of the DINOv2 revision (4 regularization)
//!
//! The DINOv2-reg4 model is a variant of DINOv2 that adds 4 regularization tokens to the
//! original architecture. This implementation is specifically trained for plant species
//! classification on the PlantCLEF2024 dataset with 7,806 classes.
//!
//! ... | candle/candle-transformers/src/models/dinov2reg4.rs/0 | {
"file_path": "candle/candle-transformers/src/models/dinov2reg4.rs",
"repo_id": "candle",
"token_count": 4809
} |
//! Granite is a Long Context Transformer Language Model.
//!
//! A high performance transformer model optimized for efficient processing
//! of very long context sequences
//!
//! Based on implementation from [Nod.ai](https://github.com/nod-ai/granite)
use super::with_tracing::{linear_no_bias as linear, Linear, RmsNo... | candle/candle-transformers/src/models/granite.rs/0 | {
"file_path": "candle/candle-transformers/src/models/granite.rs",
"repo_id": "candle",
"token_count": 8417
} |
// Copyright (c) Kyutai, all rights reserved.
// This source code is licensed under the license found in the
// LICENSE file in the root directory of this source tree.
use candle::{IndexOp, Layout, Result, Shape, Tensor, D};
use candle_nn::{linear, Linear, VarBuilder};
struct CodebookEncode;
impl candle::CustomOp2 f... | candle/candle-transformers/src/models/mimi/quantization.rs/0 | {
"file_path": "candle/candle-transformers/src/models/mimi/quantization.rs",
"repo_id": "candle",
"token_count": 6873
} |
//! MoonDream Model vision-to-text
//!
//!
//! Moondream is a computer-vision model that can answer real-world questions about images.
//! It's lightweight with only 1.6B parameters, enabling it to run on mobile phones and edge devices.
//! [MoonDream Original Implementation](https://github.com/vikhyat/moondream)
//!
/... | candle/candle-transformers/src/models/moondream.rs/0 | {
"file_path": "candle/candle-transformers/src/models/moondream.rs",
"repo_id": "candle",
"token_count": 4946
} |
//! BLIP model implementation with quantization support.
//!
//! BLIP is a vision-language model for image understanding and generation tasks.
//! This implementation provides quantization for reduced memory and compute.
//!
//! Key characteristics:
//! - Vision encoder using ViT architecture
//! - Text decoder using B... | candle/candle-transformers/src/models/quantized_blip.rs/0 | {
"file_path": "candle/candle-transformers/src/models/quantized_blip.rs",
"repo_id": "candle",
"token_count": 4186
} |
//! T5 model implementation with quantization support.
//!
//! T5 is an encoder-decoder model pre-trained on a multi-task mixture of supervised
//! and unsupervised tasks. This implementation provides quantization for reduced
//! memory and compute requirements.
//!
//! Key characteristics:
//! - Encoder-decoder archit... | candle/candle-transformers/src/models/quantized_t5.rs/0 | {
"file_path": "candle/candle-transformers/src/models/quantized_t5.rs",
"repo_id": "candle",
"token_count": 14169
} |
//! Siglip model implementation.
//!
//! Siglip architecture combining vision and language for zero-shot tasks.
//!
//! References:
//! - 🤗 [Model Card](https://huggingface.co/google/siglip-base-patch16-224)
//!
use crate::models::clip::div_l2_norm;
use candle::{IndexOp, Module, Result, Tensor, D};
use candle_nn::{la... | candle/candle-transformers/src/models/siglip.rs/0 | {
"file_path": "candle/candle-transformers/src/models/siglip.rs",
"repo_id": "candle",
"token_count": 10577
} |
//! StarCoder model implementation with quantization support.
//!
//! StarCoder is a large language model optimized for code generation.
//! This implementation provides quantization for reduced memory and compute.
//!
//! Key characteristics:
//! - Causal self-attention mechanism
//! - Multi-query attention (MQA)
//! ... | candle/candle-transformers/src/models/starcoder2.rs/0 | {
"file_path": "candle/candle-transformers/src/models/starcoder2.rs",
"repo_id": "candle",
"token_count": 6059
} |
use super::common::LayerNormNoWeights;
use candle::{Module, Result, Tensor};
use candle_nn::VarBuilder;
#[derive(Debug)]
pub struct MixingResidualBlock {
norm1: LayerNormNoWeights,
depthwise_conv: candle_nn::Conv2d,
norm2: LayerNormNoWeights,
channelwise_lin1: candle_nn::Linear,
channelwise_lin2: c... | candle/candle-transformers/src/models/wuerstchen/paella_vq.rs/0 | {
"file_path": "candle/candle-transformers/src/models/wuerstchen/paella_vq.rs",
"repo_id": "candle",
"token_count": 4078
} |
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<title>Candle Bert</title>
</head>
<body></body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
@import u... | candle/candle-wasm-examples/bert/lib-example.html/0 | {
"file_path": "candle/candle-wasm-examples/bert/lib-example.html",
"repo_id": "candle",
"token_count": 6066
} |
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<title>Candle Llama.c Rust/WASM</title>
</head>
<body></body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
... | candle/candle-wasm-examples/llama2-c/lib-example.html/0 | {
"file_path": "candle/candle-wasm-examples/llama2-c/lib-example.html",
"repo_id": "candle",
"token_count": 6089
} |
## Running T5 with Candle and WASM
Here, we provide two examples of how to run Bert using a Candle-compiled WASM binary and runtime.
### Vanilla JS and WebWorkers
To build and test the UI made in Vanilla JS and WebWorkers, first we need to build the WASM library:
```bash
sh build-lib.sh
```
This will bundle the li... | candle/candle-wasm-examples/t5/README.md/0 | {
"file_path": "candle/candle-wasm-examples/t5/README.md",
"repo_id": "candle",
"token_count": 282
} |
// Audio processing code, adapted from whisper.cpp
// https://github.com/ggerganov/whisper.cpp
use super::worker;
pub trait Float: num_traits::Float + num_traits::FloatConst + num_traits::NumAssign {}
impl Float for f32 {}
impl Float for f64 {}
// https://github.com/ggerganov/whisper.cpp/blob/4774d2feb01a772a15de81f... | candle/candle-wasm-examples/whisper/src/audio.rs/0 | {
"file_path": "candle/candle-wasm-examples/whisper/src/audio.rs",
"repo_id": "candle",
"token_count": 3162
} |
{
"version": "0.2.0",
"configurations": [
{
"command": "npm run dev",
"name": "Run development server",
"request": "launch",
"type": "node-terminal"
}
]
}
| chat-ui/.vscode/launch.json/0 | {
"file_path": "chat-ui/.vscode/launch.json",
"repo_id": "chat-ui",
"token_count": 82
} |
{{- if and .Values.serviceAccount.enabled .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
metadata:
name: "{{ .Values.serviceAccount.name | default (include "name" .) }}"
namespace: {{ .Release.Namespace }}
... | chat-ui/chart/templates/service-account.yaml/0 | {
"file_path": "chat-ui/chart/templates/service-account.yaml",
"repo_id": "chat-ui",
"token_count": 154
} |
# Llama.cpp
| Feature | Available |
| --------------------------- | --------- |
| [Tools](../tools) | No |
| [Multimodal](../multimodal) | No |
Chat UI supports the llama.cpp API server directly without the need for an adapter. You can do this using the `llamacpp` endpoint ... | chat-ui/docs/source/configuration/models/providers/llamacpp.md/0 | {
"file_path": "chat-ui/docs/source/configuration/models/providers/llamacpp.md",
"repo_id": "chat-ui",
"token_count": 1023
} |
ENV_LOCAL_PATH=/app/.env.local
if test -z "${DOTENV_LOCAL}" ; then
if ! test -f "${ENV_LOCAL_PATH}" ; then
echo "DOTENV_LOCAL was not found in the ENV variables and .env.local is not set using a bind volume. Make sure to set environment variables properly. "
fi;
else
echo "DOTENV_LOCAL was found in... | chat-ui/entrypoint.sh/0 | {
"file_path": "chat-ui/entrypoint.sh",
"repo_id": "chat-ui",
"token_count": 266
} |
<script lang="ts">
import { base } from "$app/paths";
import type { ToolLogoColor, ToolLogoIcon } from "$lib/types/Tool";
import { debounce } from "$lib/utils/debounce";
import { onMount } from "svelte";
import ToolLogo from "./ToolLogo.svelte";
import CarbonClose from "~icons/carbon/close";
interface ToolSugg... | chat-ui/src/lib/components/AssistantToolPicker.svelte/0 | {
"file_path": "chat-ui/src/lib/components/AssistantToolPicker.svelte",
"repo_id": "chat-ui",
"token_count": 1761
} |
<script lang="ts">
import CarbonCaretLeft from "~icons/carbon/caret-left";
import CarbonCaretRight from "~icons/carbon/caret-right";
interface Props {
href: string;
direction: "next" | "previous";
isDisabled?: boolean;
}
let { href, direction, isDisabled = false }: Props = $props();
</script>
<a
class="f... | chat-ui/src/lib/components/PaginationArrow.svelte/0 | {
"file_path": "chat-ui/src/lib/components/PaginationArrow.svelte",
"repo_id": "chat-ui",
"token_count": 254
} |
<script lang="ts">
import type { Message } from "$lib/types/Message";
import CarbonTrashCan from "~icons/carbon/trash-can";
import CarbonChevronLeft from "~icons/carbon/chevron-left";
import CarbonChevronRight from "~icons/carbon/chevron-right";
import { enhance } from "$app/forms";
import { createEventDispatche... | chat-ui/src/lib/components/chat/Alternatives.svelte/0 | {
"file_path": "chat-ui/src/lib/components/chat/Alternatives.svelte",
"repo_id": "chat-ui",
"token_count": 844
} |
import { Database } from "$lib/server/database";
import { migrations } from "./routines";
import { acquireLock, releaseLock, isDBLocked, refreshLock } from "./lock";
import { isHuggingChat } from "$lib/utils/isHuggingChat";
import { logger } from "$lib/server/logger";
const LOCK_KEY = "migrations";
export async funct... | chat-ui/src/lib/migrations/migrations.ts/0 | {
"file_path": "chat-ui/src/lib/migrations/migrations.ts",
"repo_id": "chat-ui",
"token_count": 1286
} |
import { z } from "zod";
import type { EmbeddingEndpoint, Embedding } from "../embeddingEndpoints";
import { chunk } from "$lib/utils/chunk";
import { env } from "$env/dynamic/private";
import { logger } from "$lib/server/logger";
export const embeddingEndpointHfApiSchema = z.object({
weight: z.number().int().positiv... | chat-ui/src/lib/server/embeddingEndpoints/hfApi/embeddingHfApi.ts/0 | {
"file_path": "chat-ui/src/lib/server/embeddingEndpoints/hfApi/embeddingHfApi.ts",
"repo_id": "chat-ui",
"token_count": 671
} |
import type { Sharp } from "sharp";
import sharp from "sharp";
import type { MessageFile } from "$lib/types/Message";
import { z, type util } from "zod";
export interface ImageProcessorOptions<TMimeType extends string = string> {
supportedMimeTypes: TMimeType[];
preferredMimeType: TMimeType;
maxSizeInMB: number;
m... | chat-ui/src/lib/server/endpoints/images.ts/0 | {
"file_path": "chat-ui/src/lib/server/endpoints/images.ts",
"repo_id": "chat-ui",
"token_count": 2311
} |
import { generateFromDefaultEndpoint } from "../generateFromDefaultEndpoint";
import { getReturnFromGenerator } from "$lib/utils/getReturnFromGenerator";
import { logger } from "../logger";
export async function generateSummaryOfReasoning(buffer: string): Promise<string> {
// debug 5s delay
await new Promise((resol... | chat-ui/src/lib/server/textGeneration/reasoning.ts/0 | {
"file_path": "chat-ui/src/lib/server/textGeneration/reasoning.ts",
"repo_id": "chat-ui",
"token_count": 403
} |
import type { SerializedHTMLElement } from "../scrape/types";
import { htmlElementToMarkdownElements, mergeAdjacentElements } from "./fromHtml";
import type { HeaderElement, MarkdownElement } from "./types";
import { MarkdownElementType } from "./types";
import { chunkElements } from "./utils/chunk";
/**
* Converts H... | chat-ui/src/lib/server/websearch/markdown/tree.ts/0 | {
"file_path": "chat-ui/src/lib/server/websearch/markdown/tree.ts",
"repo_id": "chat-ui",
"token_count": 613
} |
import { env } from "$env/dynamic/private";
import type { WebSearchSource } from "$lib/types/WebSearch";
export default async function search(query: string): Promise<WebSearchSource[]> {
const params = {
q: query,
hl: "en",
gl: "us",
};
const response = await fetch("https://google.serper.dev/search", {
met... | chat-ui/src/lib/server/websearch/search/endpoints/serper.ts/0 | {
"file_path": "chat-ui/src/lib/server/websearch/search/endpoints/serper.ts",
"repo_id": "chat-ui",
"token_count": 282
} |
import type { ObjectId } from "mongodb";
import type { User } from "./User";
import type { Timestamps } from "./Timestamps";
import type { ReviewStatus } from "./Review";
export interface Assistant extends Timestamps {
_id: ObjectId;
createdById: User["_id"] | string; // user id or session
createdByName?: User["use... | chat-ui/src/lib/types/Assistant.ts/0 | {
"file_path": "chat-ui/src/lib/types/Assistant.ts",
"repo_id": "chat-ui",
"token_count": 318
} |
import type { Message } from "./Message";
import type { Tool, ToolResult } from "./Tool";
export type ChatTemplateInput = {
messages: Pick<Message, "from" | "content" | "files">[];
preprompt?: string;
tools?: Tool[];
toolResults?: ToolResult[];
continueMessage?: boolean;
};
| chat-ui/src/lib/types/Template.ts/0 | {
"file_path": "chat-ui/src/lib/types/Template.ts",
"repo_id": "chat-ui",
"token_count": 89
} |
<script lang="ts">
import { page } from "$app/state";
</script>
<div
class="flex items-center justify-center bg-gradient-to-t from-gray-200 text-gray-800 dark:from-gray-700 dark:text-gray-300"
>
<div
class="align-center -mt-24 flex flex-col justify-center rounded-xl border bg-white px-8 pb-2 pt-4 text-center dark... | chat-ui/src/routes/+error.svelte/0 | {
"file_path": "chat-ui/src/routes/+error.svelte",
"repo_id": "chat-ui",
"token_count": 342
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.