text stringlengths 96 319k | id stringlengths 14 178 | metadata dict |
|---|---|---|
# 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/zamba2/test_modeling_zamba2.py/0 | {
"file_path": "transformers/tests/models/zamba2/test_modeling_zamba2.py",
"repo_id": "transformers",
"token_count": 13146
} |
# 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... | transformers/tests/pipelines/test_pipelines_image_classification.py/0 | {
"file_path": "transformers/tests/pipelines/test_pipelines_image_classification.py",
"repo_id": "transformers",
"token_count": 5745
} |
# 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/pipelines/test_pipelines_translation.py/0 | {
"file_path": "transformers/tests/pipelines/test_pipelines_translation.py",
"repo_id": "transformers",
"token_count": 3494
} |
# coding=utf-8
# Copyright 2022 The HuggingFace Team 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 clone of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | transformers/tests/quantization/bnb/test_mixed_int8.py/0 | {
"file_path": "transformers/tests/quantization/bnb/test_mixed_int8.py",
"repo_id": "transformers",
"token_count": 17432
} |
import json
import logging
import os
import subprocess
from argparse import ArgumentParser
logger = logging.getLogger(__name__)
def parse_args():
parser = ArgumentParser()
parsed, unknown = parser.parse_known_args()
for arg in unknown:
if arg.startswith(("-", "--")):
parser.add_argum... | transformers/tests/sagemaker/scripts/pytorch/run_ddp.py/0 | {
"file_path": "transformers/tests/sagemaker/scripts/pytorch/run_ddp.py",
"repo_id": "transformers",
"token_count": 694
} |
# 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/test_pipeline_mixin.py/0 | {
"file_path": "transformers/tests/test_pipeline_mixin.py",
"repo_id": "transformers",
"token_count": 16841
} |
# coding=utf-8
# Copyright 2018 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_utils.py/0 | {
"file_path": "transformers/tests/trainer/test_trainer_utils.py",
"repo_id": "transformers",
"token_count": 12025
} |
# 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 required by applicabl... | transformers/tests/utils/test_deprecation.py/0 | {
"file_path": "transformers/tests/utils/test_deprecation.py",
"repo_id": "transformers",
"token_count": 3428
} |
# 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_modeling_tf_core.py/0 | {
"file_path": "transformers/tests/utils/test_modeling_tf_core.py",
"repo_id": "transformers",
"token_count": 9190
} |
# coding=utf-8
# Copyright 2023 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_docstrings.py/0 | {
"file_path": "transformers/utils/check_docstrings.py",
"repo_id": "transformers",
"token_count": 14531
} |
import argparse
import json
import os
import time
import zipfile
from get_ci_error_statistics import download_artifact, get_artifacts_links
from transformers import logging
logger = logging.get_logger(__name__)
def extract_warnings_from_single_artifact(artifact_path, targets):
"""Extract warnings from a downl... | transformers/utils/extract_warnings.py/0 | {
"file_path": "transformers/utils/extract_warnings.py",
"repo_id": "transformers",
"token_count": 2110
} |
#!/usr/bin/env python3
# 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
#
# Unles... | transformers/utils/print_env.py/0 | {
"file_path": "transformers/utils/print_env.py",
"repo_id": "transformers",
"token_count": 546
} |
# Best of N sampling: Alternative ways to get better model output without RL based fine-tuning
Within the extras module is the `best-of-n` sampler class that serves as an alternative method of generating better model output.
As to how it fares against the RL based fine-tuning, please look in the `examples` directory ... | trl/docs/source/best_of_n.md/0 | {
"file_path": "trl/docs/source/best_of_n.md",
"repo_id": "trl",
"token_count": 841
} |
<div style="text-align: center">
<img src="https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/trl_banner_dark.png">
</div>
# TRL - Transformer Reinforcement Learning
TRL is a full stack library where we provide a set of tools to train transformer language models with Reinforcement Learning, fro... | trl/docs/source/index.md/0 | {
"file_path": "trl/docs/source/index.md",
"repo_id": "trl",
"token_count": 1901
} |
# Quickstart
## How does it work?
Fine-tuning a language model via PPO consists of roughly three steps:
1. **Rollout**: The language model generates a response or continuation based on a query which could be the start of a sentence.
2. **Evaluation**: The query and response are evaluated with a function, model, huma... | trl/docs/source/quickstart.md/0 | {
"file_path": "trl/docs/source/quickstart.md",
"repo_id": "trl",
"token_count": 1117
} |
compute_environment: LOCAL_MACHINE
debug: false
deepspeed_config:
deepspeed_multinode_launcher: standard
offload_optimizer_device: none
offload_param_device: none
zero3_init_flag: true
zero3_save_16bit_model: true
zero_stage: 3
distributed_type: DEEPSPEED
downcast_bf16: 'no'
machine_rank: 0
main_training_fu... | trl/examples/accelerate_configs/deepspeed_zero3.yaml/0 | {
"file_path": "trl/examples/accelerate_configs/deepspeed_zero3.yaml",
"repo_id": "trl",
"token_count": 193
} |
<jupyter_start><jupyter_text>**Best-of-n sampling as an alternative to RLHF**This notebook compares reward-model scores of prompt based responses from 1. a base model (`gpt2-imdb`)2. `RLHF` tuned model based on this base-model 3. the base-model again from which we sample n responses to each prompt, score them and take ... | trl/examples/notebooks/best_of_n.ipynb/0 | {
"file_path": "trl/examples/notebooks/best_of_n.ipynb",
"repo_id": "trl",
"token_count": 1998
} |
# 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/scripts/ppo/ppo.py/0 | {
"file_path": "trl/examples/scripts/ppo/ppo.py",
"repo_id": "trl",
"token_count": 2397
} |
# 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/log_example_reports.py/0 | {
"file_path": "trl/scripts/log_example_reports.py",
"repo_id": "trl",
"token_count": 2641
} |
# 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_core.py/0 | {
"file_path": "trl/tests/test_core.py",
"repo_id": "trl",
"token_count": 653
} |
# 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_online_dpo_trainer.py/0 | {
"file_path": "trl/tests/test_online_dpo_trainer.py",
"repo_id": "trl",
"token_count": 5519
} |
# 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/core.py/0 | {
"file_path": "trl/trl/core.py",
"repo_id": "trl",
"token_count": 2373
} |
# 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/cpo_trainer.py/0 | {
"file_path": "trl/trl/trainer/cpo_trainer.py",
"repo_id": "trl",
"token_count": 22633
} |
# 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/online_dpo_config.py/0 | {
"file_path": "trl/trl/trainer/online_dpo_config.py",
"repo_id": "trl",
"token_count": 2921
} |
# 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/xpo_trainer.py/0 | {
"file_path": "trl/trl/trainer/xpo_trainer.py",
"repo_id": "trl",
"token_count": 11292
} |
# Big model inference benchmarks
Running inference with Accelerate on big models.
## Setup
These benchmarks use the `transformers` library:
```bash
pip install transformers
```
To reproduce or test a new setup, run
```py
python inference_acc.py model_name
```
This script supports `gpt-j-6b`, `gpt-neox`, `opt` (3... | accelerate/benchmarks/big_model_inference/README.md/0 | {
"file_path": "accelerate/benchmarks/big_model_inference/README.md",
"repo_id": "accelerate",
"token_count": 702
} |
# Builds CPU-only Docker image of PyTorch
# Uses multi-staged approach to reduce size
# Stage 1
FROM python:3.9-slim as compile-image
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update
RUN apt-get install -y --no-install-recommends \
build-essential \
git \
gcc
# Setup virtual environment for Docker
ENV V... | accelerate/docker/accelerate-cpu/Dockerfile/0 | {
"file_path": "accelerate/docker/accelerate-cpu/Dockerfile",
"repo_id": "accelerate",
"token_count": 380
} |
<!--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/explore.md/0 | {
"file_path": "accelerate/docs/source/usage_guides/explore.md",
"repo_id": "accelerate",
"token_count": 566
} |
# 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 required by appl... | accelerate/examples/complete_cv_example.py/0 | {
"file_path": "accelerate/examples/complete_cv_example.py",
"repo_id": "accelerate",
"token_count": 5557
} |
# Distributed inference examples
This folder contains a variety of tutorials for running distributed inference with the following strategy:
Load an entire model onto each GPU and sending chunks of a batch through each GPU’s model copy at a time
## Installation
```bash
pip install accelerate torch
```
## Running c... | accelerate/examples/inference/distributed/README.md/0 | {
"file_path": "accelerate/examples/inference/distributed/README.md",
"repo_id": "accelerate",
"token_count": 175
} |
#!/bin/bash -l
#SBATCH --job-name=multicpu
#SBATCH --nodes=2 # number of Nodes
#SBATCH --ntasks-per-node=1 # number of MP tasks
#SBATCH --exclusive
#SBATCH --output=O-%x.%j
#SBATCH --error=E-%x.%j
######################
### Set enviroment ###
######################
source activateEnv... | accelerate/examples/slurm/submit_multicpu.sh/0 | {
"file_path": "accelerate/examples/slurm/submit_multicpu.sh",
"repo_id": "accelerate",
"token_count": 767
} |
#!/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/config/update.py/0 | {
"file_path": "accelerate/src/accelerate/commands/config/update.py",
"repo_id": "accelerate",
"token_count": 774
} |
# 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 required by applicabl... | accelerate/src/accelerate/inference.py/0 | {
"file_path": "accelerate/src/accelerate/inference.py",
"repo_id": "accelerate",
"token_count": 2855
} |
# 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 required by appl... | accelerate/src/accelerate/test_utils/scripts/external_deps/test_performance.py/0 | {
"file_path": "accelerate/src/accelerate/test_utils/scripts/external_deps/test_performance.py",
"repo_id": "accelerate",
"token_count": 4147
} |
# 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/constants.py/0 | {
"file_path": "accelerate/src/accelerate/utils/constants.py",
"repo_id": "accelerate",
"token_count": 1404
} |
# 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/tqdm.py/0 | {
"file_path": "accelerate/src/accelerate/utils/tqdm.py",
"repo_id": "accelerate",
"token_count": 553
} |
# 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/tests/test_multigpu.py/0 | {
"file_path": "accelerate/tests/test_multigpu.py",
"repo_id": "accelerate",
"token_count": 2501
} |
# Copyright 2022 The HuggingFace Team, the AllenNLP library authors. 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
#
... | accelerate/utils/stale.py/0 | {
"file_path": "accelerate/utils/stale.py",
"repo_id": "accelerate",
"token_count": 1013
} |
[package]
name = "candle-book"
version.workspace = true
edition.workspace = true
description.workspace = true
repository.workspace = true
keywords.workspace = true
categories.workspace = true
license.workspace = true
readme = "README.md"
[dependencies]
accelerate-src = { workspace = true, optional = true }
candle = { ... | candle/candle-book/Cargo.toml/0 | {
"file_path": "candle/candle-book/Cargo.toml",
"repo_id": "candle",
"token_count": 459
} |
# Installation
**With Cuda support**:
1. First, make sure that Cuda is correctly installed.
- `nvcc --version` should print information about your Cuda compiler driver.
- `nvidia-smi --query-gpu=compute_cap --format=csv` should print your GPUs compute capability, e.g. something
like:
```bash
compute_cap
8.9
```
You... | candle/candle-book/src/guide/installation.md/0 | {
"file_path": "candle/candle-book/src/guide/installation.md",
"repo_id": "candle",
"token_count": 487
} |
mod benchmarks;
use criterion::criterion_main;
criterion_main!(
benchmarks::affine::benches,
benchmarks::matmul::benches,
benchmarks::random::benches,
benchmarks::reduce::benches,
benchmarks::where_cond::benches,
benchmarks::conv_transpose2d::benches,
benchmarks::qmatmul::benches,
benc... | candle/candle-core/benches/bench_main.rs/0 | {
"file_path": "candle/candle-core/benches/bench_main.rs",
"repo_id": "candle",
"token_count": 126
} |
//! Methods for backpropagation of gradients.
use crate::op::{BinaryOp, Op, ReduceOp, UnaryOp};
use crate::{Error, Result, Tensor, TensorId};
use std::collections::HashMap;
// arg has been reduced to node via reduce_dims, expand it back to arg.
// This has to handle keepdims.
fn broadcast_back(arg: &Tensor, node: &Ten... | candle/candle-core/src/backprop.rs/0 | {
"file_path": "candle/candle-core/src/backprop.rs",
"repo_id": "candle",
"token_count": 24360
} |
use crate::op::{BackpropOp, Op};
use crate::tensor::from_storage;
use crate::{CpuStorage, CudaStorage, Layout, MetalStorage, Result, Shape, Tensor};
use std::sync::Arc;
/// Unary ops that can be defined in user-land.
pub trait CustomOp1 {
// Box<dyn> does not support const yet, so use a function to get the name.
... | candle/candle-core/src/custom_op.rs/0 | {
"file_path": "candle/candle-core/src/custom_op.rs",
"repo_id": "candle",
"token_count": 7370
} |
use super::k_quants::{
BlockQ2K, BlockQ3K, BlockQ4K, BlockQ4_0, BlockQ5K, BlockQ6K, BlockQ8K, BlockQ8_0, QK8_0, QK_K,
};
use crate::Result;
use byteorder::{ByteOrder, LittleEndian};
use half::f16;
#[cfg(target_arch = "x86")]
use core::arch::x86::*;
#[cfg(target_arch = "x86_64")]
use core::arch::x86_64::*;
#[inlin... | candle/candle-core/src/quantized/avx.rs/0 | {
"file_path": "candle/candle-core/src/quantized/avx.rs",
"repo_id": "candle",
"token_count": 17495
} |
use crate::backend::BackendStorage;
use crate::op::{self, CmpOp, ReduceOp};
use crate::{CpuStorage, CudaStorage, DType, Device, Error, Layout, MetalStorage, Result, Shape};
use crate::{CustomOp1, CustomOp2, CustomOp3, InplaceOp1, InplaceOp2, InplaceOp3};
// We do not want to implement Clone on Storage as cloning may f... | candle/candle-core/src/storage.rs/0 | {
"file_path": "candle/candle-core/src/storage.rs",
"repo_id": "candle",
"token_count": 15585
} |
# candle-blip
The
[blip-image-captioning](https://huggingface.co/Salesforce/blip-image-captioning-base)
model can generate captions for an input image.
## Running on an example
```bash
cargo run --example blip --release -- --image candle-examples/examples/yolo-v8/assets/bike.jpg
```
```
Running on CPU, to run on GP... | candle/candle-examples/examples/blip/README.md/0 | {
"file_path": "candle/candle-examples/examples/blip/README.md",
"repo_id": "candle",
"token_count": 190
} |
// This example illustrates how to implement custom operations. These operations can provide their
// own forward pass (CPU and GPU versions) as well as their backward pass.
//
// In this example we add the RMS normalization operation and implement it for f32.
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[rus... | candle/candle-examples/examples/custom-ops/main.rs/0 | {
"file_path": "candle/candle-examples/examples/custom-ops/main.rs",
"repo_id": "candle",
"token_count": 1475
} |
use anyhow::{Context, Result};
use std::sync::{Arc, Mutex};
pub const SAMPLE_RATE: usize = 24_000;
pub(crate) struct AudioOutputData_ {
resampled_data: std::collections::VecDeque<f32>,
resampler: rubato::FastFixedIn<f32>,
output_buffer: Vec<f32>,
input_buffer: Vec<f32>,
input_len: usize,
}
impl A... | candle/candle-examples/examples/encodec/audio_io.rs/0 | {
"file_path": "candle/candle-examples/examples/encodec/audio_io.rs",
"repo_id": "candle",
"token_count": 4796
} |
use candle::{DType, Device, Tensor};
use candle_nn::VarBuilder;
use candle_transformers::generation::LogitsProcessor;
use candle_transformers::models::glm4::*;
use clap::Parser;
use hf_hub::{Repo, RepoType};
use tokenizers::Tokenizer;
struct TextGeneration {
model: Model,
device: Device,
tokenizer: Tokenize... | candle/candle-examples/examples/glm4/main.rs/0 | {
"file_path": "candle/candle-examples/examples/glm4/main.rs",
"repo_id": "candle",
"token_count": 3621
} |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use anyhow::{Error as E, Result};
use clap::Parser;
use candle::{DType, Device, Tensor};
use candle_nn::VarBuilder;
use candle_transformers::{
generation::LogitsProcessor,
models::{moondream, quant... | candle/candle-examples/examples/moondream/main.rs/0 | {
"file_path": "candle/candle-examples/examples/moondream/main.rs",
"repo_id": "candle",
"token_count": 5490
} |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use anyhow::{Error as E, Result};
use clap::{Parser, ValueEnum};
use candle_examples::token_output_stream::TokenOutputStream;
use candle_transformers::models::mixformer::{Config, MixFormerSequentialForCaus... | candle/candle-examples/examples/phi/main.rs/0 | {
"file_path": "candle/candle-examples/examples/phi/main.rs",
"repo_id": "candle",
"token_count": 9478
} |
import gymnasium as gym
import numpy as np
from collections import deque
from PIL import Image
from multiprocessing import Process, Pipe
# atari_wrappers.py
class NoopResetEnv(gym.Wrapper):
def __init__(self, env, noop_max=30):
"""Sample initial states by taking random number of no-ops on reset.
No... | candle/candle-examples/examples/reinforcement-learning/atari_wrappers.py/0 | {
"file_path": "candle/candle-examples/examples/reinforcement-learning/atari_wrappers.py",
"repo_id": "candle",
"token_count": 4740
} |
# candle-segformer
- [HuggingFace Segformer Model Card][segformer]
- [`mit-b0` - An encoder only pretrained model][encoder]
- [`segformer-b0-finetuned-ade-512-512` - A fine tuned model for segmentation][ade512]
## How to run the example
If you want you can use the example images from this [pull request][pr], downloa... | candle/candle-examples/examples/segformer/README.md/0 | {
"file_path": "candle/candle-examples/examples/segformer/README.md",
"repo_id": "candle",
"token_count": 357
} |
use anyhow::{Error as E, Ok, Result};
use candle::{DType, IndexOp, Module, Tensor, D};
use candle_transformers::models::{stable_diffusion, t5};
use std::path::PathBuf;
use tokenizers::tokenizer::Tokenizer;
struct ClipWithTokenizer {
clip: stable_diffusion::clip::ClipTextTransformer,
config: stable_diffusion::c... | candle/candle-examples/examples/stable-diffusion-3/clip.rs/0 | {
"file_path": "candle/candle-examples/examples/stable-diffusion-3/clip.rs",
"repo_id": "candle",
"token_count": 4060
} |
use image::{DynamicImage, ImageBuffer};
use serde::Deserialize;
use std::collections::HashMap;
use candle::{DType, Device, Result, Tensor};
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct ProcessorConfig {
do_resize: bool,
height: u32,
width: u32,
do_rescale: bool,
do_normalize: bool,
... | candle/candle-examples/examples/trocr/image_processor.rs/0 | {
"file_path": "candle/candle-examples/examples/trocr/image_processor.rs",
"repo_id": "candle",
"token_count": 2273
} |
# candle-wuerstchen: Efficient Pretraining of Text-to-Image Models

The `wuerstchen` example is a port of the [diffusers
implementation](https://github.com/huggingface/diffusers/tree/19edca82f1ff194c07317369a92b470dbae97f34/src/diffusers/pipelines/wuer... | candle/candle-examples/examples/wuerstchen/README.md/0 | {
"file_path": "candle/candle-examples/examples/wuerstchen/README.md",
"repo_id": "candle",
"token_count": 358
} |
use candle::{DType, IndexOp, Result, Tensor, D};
use candle_nn::{batch_norm, conv2d, conv2d_no_bias, Conv2d, Conv2dConfig, Module, VarBuilder};
#[derive(Clone, Copy, PartialEq, Debug)]
pub struct Multiples {
depth: f64,
width: f64,
ratio: f64,
}
impl Multiples {
pub fn n() -> Self {
Self {
... | candle/candle-examples/examples/yolo-v8/model.rs/0 | {
"file_path": "candle/candle-examples/examples/yolo-v8/model.rs",
"repo_id": "candle",
"token_count": 12422
} |
/******************************************************************************
* Copyright (c) 2023, Tri Dao.
******************************************************************************/
#pragma once
#include <cuda.h>
#include <vector>
// #include <ATen/cuda/CUDAGeneratorImpl.h> // For at::Generator and at::Ph... | candle/candle-flash-attn/kernels/flash.h/0 | {
"file_path": "candle/candle-flash-attn/kernels/flash.h",
"repo_id": "candle",
"token_count": 2326
} |
mod ffi;
use candle::backend::BackendStorage;
use candle::cuda_backend::cudarc::driver::DevicePtr;
use candle::cuda_backend::WrapErr;
use candle::{CpuStorage, DType, Layout, Result, Shape, Tensor};
use half::{bf16, f16};
pub struct FlashAttn {
pub softmax_scale: f32,
pub alibi_slopes: Option<Tensor>,
pub ... | candle/candle-flash-attn/src/lib.rs/0 | {
"file_path": "candle/candle-flash-attn/src/lib.rs",
"repo_id": "candle",
"token_count": 17752
} |
#include "cuda_utils.cuh"
#include <cmath>
#include <stdint.h>
#define WARP_SIZE 32
const int BLOCK_SIZE = 1024;
// TODO: Maybe add some fast_sum_f16_f32 variant that not only accumulate in f32
// but also expect a f32 output so that this can be used for normalization e.g.
// in softmax.
// Fast reduce sum kernel, t... | candle/candle-kernels/src/reduce.cu/0 | {
"file_path": "candle/candle-kernels/src/reduce.cu",
"repo_id": "candle",
"token_count": 12783
} |
// The implementation below comes from MLX.
// https://github.com/ml-explore/mlx/blob/0cea88bcc5e98e81a24d92eed8870a6976999f05/mlx/backend/metal/kernels/sort.h
// Copyright © 2023-2024 Apple Inc.
#define MLX_MTL_CONST static constant constexpr const
#define MLX_MTL_LOOP_UNROLL _Pragma("clang loop unroll(full)")
#incl... | candle/candle-metal-kernels/src/mlx_sort.metal/0 | {
"file_path": "candle/candle-metal-kernels/src/mlx_sort.metal",
"repo_id": "candle",
"token_count": 12675
} |
[package]
name = "candle-nn"
version.workspace = true
edition.workspace = true
description.workspace = true
repository.workspace = true
keywords.workspace = true
categories.workspace = true
license.workspace = true
readme = "README.md"
[dependencies]
accelerate-src = { workspace = true, optional = true }
candle = { wo... | candle/candle-nn/Cargo.toml/0 | {
"file_path": "candle/candle-nn/Cargo.toml",
"repo_id": "candle",
"token_count": 371
} |
//! Variable initialization.
// This is based on:
// https://github.com/pytorch/pytorch/blob/07107919297db3f8ab37f11c12666b6d6d5f692e/torch/nn/init.py#
use candle::{DType, Device, Result, Shape, Tensor, Var};
/// Number of features as input or output of a layer.
/// In Kaiming initialization, choosing `FanIn` preserve... | candle/candle-nn/src/init.rs/0 | {
"file_path": "candle/candle-nn/src/init.rs",
"repo_id": "candle",
"token_count": 2212
} |
#[cfg(feature = "mkl")]
extern crate intel_mkl_src;
#[cfg(feature = "accelerate")]
extern crate accelerate_src;
use anyhow::Result;
use candle::{test_utils, Device, Tensor};
use candle_nn::{LayerNorm, Module};
#[test]
fn layer_norm() -> Result<()> {
let device = &Device::Cpu;
let w = Tensor::new(&[3f32], dev... | candle/candle-nn/tests/layer_norm.rs/0 | {
"file_path": "candle/candle-nn/tests/layer_norm.rs",
"repo_id": "candle",
"token_count": 892
} |
## Installation
From the `candle-pyo3` directory, enable a virtual env where you will want the
candle package to be installed then run.
```bash
maturin develop -r
python test.py
```
## Generating Stub Files for Type Hinting
For type hinting support, the `candle-pyo3` package requires `*.pyi` files. You can automa... | candle/candle-pyo3/README.md/0 | {
"file_path": "candle/candle-pyo3/README.md",
"repo_id": "candle",
"token_count": 190
} |
import candle
from candle import Tensor
from .module import Module
from typing import Union, List, Tuple, Optional, Any
_shape_t = Union[int, List[int]]
import numbers
class LayerNorm(Module):
r"""Applies Layer Normalization over a mini-batch of inputs as described in
the paper `Layer Normalization <https://... | candle/candle-pyo3/py_src/candle/nn/normalization.py/0 | {
"file_path": "candle/candle-pyo3/py_src/candle/nn/normalization.py",
"repo_id": "candle",
"token_count": 803
} |
import candle
import torch
# convert from candle tensor to torch tensor
t = candle.randn((3, 512, 512))
torch_tensor = t.to_torch()
print(torch_tensor)
print(type(torch_tensor))
# convert from torch tensor to candle tensor
t = torch.randn((3, 512, 512))
candle_tensor = candle.Tensor(t)
print(candle_tensor)
print(type... | candle/candle-pyo3/test_pytorch.py/0 | {
"file_path": "candle/candle-pyo3/test_pytorch.py",
"repo_id": "candle",
"token_count": 126
} |
//! Based on the BLIP paper from Salesforce Research.
//!
//! The blip-image-captioning model can generate captions for an input image.
//!
//! - ⚡ [Interactive Wasm Example](https://huggingface.co/spaces/radames/Candle-BLIP-Image-Captioning)
//! - 💻 [GH Link](https://github.com/salesforce/BLIP)
//! - 🤗 [HF Link](htt... | candle/candle-transformers/src/models/blip.rs/0 | {
"file_path": "candle/candle-transformers/src/models/blip.rs",
"repo_id": "candle",
"token_count": 4762
} |
//! Implementation of the DINOv2 models from Meta Research.
//!
//! This module implements the DINOv2 vision transformer model from Meta AI Research.
//! DINOv2 is a self-supervised learning model that can learn visual features
//! without using any labeled data. See: ["DINOv2: Learning Robust Visual Features without S... | candle/candle-transformers/src/models/dinov2.rs/0 | {
"file_path": "candle/candle-transformers/src/models/dinov2.rs",
"repo_id": "candle",
"token_count": 6312
} |
//! GLM-4 inference implementation.
//!
//! An open bilingual language model with 130B parameters.
//!
//! Based on implementation from [ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B)
use crate::models::with_tracing::{linear_b as linear, Linear};
use candle::{DType, Device, IndexOp, Module, Result, Tensor, D};
use c... | candle/candle-transformers/src/models/glm4.rs/0 | {
"file_path": "candle/candle-transformers/src/models/glm4.rs",
"repo_id": "candle",
"token_count": 10660
} |
//! mimi model
//!
//! [Mimi](https://huggingface.co/kyutai/mimi) is a state of the art audio
//! compression model using an encoder/decoder architecture with residual vector
//! quantization. The candle implementation supports streaming meaning that it's
//! possible to encode or decode a stream of audio tokens on the... | candle/candle-transformers/src/models/mimi/mod.rs/0 | {
"file_path": "candle/candle-transformers/src/models/mimi/mod.rs",
"repo_id": "candle",
"token_count": 480
} |
//! ModernBERT
//!
//! ModernBERT is a modernized bidirectional encoder-only Transformer model.
//! - [Arxiv](https://arxiv.org/abs/2412.13663) "Smarter, Better, Faster, Longer: A Modern Bidirectional Encoder for Fast, Memory Efficient, and Long Context Finetuning and Inference"
//! - Upstream [Github repo](https://git... | candle/candle-transformers/src/models/modernbert.rs/0 | {
"file_path": "candle/candle-transformers/src/models/modernbert.rs",
"repo_id": "candle",
"token_count": 6231
} |
use candle::{DType, Device, Module, Result, Tensor, D};
use candle_nn::{linear_b, rms_norm, Linear, RmsNorm, VarBuilder};
fn default_act() -> candle_nn::Activation {
candle_nn::Activation::Silu
}
fn default_hidden_size() -> usize {
1024
}
fn default_intermediate_size() -> usize {
4096
}
fn default_num_c... | candle/candle-transformers/src/models/pixtral/vision_model.rs/0 | {
"file_path": "candle/candle-transformers/src/models/pixtral/vision_model.rs",
"repo_id": "candle",
"token_count": 5788
} |
//! Module for quantized StableLM implementation.
//!
//! StableLM is a series of open-source large language models
//! optimized for performance and stability. This implementation
//! provides quantization support for efficient model deployment.
//!
//! Key characteristics:
//! - RMSNorm for layer normalization
//! - ... | candle/candle-transformers/src/models/quantized_stable_lm.rs/0 | {
"file_path": "candle/candle-transformers/src/models/quantized_stable_lm.rs",
"repo_id": "candle",
"token_count": 5352
} |
use candle::{Result, Tensor};
use candle_nn::{layer_norm, LayerNorm, Linear, Module, VarBuilder};
#[derive(Debug)]
struct Attention {
q_proj: Linear,
k_proj: Linear,
v_proj: Linear,
out_proj: Linear,
num_heads: usize,
}
impl Attention {
fn new(
embedding_dim: usize,
num_heads: ... | candle/candle-transformers/src/models/segment_anything/transformer.rs/0 | {
"file_path": "candle/candle-transformers/src/models/segment_anything/transformer.rs",
"repo_id": "candle",
"token_count": 3597
} |
//! Würstchen Efficient Diffusion Model
//!
//! Würstchen is an efficient diffusion model architecture for generating images using
//! a two-stage approach with a small decoder and prior network.
//!
//! - 💻 [GH Link](https://github.com/dome272/Wuerstchen)
//! - 🤗 [HF Link](https://github.com/huggingface/diffusers/bl... | candle/candle-transformers/src/models/wuerstchen/mod.rs/0 | {
"file_path": "candle/candle-transformers/src/models/wuerstchen/mod.rs",
"repo_id": "candle",
"token_count": 302
} |
use candle::{DType, Device, Tensor};
use candle_nn::VarBuilder;
use candle_transformers::{
generation::LogitsProcessor,
models::{moondream, quantized_moondream},
};
use candle_wasm_example_moondream::console_log;
use js_sys::Date;
use serde::{Deserialize, Serialize};
use tokenizers::Tokenizer;
use wasm_bindgen:... | candle/candle-wasm-examples/moondream/src/bin/m.rs/0 | {
"file_path": "candle/candle-wasm-examples/moondream/src/bin/m.rs",
"repo_id": "candle",
"token_count": 4976
} |
use crate::console_log;
use crate::worker::{ModelData, Segment, Worker, WorkerInput, WorkerOutput};
use js_sys::Date;
use wasm_bindgen::prelude::*;
use wasm_bindgen_futures::JsFuture;
use yew::{html, Component, Context, Html};
use yew_agent::{Bridge, Bridged};
const SAMPLE_NAMES: [&str; 6] = [
"audios/samples_jfk.... | candle/candle-wasm-examples/whisper/src/app.rs/0 | {
"file_path": "candle/candle-wasm-examples/whisper/src/app.rs",
"repo_id": "candle",
"token_count": 5669
} |
use candle_wasm_example_yolo::coco_classes;
use candle_wasm_example_yolo::model::Bbox;
use candle_wasm_example_yolo::worker::Model as M;
use candle_wasm_example_yolo::worker::ModelPose as P;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct Model {
inner: M,
}
#[wasm_bindgen]
impl Model {
#[wasm_bindge... | candle/candle-wasm-examples/yolo/src/bin/m.rs/0 | {
"file_path": "candle/candle-wasm-examples/yolo/src/bin/m.rs",
"repo_id": "candle",
"token_count": 840
} |
# Use .env.local to change these variables
# DO NOT EDIT THIS FILE WITH SENSITIVE DATA
### MongoDB ###
MONGODB_URL=#your mongodb URL here, use chat-ui-db image if you don't want to set this
MONGODB_DB_NAME=chat-ui
MONGODB_DIRECT_CONNECTION=false
### Endpoints config ###
HF_API_ROOT=https://api-inference.huggingface.... | chat-ui/.env/0 | {
"file_path": "chat-ui/.env",
"repo_id": "chat-ui",
"token_count": 2884
} |
{{- if $.Values.networkPolicy.enabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "name" . }}
namespace: {{ .Release.Namespace }}
spec:
egress:
- ports:
- port: 53
protocol: UDP
to:
- namespaceSelector:
matchLabels:
... | chat-ui/chart/templates/network-policy.yaml/0 | {
"file_path": "chat-ui/chart/templates/network-policy.yaml",
"repo_id": "chat-ui",
"token_count": 494
} |
# LangServe
| Feature | Available |
| --------------------------- | --------- |
| [Tools](../tools) | No |
| [Multimodal](../multimodal) | No |
LangChain applications that are deployed using LangServe can be called with the following config:
```ini
MODELS=`[
{
"name"... | chat-ui/docs/source/configuration/models/providers/langserve.md/0 | {
"file_path": "chat-ui/docs/source/configuration/models/providers/langserve.md",
"repo_id": "chat-ui",
"token_count": 220
} |
<script lang="ts">
import type { readAndCompressImage } from "browser-image-resizer";
import type { Model } from "$lib/types/Model";
import type { Assistant } from "$lib/types/Assistant";
import { onMount } from "svelte";
import { applyAction, enhance } from "$app/forms";
import { page } from "$app/state";
impo... | chat-ui/src/lib/components/AssistantSettings.svelte/0 | {
"file_path": "chat-ui/src/lib/components/AssistantSettings.svelte",
"repo_id": "chat-ui",
"token_count": 9229
} |
<script lang="ts">
import { page } from "$app/stores";
import { getHref } from "$lib/utils/getHref";
import PaginationArrow from "./PaginationArrow.svelte";
interface Props {
classNames?: string;
numItemsPerPage: number;
numTotalItems: number;
}
let { classNames = "", numItemsPerPage, numTotalItems }: Pro... | chat-ui/src/lib/components/Pagination.svelte/0 | {
"file_path": "chat-ui/src/lib/components/Pagination.svelte",
"repo_id": "chat-ui",
"token_count": 1249
} |
<script lang="ts">
import { webSearchParameters } from "$lib/stores/webSearchParameters";
import CarbonInformation from "~icons/carbon/information";
import Switch from "./Switch.svelte";
const toggle = () => ($webSearchParameters.useSearch = !$webSearchParameters.useSearch);
</script>
<div
class="flex h-8 cursor... | chat-ui/src/lib/components/WebSearchToggle.svelte/0 | {
"file_path": "chat-ui/src/lib/components/WebSearchToggle.svelte",
"repo_id": "chat-ui",
"token_count": 448
} |
<script lang="ts">
interface Props {
classNames?: string;
}
let { classNames = "" }: Props = $props();
</script>
<svg
xmlns="http://www.w3.org/2000/svg"
width="1em"
height="1em"
class={classNames}
fill="none"
viewBox="0 0 26 23"
>
<path
fill="url(#a)"
d="M.93 10.65A10.17 10.17 0 0 1 11.11.48h4.67a9.45... | chat-ui/src/lib/components/icons/IconDazzled.svelte/0 | {
"file_path": "chat-ui/src/lib/components/icons/IconDazzled.svelte",
"repo_id": "chat-ui",
"token_count": 941
} |
import { afterEach, assert, describe, expect, it } from "vitest";
import { migrations } from "./routines";
import { acquireLock, isDBLocked, refreshLock, releaseLock } from "./lock";
import { collections } from "$lib/server/database";
const LOCK_KEY = "migrations.test";
describe("migrations", () => {
it("should not ... | chat-ui/src/lib/migrations/migrations.spec.ts/0 | {
"file_path": "chat-ui/src/lib/migrations/migrations.spec.ts",
"repo_id": "chat-ui",
"token_count": 665
} |
import { z } from "zod";
import {
embeddingEndpointTei,
embeddingEndpointTeiParametersSchema,
} from "./tei/embeddingEndpoints";
import {
embeddingEndpointTransformersJS,
embeddingEndpointTransformersJSParametersSchema,
} from "./transformersjs/embeddingEndpoints";
import {
embeddingEndpointOpenAI,
embeddingEndpo... | chat-ui/src/lib/server/embeddingEndpoints/embeddingEndpoints.ts/0 | {
"file_path": "chat-ui/src/lib/server/embeddingEndpoints/embeddingEndpoints.ts",
"repo_id": "chat-ui",
"token_count": 544
} |
import {
VertexAI,
HarmCategory,
HarmBlockThreshold,
type Content,
type TextPart,
} from "@google-cloud/vertexai";
import type { Endpoint, TextGenerationStreamOutputWithToolsAndWebSources } from "../endpoints";
import { z } from "zod";
import type { Message } from "$lib/types/Message";
import { createImageProcesso... | chat-ui/src/lib/server/endpoints/google/endpointVertex.ts/0 | {
"file_path": "chat-ui/src/lib/server/endpoints/google/endpointVertex.ts",
"repo_id": "chat-ui",
"token_count": 2595
} |
import { runWebSearch } from "$lib/server/websearch/runWebSearch";
import { preprocessMessages } from "../endpoints/preprocessMessages";
import { generateTitleForConversation } from "./title";
import {
assistantHasDynamicPrompt,
assistantHasWebSearch,
getAssistantById,
processPreprompt,
} from "./assistant";
impor... | chat-ui/src/lib/server/textGeneration/index.ts/0 | {
"file_path": "chat-ui/src/lib/server/textGeneration/index.ts",
"repo_id": "chat-ui",
"token_count": 960
} |
import { collapseString, sanitizeString } from "./utils/nlp";
import { stringifyHTMLElements, stringifyHTMLElementsUnformatted } from "./utils/stringify";
import { MarkdownElementType, tagNameMap, type HeaderElement, type MarkdownElement } from "./types";
import type { SerializedHTMLElement } from "../scrape/types";
i... | chat-ui/src/lib/server/websearch/markdown/fromHtml.ts/0 | {
"file_path": "chat-ui/src/lib/server/websearch/markdown/fromHtml.ts",
"repo_id": "chat-ui",
"token_count": 1033
} |
import { env } from "$env/dynamic/private";
import { isURL } from "$lib/utils/isUrl";
import type { WebSearchSource } from "$lib/types/WebSearch";
type SerpStackResponse = {
organic_results: {
title: string;
url: string;
snippet?: string;
}[];
error?: string;
};
export default async function searchSerpStack(... | chat-ui/src/lib/server/websearch/search/endpoints/serpStack.ts/0 | {
"file_path": "chat-ui/src/lib/server/websearch/search/endpoints/serpStack.ts",
"repo_id": "chat-ui",
"token_count": 344
} |
import type { Conversation } from "./Conversation";
export type SharedConversation = Pick<
Conversation,
| "model"
| "embeddingModel"
| "title"
| "rootMessageId"
| "messages"
| "preprompt"
| "assistantId"
| "createdAt"
| "updatedAt"
> & {
_id: string;
hash: string;
};
| chat-ui/src/lib/types/SharedConversation.ts/0 | {
"file_path": "chat-ui/src/lib/types/SharedConversation.ts",
"repo_id": "chat-ui",
"token_count": 114
} |
/** Takes an unknown error and attempts to convert it to a string */
export function stringifyError(error: unknown): string {
if (error instanceof Error) return error.message;
if (typeof error === "string") return error;
if (typeof error === "object" && error !== null) {
// try a few common properties
if ("messa... | chat-ui/src/lib/utils/stringifyError.ts/0 | {
"file_path": "chat-ui/src/lib/utils/stringifyError.ts",
"repo_id": "chat-ui",
"token_count": 167
} |
import { collections } from "$lib/server/database";
import { ObjectId } from "mongodb";
import { describe, expect, it } from "vitest";
// function used to insert conversations used for testing
export const insertLegacyConversation = async () => {
const res = await collections.conversations.insertOne({
_id: new Obj... | chat-ui/src/lib/utils/tree/treeHelpers.spec.ts/0 | {
"file_path": "chat-ui/src/lib/utils/tree/treeHelpers.spec.ts",
"repo_id": "chat-ui",
"token_count": 1864
} |
import { authCondition } from "$lib/server/auth";
import type { Conversation } from "$lib/types/Conversation";
import { collections } from "$lib/server/database";
import { ObjectId } from "mongodb";
export async function GET({ locals }) {
if (locals.user?._id || locals.sessionId) {
const settings = await collection... | chat-ui/src/routes/api/user/assistants/+server.ts/0 | {
"file_path": "chat-ui/src/routes/api/user/assistants/+server.ts",
"repo_id": "chat-ui",
"token_count": 509
} |
import { base } from "$app/paths";
import { authCondition } from "$lib/server/auth";
import { collections } from "$lib/server/database";
import { redirect } from "@sveltejs/kit";
export const actions = {
async delete({ locals }) {
// double check we have a user to delete conversations for
if (locals.user?._id || ... | chat-ui/src/routes/conversations/+page.server.ts/0 | {
"file_path": "chat-ui/src/routes/conversations/+page.server.ts",
"repo_id": "chat-ui",
"token_count": 158
} |
import { collections } from "$lib/server/database";
import { z } from "zod";
import { authCondition } from "$lib/server/auth";
import { DEFAULT_SETTINGS, type SettingsEditable } from "$lib/types/Settings";
import { toolFromConfigs } from "$lib/server/tools/index.js";
import { ObjectId } from "mongodb";
export async fu... | chat-ui/src/routes/settings/(nav)/+server.ts/0 | {
"file_path": "chat-ui/src/routes/settings/(nav)/+server.ts",
"repo_id": "chat-ui",
"token_count": 695
} |
import { env } from "$env/dynamic/private";
import { authCondition } from "$lib/server/auth.js";
import { Database, collections } from "$lib/server/database.js";
import { toolFromConfigs } from "$lib/server/tools/index.js";
import { SortKey } from "$lib/types/Assistant.js";
import { ReviewStatus } from "$lib/types/Revi... | chat-ui/src/routes/tools/+page.server.ts/0 | {
"file_path": "chat-ui/src/routes/tools/+page.server.ts",
"repo_id": "chat-ui",
"token_count": 1098
} |
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"values": "<DVC_METRIC_DATA>"
},
"title": "<DVC_METRIC_TITLE>",
"mark": "point",
"encoding": {
"x": {
"field": "<DVC_METRIC_X>",
"type": "quantitative",
"title": "<DVC_ME... | datasets/.dvc/plots/scatter.json/0 | {
"file_path": "datasets/.dvc/plots/scatter.json",
"repo_id": "datasets",
"token_count": 402
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.