text
stringlengths
5
631k
id
stringlengths
14
178
metadata
dict
__index_level_0__
int64
0
647
from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class CustomTokenizerFast(BertTokenizerFast): slow_tokenizer_class = CustomTokenizer pass
transformers/utils/test_module/custom_tokenization_fast.py/0
{ "file_path": "transformers/utils/test_module/custom_tokenization_fast.py", "repo_id": "transformers", "token_count": 54 }
600
- sections: - local: index title: TRL - local: installation title: Installation - local: quickstart title: Quickstart title: Getting started - sections: - local: dataset_formats title: Dataset Formats - local: paper_index title: Paper Index - local: how_to_train title: Training FAQ...
trl/docs/source/_toctree.yml/0
{ "file_path": "trl/docs/source/_toctree.yml", "repo_id": "trl", "token_count": 1067 }
601
# Use model after training Once you have trained a model using either the SFTTrainer, PPOTrainer, or DPOTrainer, you will have a fine-tuned model that can be used for text generation. In this section, we'll walk through the process of loading the fine-tuned model and generating text. If you need to run an inference se...
trl/docs/source/use_model.md/0
{ "file_path": "trl/docs/source/use_model.md", "repo_id": "trl", "token_count": 778 }
602
# Copyright 2020-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 appl...
trl/examples/research_projects/layer_skip/scripts/custom_trainer.py/0
{ "file_path": "trl/examples/research_projects/layer_skip/scripts/custom_trainer.py", "repo_id": "trl", "token_count": 800 }
603
# Copyright 2020-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 appl...
trl/examples/scripts/prm.py/0
{ "file_path": "trl/examples/scripts/prm.py", "repo_id": "trl", "token_count": 1727 }
604
# Copyright 2020-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 appl...
trl/scripts/generate_toolcall_dataset.py/0
{ "file_path": "trl/scripts/generate_toolcall_dataset.py", "repo_id": "trl", "token_count": 4074 }
605
# Copyright 2020-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 appl...
trl/tests/test_alignprop_trainer.py/0
{ "file_path": "trl/tests/test_alignprop_trainer.py", "repo_id": "trl", "token_count": 1265 }
606
# Copyright 2020-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 appl...
trl/tests/test_judges.py/0
{ "file_path": "trl/tests/test_judges.py", "repo_id": "trl", "token_count": 1303 }
607
# Copyright 2020-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 appl...
trl/tests/test_utils.py/0
{ "file_path": "trl/tests/test_utils.py", "repo_id": "trl", "token_count": 12515 }
608
# Copyright 2020-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 appl...
trl/trl/rewards/__init__.py/0
{ "file_path": "trl/trl/rewards/__init__.py", "repo_id": "trl", "token_count": 322 }
609
# Copyright 2020-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 appl...
trl/trl/trainer/bco_trainer.py/0
{ "file_path": "trl/trl/trainer/bco_trainer.py", "repo_id": "trl", "token_count": 32651 }
610
# Copyright 2020-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 appl...
trl/trl/trainer/kto_trainer.py/0
{ "file_path": "trl/trl/trainer/kto_trainer.py", "repo_id": "trl", "token_count": 38736 }
611
# Copyright 2020-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 appl...
trl/trl/trainer/sft_config.py/0
{ "file_path": "trl/trl/trainer/sft_config.py", "repo_id": "trl", "token_count": 4833 }
612
# Agent Course quiz scripts
agents-course/quiz/README.md/0
{ "file_path": "agents-course/quiz/README.md", "repo_id": "agents-course", "token_count": 5 }
0
# Unit 1 Quiz <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/whiteboard-unit1sub4DONE.jpg" alt="Unit 1 planning"/> Well done on working through the first unit! Let's test your understanding of the key concepts covered so far. When you pass the quiz, proceed to the next se...
agents-course/units/en/unit1/final-quiz.mdx/0
{ "file_path": "agents-course/units/en/unit1/final-quiz.mdx", "repo_id": "agents-course", "token_count": 479 }
1
# Introduction to `LangGraph` <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/LangGraph/LangGraph.png" alt="Unit 2.3 Thumbnail"/> Welcome to this next part of our journey, where you'll learn **how to build applications** using the [`LangGraph`](https://github.com/langchain-...
agents-course/units/en/unit2/langgraph/introduction.mdx/0
{ "file_path": "agents-course/units/en/unit2/langgraph/introduction.mdx", "repo_id": "agents-course", "token_count": 499 }
2
# Introduction to `smolagents` <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit2/smolagents/thumbnail.jpg" alt="Unit 2.1 Thumbnail"/> Welcome to this module, where you'll learn **how to build effective agents** using the [`smolagents`](https://github.com/huggingface/smolagent...
agents-course/units/en/unit2/smolagents/introduction.mdx/0
{ "file_path": "agents-course/units/en/unit2/smolagents/introduction.mdx", "repo_id": "agents-course", "token_count": 1548 }
3
# And now? What topics I should learn? Agentic AI is a rapidly evolving field, and understanding foundational protocols is essential for building intelligent, autonomous systems. Two important standards you should get familiar with are: - The **Model Context Protocol (MCP)** - The **Agent-to-Agent Protocol (A2A)*...
agents-course/units/en/unit4/additional-readings.mdx/0
{ "file_path": "agents-course/units/en/unit4/additional-readings.mdx", "repo_id": "agents-course", "token_count": 443 }
4
# Conclusión Si llegaste hasta aquí, ¡felicidades! 🥳 ¡Has construido con éxito tu propio agente de batalla Pokémon! ⚔️🎮 Has dominado los fundamentos de los **flujos de trabajo agénticos**, conectado un **LLM** a un entorno de juego y desplegado un Agente inteligente listo para enfrentar los desafíos de la batalla. ...
agents-course/units/es/bonus-unit3/conclusion.mdx/0
{ "file_path": "agents-course/units/es/bonus-unit3/conclusion.mdx", "repo_id": "agents-course", "token_count": 451 }
5
# Mensajes y Tokens especiales Ahora que entendemos cómo funcionan los LLMs, veamos **cómo estructuran sus generaciones a través de plantillas de chat**. Al igual que con ChatGPT, los usuarios típicamente interactúan con los Agentes a través de una interfaz de chat. Por lo tanto, buscamos entender cómo los LLMs gesti...
agents-course/units/es/unit1/messages-and-special-tokens.mdx/0
{ "file_path": "agents-course/units/es/unit1/messages-and-special-tokens.mdx", "repo_id": "agents-course", "token_count": 4391 }
6
# ¿Qué es `LangGraph`? `LangGraph` s un marco de trabajo desarrollado por [LangChain](https://www.langchain.com/) **para gestionar el flujo de control de aplicaciones que integran un LLM.**. ## ¿Es `LangGraph` diferente de `LangChain`? LangChain proporciona una interfaz estándar para interactuar con modelos y otros ...
agents-course/units/es/unit2/langgraph/when_to_use_langgraph.mdx/0
{ "file_path": "agents-course/units/es/unit2/langgraph/when_to_use_langgraph.mdx", "repo_id": "agents-course", "token_count": 1720 }
7
# Pequeño Quiz (no calificado) [[quiz1]] ¡Vamos a poner a prueba tu comprensión de `smolagents` con un quiz rápido! Recuerda, ponerte a prueba ayuda a reforzar el aprendizaje e identificar áreas que pueden necesitar revisión. Este es un quiz opcional y no está calificado. ### P1: ¿Cuál es una de las principales vent...
agents-course/units/es/unit2/smolagents/quiz1.mdx/0
{ "file_path": "agents-course/units/es/unit2/smolagents/quiz1.mdx", "repo_id": "agents-course", "token_count": 2557 }
8
# Conclusión **¡Felicitaciones por terminar el Curso de Agentes!** A través de la perseverancia y la dedicación, has construido una base sólida en el mundo de los Agentes de IA. Pero terminar este curso **no es el final de tu viaje**. Es solo el comienzo: no dudes en explorar la siguiente sección donde compartimos r...
agents-course/units/es/unit4/conclusion.mdx/0
{ "file_path": "agents-course/units/es/unit4/conclusion.mdx", "repo_id": "agents-course", "token_count": 223 }
9
# Des LLM aux agents Nous avons appris dans la [première unité](https://huggingface.co/learn/agents-course/unit1/introduction) du cours que les agents sont capables de planifier et prendre des décisions. Et tandis que les LLM ont permis des interactions plus naturelles avec les PNJ, l'IA agentique va plus loin en pe...
agents-course/units/fr/bonus-unit3/from-llm-to-agents.mdx/0
{ "file_path": "agents-course/units/fr/bonus-unit3/from-llm-to-agents.mdx", "repo_id": "agents-course", "token_count": 1080 }
10
# Observer : intégrer le retour d'information pour réfléchir et s'adapter Les observations sont **la manière dont un agent perçoit les conséquences de ses actions**. Elles fournissent des informations cruciales qui alimentent le processus de réflexion de l'agent et orientent ses actions futures. Ce sont **des signau...
agents-course/units/fr/unit1/observations.mdx/0
{ "file_path": "agents-course/units/fr/unit1/observations.mdx", "repo_id": "agents-course", "token_count": 1244 }
11
# Table des matières Ce plan de chapitre LlamaIndex fait partie de l'unité 2 du cours. Vous pouvez accéder à l'unité 2 sur LlamaIndex sur hf.co/learn 👉 <a href="https://hf.co/learn/agents-course/unit2/llama-index/introduction">ici</a> | Titre | Description | | --- | --- | | [Introduction](introduction.mdx) | Introdu...
agents-course/units/fr/unit2/llama-index/README.md/0
{ "file_path": "agents-course/units/fr/unit2/llama-index/README.md", "repo_id": "agents-course", "token_count": 339 }
12
# Petit Quiz (non noté) [[quiz2]] Il est temps de tester votre compréhension des sections sur `CodeAgent`, `ToolCalling Agent` et les *Outils*. Ce quiz est optionnel et non noté. --- ### Q1 : Quelle est la différence clé entre créer un outil avec le décorateur `@tool` et créer une sous-classe de `Tool` dans smolagen...
agents-course/units/fr/unit2/smolagents/quiz2.mdx/0
{ "file_path": "agents-course/units/fr/unit2/smolagents/quiz2.mdx", "repo_id": "agents-course", "token_count": 2951 }
13
# Le projet pratique final Maintenant que vous êtes prêt à plonger plus profondément dans la création de votre agent, voyons comment vous pouvez le soumettre pour l'évaluer. ## Le jeu de données Le jeu de données utilisé pour le classement se compose de 20 questions extraites des questions de niveau 1 de la partie *...
agents-course/units/fr/unit4/hands-on.mdx/0
{ "file_path": "agents-course/units/fr/unit4/hands-on.mdx", "repo_id": "agents-course", "token_count": 1411 }
14
--- ### Q1: 에이전트(Agent)란? [[q1-what-is-an-agent]] 다음 중 AI 에이전트를 가장 잘 설명한 것은 무엇인가요? <Question choices={[ { text: "정적인 텍스트만 처리하고, 환경과 동적으로 상호작용하거나 의미 있는 행동을 수행하는 메커니즘이 없는 시스템.", explain: "에이전트는 행동을 취하고 환경과 상호작용할 수 있어야 합니다.", }, { text: "추론하고 계획을 세우며 도구를 활용하여 환경과 상호작용하여 특정 목표를 달성하는 AI 모델.", explain: "이 정의는 에이전트의 핵심 특징을 정...
agents-course/units/ko/unit1/quiz1.mdx/0
{ "file_path": "agents-course/units/ko/unit1/quiz1.mdx", "repo_id": "agents-course", "token_count": 6252 }
15
# Подготовка к работе: Ваши первые шаги ⛵ <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit0/time-to-onboard.jpg" alt="Время подняться на борт" width="100%"/> Теперь, когда у вас есть все подробности, давайте начнем! Мы сделаем четыре вещи: 1. **Создадим аккаунт Hugging Face*...
agents-course/units/ru-RU/unit0/onboarding.mdx/0
{ "file_path": "agents-course/units/ru-RU/unit0/onboarding.mdx", "repo_id": "agents-course", "token_count": 2438 }
16
# Что такое Агент? <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/whiteboard-no-check.jpg" alt="Unit 1 planning"/> К концу этого раздела вы будете чувствовать себя комфортно с концепцией агентов и их различными применениями в ИИ. Чтобы объяснить, что такое агент, давайте ...
agents-course/units/ru-RU/unit1/what-are-agents.mdx/0
{ "file_path": "agents-course/units/ru-RU/unit1/what-are-agents.mdx", "repo_id": "agents-course", "token_count": 8089 }
17
# Chương 1: Kiểm tra nhanh <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/whiteboard-unit1sub4DONE.jpg" alt="Kế hoạch chương 1"/> Chúc mừng bạn đã hoàn thành chương đầu tiên! Hãy cùng kiểm tra hiểu biết của bạn về các khái niệm chính đã học nhé. Khi vượt qua bài kiểm tra ...
agents-course/units/vi/unit1/final-quiz.mdx/0
{ "file_path": "agents-course/units/vi/unit1/final-quiz.mdx", "repo_id": "agents-course", "token_count": 1132 }
18
# 让我们为函数调用微调模型 (Let's Fine-Tune your model for function-calling) 我们现在准备好为函数调用微调我们的第一个模型了 🔥。 ## 我们如何训练模型进行函数调用? > 答案:我们需要**数据** 模型训练可以分为3个步骤: 1. **模型在大量数据上进行预训练 (pretrained)**。这一步的输出是一个**预训练模型 (pre-trained model)**。例如 [google/gemma-2-2b](https://huggingface.co/google/gemma-2-2b)。这是一个基础模型,只知道**如何预测下一个词元(token),而没有良...
agents-course/units/zh-CN/bonus-unit1/fine-tuning.mdx/0
{ "file_path": "agents-course/units/zh-CN/bonus-unit1/fine-tuning.mdx", "repo_id": "agents-course", "token_count": 2515 }
19
# 简单智能体库 (Dummy Agent Library) <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/whiteboard-unit1sub3DONE.jpg" alt="Unit 1 planning"/> 本课程是框架无关的,因为我们想要**专注于 AI 智能体(AI Agent)的概念,避免陷入特定框架的细节中**。 同时,我们希望学生能够在自己的项目中使用他们在本课程中学到的概念,使用任何他们喜欢的框架。 因此,在第一单元中,我们将使用一个简单智能体库和一个简单的无服务器 A...
agents-course/units/zh-CN/unit1/dummy-agent-library.mdx/0
{ "file_path": "agents-course/units/zh-CN/unit1/dummy-agent-library.mdx", "repo_id": "agents-course", "token_count": 6330 }
20
# 构建你的第一个 LangGraph 现在我们已经理解了基本构建模块,让我们通过构建第一个功能图来实践。我们将实现 Alfred 的邮件处理系统,他需要: 1. 阅读 incoming emails 2. 将其分类为 spam 或 legitimate 3. 为 legitimate 邮件起草初步响应 4. 当邮件合法时向 Mr. Wayne 发送信息(仅打印) 这个示例演示了如何使用 LangGraph 构建涉及基于 LLM 决策的工作流程结构。虽然这不能算是真正的 Agent(因为没有涉及工具),但本节更侧重于学习 LangGraph 框架而非 Agents。 <Tip> 你可以在 <a href="https://h...
agents-course/units/zh-CN/unit2/langgraph/first_graph.mdx/0
{ "file_path": "agents-course/units/zh-CN/unit2/langgraph/first_graph.mdx", "repo_id": "agents-course", "token_count": 6502 }
21
# 测验时间! 恭喜你完成了 `smolagents` 的学习材料!你已经取得了很多成就。现在,是时候通过一个测验来测试你的知识了。🧠 ## 说明 - 测验由代码问题组成。 - 你将得到完成代码片段的指示。 - 仔细阅读指示并相应地完成代码片段。 - 对于每个问题,你将得到结果和一些反馈。 🧘 **这个测验不计分也不提供证书**。这是关于你理解 `smolagents` 库,并了解你是否应该在书面材料上花更多时间。在接下来的单元中,你将在用例和项目中测试这些知识。 让我们开始吧! ## 测验 🚀 <iframe src="https://agents-course-unit2-smolagents-qui...
agents-course/units/zh-CN/unit2/smolagents/final_quiz.mdx/0
{ "file_path": "agents-course/units/zh-CN/unit2/smolagents/final_quiz.mdx", "repo_id": "agents-course", "token_count": 569 }
22
# 构建并集成智能体工具 节将为 Alfred 赋予网络访问能力,使其能够获取实时新闻与全球资讯。 同时还将集成天气数据和 Hugging Face Hub 模型下载统计功能,帮助其进行时效性话题交流。 ## 赋予智能体网络访问能力 请记住,我们希望 Alfred 能够展现出一位真正的文艺复兴主持人的风采,并对世界有着深刻的了解。 为此,我们需要确保 Alfred 能够获取有关世界的最新新闻和信息。 让我们从为 Alfred 创建一个网络搜索工具开始吧! <hfoptions id="agents-frameworks"> <hfoption id="smolagents"> ```python from smolag...
agents-course/units/zh-CN/unit3/agentic-rag/tools.mdx/0
{ "file_path": "agents-course/units/zh-CN/unit3/agentic-rag/tools.mdx", "repo_id": "agents-course", "token_count": 6321 }
23
# Advanced Cuda usage
candle/candle-book/src/cuda/README.md/0
{ "file_path": "candle/candle-book/src/cuda/README.md", "repo_id": "candle", "token_count": 6 }
24
#[cfg(test)] pub mod simplified; #[cfg(test)] mod tests { use anyhow::Result; use candle::{DType, Device, Tensor}; use parquet::file::reader::SerializedFileReader; // NOTE: Waiting on https://github.com/rust-lang/mdBook/pull/1856 #[rustfmt::skip] #[tokio::test] async fn book_hub_1() { // A...
candle/candle-book/src/lib.rs/0
{ "file_path": "candle/candle-book/src/lib.rs", "repo_id": "candle", "token_count": 2808 }
25
pub(crate) mod affine; pub(crate) mod conv_transpose2d; pub(crate) mod copy; pub(crate) mod matmul; pub(crate) mod qmatmul; pub(crate) mod random; pub(crate) mod reduce; pub(crate) mod unary; pub(crate) mod where_cond; use candle_core::{Device, Result}; pub(crate) trait BenchDevice { fn sync(&self) -> Result<()>;...
candle/candle-core/benches/benchmarks/mod.rs/0
{ "file_path": "candle/candle-core/benches/benchmarks/mod.rs", "repo_id": "candle", "token_count": 1142 }
26
#![allow(clippy::excessive_precision)] // Code taken from https://github.com/statrs-dev/statrs //! Provides the [error](https://en.wikipedia.org/wiki/Error_function) and //! related functions mod evaluate { //! Provides functions that don't have a numerical solution and must //! be solved computationally (e.g....
candle/candle-core/src/cpu/erf.rs/0
{ "file_path": "candle/candle-core/src/cpu/erf.rs", "repo_id": "candle", "token_count": 11974 }
27
//! Implementation of the Cuda backend when Cuda support has not been compiled in. //! #![allow(dead_code)] use crate::op::{BinaryOpT, CmpOp, ReduceOp, UnaryOpT}; use crate::{CpuStorage, DType, Error, Layout, Result, Shape}; #[derive(Debug, Clone)] pub struct CudaDevice; #[derive(Debug)] pub struct CudaStorage; macr...
candle/candle-core/src/dummy_cuda_backend.rs/0
{ "file_path": "candle/candle-core/src/dummy_cuda_backend.rs", "repo_id": "candle", "token_count": 3546 }
28
//! Support for the GGML file format. use super::{k_quants, GgmlDType, QStorage}; use crate::{Device, Result}; use byteorder::{LittleEndian, ReadBytesExt}; use std::collections::HashMap; // https://github.com/ggerganov/llama.cpp/blob/468ea24fb4633a0d681f7ac84089566c1c6190cb/llama.h#L37 #[derive(Debug, Clone, Copy, Pa...
candle/candle-core/src/quantized/ggml_file.rs/0
{ "file_path": "candle/candle-core/src/quantized/ggml_file.rs", "repo_id": "candle", "token_count": 4628 }
29
use crate::{shape::Dim, Context, Error, Result, Shape, Tensor}; impl Tensor { /// Concatenates two or more tensors along a particular dimension. /// /// All tensors must of the same rank, and the output will have /// the same rank /// /// ```rust /// # use candle_core::{Tensor, DType, Devic...
candle/candle-core/src/tensor_cat.rs/0
{ "file_path": "candle/candle-core/src/tensor_cat.rs", "repo_id": "candle", "token_count": 6379 }
30
use candle_core::{ bail, quantized::{self, GgmlDType}, test_device, test_utils::to_vec2_round, DType, Device, IndexOp, Module, Result, Tensor, }; use quantized::{k_quants, GgmlType}; use rand::prelude::*; const GGML_TEST_SIZE: usize = 32 * 128; const GGML_MAX_QUANTIZATION_TOTAL_ERROR: f32 = 0.002;...
candle/candle-core/tests/quantized_tests.rs/0
{ "file_path": "candle/candle-core/tests/quantized_tests.rs", "repo_id": "candle", "token_count": 22148 }
31
//! The MNIST hand-written digit dataset. //! //! The files can be obtained from the following link: //! <http://yann.lecun.com/exdb/mnist/> use candle::{DType, Device, Error, Result, Tensor}; use hf_hub::{api::sync::Api, Repo, RepoType}; use parquet::file::reader::{FileReader, SerializedFileReader}; use std::fs::File;...
candle/candle-datasets/src/vision/mnist.rs/0
{ "file_path": "candle/candle-datasets/src/vision/mnist.rs", "repo_id": "candle", "token_count": 2239 }
32
# candle-custom-ops This example illustrates how to implement forward and backward passes for custom operations on the CPU and GPU. The custom op in this example implements RMS normalization for the CPU and CUDA. ## Running an example ```bash $ cargo run --example custom-ops > [[ 0., 1., 2., 3., 4., 5., 6....
candle/candle-examples/examples/custom-ops/README.md/0
{ "file_path": "candle/candle-examples/examples/custom-ops/README.md", "repo_id": "candle", "token_count": 215 }
33
# candle-distilbert DistilBert is a distiled version of the Bert model. ## Sentence embeddings DistilBert is used to compute the sentence embeddings for a prompt. The model weights are downloaded from the hub on the first run. ```bash $ cargo run --example distilbert --release -- --prompt "Here is a test sentence" ...
candle/candle-examples/examples/distilbert/README.md/0
{ "file_path": "candle/candle-examples/examples/distilbert/README.md", "repo_id": "candle", "token_count": 708 }
34
# candle-flux: image generation with latent rectified flow transformers ![rusty robot holding a candle](./assets/flux-robot.jpg) Flux is a 12B rectified flow transformer capable of generating images from text descriptions, [huggingface](https://huggingface.co/black-forest-labs/FLUX.1-schnell), [github](https://github...
candle/candle-examples/examples/flux/README.md/0
{ "file_path": "candle/candle-examples/examples/flux/README.md", "repo_id": "candle", "token_count": 216 }
35
# candle-jina-bert Jina-Bert is a general large language model with a context size of 8192, [model card](https://huggingface.co/jinaai/jina-embeddings-v2-base-en). In this example it can be used for two different tasks: - Compute sentence embeddings for a prompt. - Compute similarities between a set of sentences. ##...
candle/candle-examples/examples/jina-bert/README.md/0
{ "file_path": "candle/candle-examples/examples/jina-bert/README.md", "repo_id": "candle", "token_count": 663 }
36
# candle-mamba: Mamba implementation Candle implementation of *Mamba* [1] inference only. Mamba is an alternative to the transformer architecture. It leverages State Space Models (SSMs) with the goal of being computationally efficient on long sequences. The implementation is based on [mamba.rs](https://github.com/Laur...
candle/candle-examples/examples/mamba/README.md/0
{ "file_path": "candle/candle-examples/examples/mamba/README.md", "repo_id": "candle", "token_count": 187 }
37
// This should reach 91.5% accuracy. #[cfg(feature = "mkl")] extern crate intel_mkl_src; #[cfg(feature = "accelerate")] extern crate accelerate_src; use clap::{Parser, ValueEnum}; use rand::prelude::*; use rand::rng; use candle::{DType, Result, Tensor, D}; use candle_nn::{loss, ops, Conv2d, Linear, Module, ModuleT, ...
candle/candle-examples/examples/mnist-training/main.rs/0
{ "file_path": "candle/candle-examples/examples/mnist-training/main.rs", "repo_id": "candle", "token_count": 4099 }
38
# candle-olmo: Open Language Models designed to enable the science of language models OLMo is a series of Open Language Models designed to enable the science of language models. - **Project Page:** https://allenai.org/olmo - **Papers:** [OLMo](https://arxiv.org/abs/2402.00838) [OLMo 2](https://arxiv.org/abs/2501.0065...
candle/candle-examples/examples/olmo/README.md/0
{ "file_path": "candle/candle-examples/examples/olmo/README.md", "repo_id": "candle", "token_count": 527 }
39
# pixtral Pixtral-12B is a 12B text+vision model. [Blog Post](https://mistral.ai/news/pixtral-12b/) - [HF Model Card](https://huggingface.co/mistralai/Pixtral-12B-2409) - [HF Community Model Card](https://huggingface.co/mistral-community/pixtral-12b). ```bash cargo run --profile=release-with-debug --features cuda --...
candle/candle-examples/examples/pixtral/README.md/0
{ "file_path": "candle/candle-examples/examples/pixtral/README.md", "repo_id": "candle", "token_count": 338 }
40
#[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_transformers::models::qwen2::{Config as ConfigBase, ModelForCausalLM as ModelBase}; use candle_transformers::models::qwen2_moe::{Config as Con...
candle/candle-examples/examples/qwen/main.rs/0
{ "file_path": "candle/candle-examples/examples/qwen/main.rs", "repo_id": "candle", "token_count": 5862 }
41
# This script exports pre-trained model weights in the safetensors format. import numpy as np import torch import torchvision from safetensors import torch as stt m = torchvision.models.resnet50(pretrained=True) stt.save_file(m.state_dict(), 'resnet50.safetensors') m = torchvision.models.resnet101(pretrained=True) stt...
candle/candle-examples/examples/resnet/export_models.py/0
{ "file_path": "candle/candle-examples/examples/resnet/export_models.py", "repo_id": "candle", "token_count": 166 }
42
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/snac/audio_io.rs/0
{ "file_path": "candle/candle-examples/examples/snac/audio_io.rs", "repo_id": "candle", "token_count": 4299 }
43
#[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_transformers::models::starcoder2::Model; use candle::{DType, Device, Tensor}; use candle_examples::token_output_stream::TokenOutputStream; us...
candle/candle-examples/examples/starcoder2/main.rs/0
{ "file_path": "candle/candle-examples/examples/starcoder2/main.rs", "repo_id": "candle", "token_count": 3545 }
44
use anyhow::{Context, Result}; use clap::Parser; use hf_hub::api::sync::Api; use model::VoxtralModel; mod download; mod model; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct Args { /// Run on CPU rather than on GPU. #[arg(long, default_value_t = false)] cpu: bool, ...
candle/candle-examples/examples/voxtral/main.rs/0
{ "file_path": "candle/candle-examples/examples/voxtral/main.rs", "repo_id": "candle", "token_count": 874 }
45
use std::path::PathBuf; use anyhow::{Error as E, Result}; use candle::{Device, Tensor}; use candle_nn::ops::softmax; use candle_nn::VarBuilder; use candle_transformers::models::xlm_roberta::{ Config, XLMRobertaForMaskedLM, XLMRobertaForSequenceClassification, }; use clap::{Parser, ValueEnum}; use hf_hub::{api::syn...
candle/candle-examples/examples/xlm-roberta/main.rs/0
{ "file_path": "candle/candle-examples/examples/xlm-roberta/main.rs", "repo_id": "candle", "token_count": 5543 }
46
use candle::{Result, Tensor}; // https://github.com/facebookresearch/audiocraft/blob/69fea8b290ad1b4b40d28f92d1dfc0ab01dbab85/audiocraft/data/audio_utils.py#L57 pub fn normalize_loudness( wav: &Tensor, sample_rate: u32, loudness_compressor: bool, ) -> Result<Tensor> { let energy = wav.sqr()?.mean_all()...
candle/candle-examples/src/audio.rs/0
{ "file_path": "candle/candle-examples/src/audio.rs", "repo_id": "candle", "token_count": 2409 }
47
/****************************************************************************** * Copyright (c) 2024, Tri Dao. ******************************************************************************/ #pragma once // #include "philox_unpack.cuh" // For at::cuda::philox::unpack #include <cute/tensor.hpp> #include <cutlass/c...
candle/candle-flash-attn/kernels/flash_fwd_kernel.h/0
{ "file_path": "candle/candle-flash-attn/kernels/flash_fwd_kernel.h", "repo_id": "candle", "token_count": 37133 }
48
[package] name = "candle-kernels" version = "0.9.1" edition = "2021" description = "CUDA kernels for Candle" repository = "https://github.com/huggingface/candle" keywords = ["blas", "tensor", "machine-learning"] categories = ["science"] license = "MIT OR Apache-2.0" [dependencies] [build-dependencies] bindgen_cuda =...
candle/candle-kernels/Cargo.toml/0
{ "file_path": "candle/candle-kernels/Cargo.toml", "repo_id": "candle", "token_count": 126 }
49
// 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": 1507 }
50
#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 N_SIMDWIDTH 32 // assuming SIMD group size is 32 #if defined(__HAVE_BFLOAT__) typedef matrix<bfloat, 4, 4> bfloat4x4...
candle/candle-metal-kernels/src/quantized.metal/0
{ "file_path": "candle/candle-metal-kernels/src/quantized.metal", "repo_id": "candle", "token_count": 179540 }
51
# candle-nn
candle/candle-nn/README.md/0
{ "file_path": "candle/candle-nn/README.md", "repo_id": "candle", "token_count": 5 }
52
//! Cache Implementations //! use candle::{DType, 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 ...
candle/candle-nn/src/kv_cache.rs/0
{ "file_path": "candle/candle-nn/src/kv_cache.rs", "repo_id": "candle", "token_count": 12514 }
53
#[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 }
54
## 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 }
55
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 }
56
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 }
57
//! 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 }
58
#![allow(clippy::cast_possible_truncation, clippy::cast_precision_loss)] use std::{f32::consts::PI, sync::Arc}; use candle::{ shape::Dim, CpuStorage, CustomOp1, DType, Device, Error, IndexOp, Layout, Result, Shape, Tensor, WithDType, D, }; use candle_nn::{embedding, rms_norm, Activation, Embedding, Linear, Mo...
candle/candle-transformers/src/models/deepseek2.rs/0
{ "file_path": "candle/candle-transformers/src/models/deepseek2.rs", "repo_id": "candle", "token_count": 18564 }
59
//! Gemma inference implementation. //! //! See ["Gemma: Open Models Based on Gemini Technology"](https://blog.google/technology/developers/gemma-open-ai-model/) //! //! Based on implementation from Google and PyTorch use std::sync::Arc; use candle::{DType, Device, Module, Result, Tensor, D}; use candle_nn::{linear_b...
candle/candle-transformers/src/models/gemma.rs/0
{ "file_path": "candle/candle-transformers/src/models/gemma.rs", "repo_id": "candle", "token_count": 7496 }
60
//! Marian Neural Machine Translation //! //! See "Marian: Fast Neural Machine Translation in C++" Junczys-Dowmunt et al. 2018 //! - [ACL Anthology](https://aclanthology.org/P18-4020/) //! - [Github](https://github.com/marian-nmt/marian) //! use super::with_tracing::{linear, Embedding, Linear}; use candle::{Result, Ten...
candle/candle-transformers/src/models/marian.rs/0
{ "file_path": "candle/candle-transformers/src/models/marian.rs", "repo_id": "candle", "token_count": 11295 }
61
//! Mobile CLIP model, combining a lightweight vision encoder with a text encoder //! //! A mobile-optimized CLIP implementation that uses: //! - FastViT as the vision encoder //! - OpenCLIP text encoder //! - Projection layers to align the feature spaces //! //! See model details at: //! - [FastViT](https://arxiv.org/...
candle/candle-transformers/src/models/mobileclip.rs/0
{ "file_path": "candle/candle-transformers/src/models/mobileclip.rs", "repo_id": "candle", "token_count": 1499 }
62
//! Persimmon Model //! //! A transformer language model for efficient inference and general-purpose tasks. The model uses a standard transformer architecture with: //! - Layer normalization for Q/K attention //! - RoPE embeddings with partial rotary factor //! - ReLU activation //! - Separate number of attention heads...
candle/candle-transformers/src/models/persimmon.rs/0
{ "file_path": "candle/candle-transformers/src/models/persimmon.rs", "repo_id": "candle", "token_count": 1045 }
63
//! Phi2 model implementation with quantization support. //! //! Phi2 is a 2.7B parameter language model using scaled-up Transformer decoder architecture. //! This implementation provides quantization for reduced memory and compute usage. //! //! Key characteristics: //! - Partial attention with learned mixing to reduc...
candle/candle-transformers/src/models/quantized_phi.rs/0
{ "file_path": "candle/candle-transformers/src/models/quantized_phi.rs", "repo_id": "candle", "token_count": 5545 }
64
//! RWKV v5 model implementation. //! //! The [RWKV model](https://wiki.rwkv.com/) is a recurrent neural network model //! with performance on par with transformer architectures. Several variants are //! available, candle implements the v5 and v6 versions and can be used with //! Eagle 7B([blog post](https://blog.rwkv....
candle/candle-transformers/src/models/rwkv_v5.rs/0
{ "file_path": "candle/candle-transformers/src/models/rwkv_v5.rs", "repo_id": "candle", "token_count": 8119 }
65
use candle::{Result, Tensor, D}; use candle_nn as nn; use candle_nn::Module; #[derive(Debug)] pub struct TimestepEmbedding { linear_1: nn::Linear, linear_2: nn::Linear, } impl TimestepEmbedding { // act_fn: "silu" pub fn new(vs: nn::VarBuilder, channel: usize, time_embed_dim: usize) -> Result<Self> { ...
candle/candle-transformers/src/models/stable_diffusion/embeddings.rs/0
{ "file_path": "candle/candle-transformers/src/models/stable_diffusion/embeddings.rs", "repo_id": "candle", "token_count": 1008 }
66
//! Vision Transformer (ViT) implementation. //! //! Vision Transformer applies transformer architecture to image classification //! by splitting images into patches and processing them as a sequence. //! //! Key characteristics: //! - Image patches as sequence tokens //! - Self-attention between patches //! - Position...
candle/candle-transformers/src/models/vit.rs/0
{ "file_path": "candle/candle-transformers/src/models/vit.rs", "repo_id": "candle", "token_count": 6028 }
67
use super::common::{AttnBlock, ResBlock, TimestepBlock}; use candle::{DType, Result, Tensor, D}; use candle_nn::VarBuilder; #[derive(Debug)] struct Block { res_block: ResBlock, ts_block: TimestepBlock, attn_block: AttnBlock, } #[derive(Debug)] pub struct WPrior { projection: candle_nn::Conv2d, con...
candle/candle-transformers/src/models/wuerstchen/prior.rs/0
{ "file_path": "candle/candle-transformers/src/models/wuerstchen/prior.rs", "repo_id": "candle", "token_count": 1920 }
68
use candle::{DType, Device, Tensor}; use candle_nn::VarBuilder; use candle_transformers::models::bert::{BertModel, Config}; use candle_wasm_example_bert::console_log; use tokenizers::{PaddingParams, Tokenizer}; use wasm_bindgen::prelude::*; #[wasm_bindgen] pub struct Model { bert: BertModel, tokenizer: Tokeniz...
candle/candle-wasm-examples/bert/src/bin/m.rs/0
{ "file_path": "candle/candle-wasm-examples/bert/src/bin/m.rs", "repo_id": "candle", "token_count": 1752 }
69
import init, { Model } from "./build/m.js"; async function fetchArrayBuffer(url) { const cacheName = "llama2c-candle-cache"; const cache = await caches.open(cacheName); const cachedResponse = await cache.match(url); if (cachedResponse) { const data = await cachedResponse.arrayBuffer(); return new Uint8...
candle/candle-wasm-examples/llama2-c/llama2cWorker.js/0
{ "file_path": "candle/candle-wasm-examples/llama2-c/llama2cWorker.js", "repo_id": "candle", "token_count": 1223 }
70
[package] name = "candle-wasm-example-phi" version.workspace = true edition.workspace = true description.workspace = true repository.workspace = true keywords.workspace = true categories.workspace = true license.workspace = true [dependencies] candle = { workspace = true } candle-nn = { workspace = true } candle-trans...
candle/candle-wasm-examples/phi/Cargo.toml/0
{ "file_path": "candle/candle-wasm-examples/phi/Cargo.toml", "repo_id": "candle", "token_count": 278 }
71
//load Candle Bert Module wasm module let init, ModelConditionalGeneration; async function fetchArrayBuffer(url) { const cacheName = "t5-candle-cache"; const cache = await caches.open(cacheName); const cachedResponse = await cache.match(url); if (cachedResponse) { const data = await cachedResponse.arrayBuf...
candle/candle-wasm-examples/t5/T5ModelConditionalGeneration.js/0
{ "file_path": "candle/candle-wasm-examples/t5/T5ModelConditionalGeneration.js", "repo_id": "candle", "token_count": 980 }
72
fn main() { wasm_logger::init(wasm_logger::Config::new(log::Level::Trace)); yew::Renderer::<candle_wasm_example_whisper::App>::new().render(); }
candle/candle-wasm-examples/whisper/src/bin/app.rs/0
{ "file_path": "candle/candle-wasm-examples/whisper/src/bin/app.rs", "repo_id": "candle", "token_count": 67 }
73
pub const NAMES: [&str; 80] = [ "person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck", "boat", "traffic light", "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow", ...
candle/candle-wasm-examples/yolo/src/coco_classes.rs/0
{ "file_path": "candle/candle-wasm-examples/yolo/src/coco_classes.rs", "repo_id": "candle", "token_count": 648 }
74
{ "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 }
75
{{- 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 }
76
# 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 }
77
import { publicConfigTransporter } from "$lib/utils/PublicConfig.svelte"; import type { Transport } from "@sveltejs/kit"; export const transport: Transport = { PublicConfig: publicConfigTransporter, };
chat-ui/src/hooks.ts/0
{ "file_path": "chat-ui/src/hooks.ts", "repo_id": "chat-ui", "token_count": 57 }
78
<script lang="ts" module> let isOpen = $state(false); export function closeMobileNav() { isOpen = false; } </script> <script lang="ts"> import { browser } from "$app/environment"; import { beforeNavigate } from "$app/navigation"; import { base } from "$app/paths"; import { page } from "$app/state"; import I...
chat-ui/src/lib/components/MobileNav.svelte/0
{ "file_path": "chat-ui/src/lib/components/MobileNav.svelte", "repo_id": "chat-ui", "token_count": 1778 }
79
<script lang="ts"> import { fade } from "svelte/transition"; import Portal from "./Portal.svelte"; import IconDazzled from "$lib/components/icons/IconDazzled.svelte"; interface Props { message?: string; } let { message = "" }: Props = $props(); </script> <Portal> <div transition:fade|global={{ duration: 3...
chat-ui/src/lib/components/Toast.svelte/0
{ "file_path": "chat-ui/src/lib/components/Toast.svelte", "repo_id": "chat-ui", "token_count": 337 }
80
import MarkdownRenderer from "./MarkdownRenderer.svelte"; import { render } from "vitest-browser-svelte"; import { page } from "@vitest/browser/context"; import { describe, expect, it } from "vitest"; describe("MarkdownRenderer", () => { it("renders", () => { render(MarkdownRenderer, { content: "Hello, world!" });...
chat-ui/src/lib/components/chat/MarkdownRenderer.svelte.test.ts/0
{ "file_path": "chat-ui/src/lib/components/chat/MarkdownRenderer.svelte.test.ts", "repo_id": "chat-ui", "token_count": 1558 }
81
import type { Migration } from "."; import { collections } from "$lib/server/database"; import { ObjectId, type WithId } from "mongodb"; import type { Conversation } from "$lib/types/Conversation"; import { MessageUpdateType, MessageWebSearchUpdateType, type MessageUpdate, } from "$lib/types/MessageUpdate"; import t...
chat-ui/src/lib/migrations/routines/06-trim-message-updates.ts/0
{ "file_path": "chat-ui/src/lib/migrations/routines/06-trim-message-updates.ts", "repo_id": "chat-ui", "token_count": 703 }
82
import { Elysia } from "elysia"; import { authPlugin } from "$api/authPlugin"; import { defaultModel } from "$lib/server/models"; import { collections } from "$lib/server/database"; import { authCondition } from "$lib/server/auth"; import { models, validateModel } from "$lib/server/models"; import { DEFAULT_SETTINGS, t...
chat-ui/src/lib/server/api/routes/groups/user.ts/0
{ "file_path": "chat-ui/src/lib/server/api/routes/groups/user.ts", "repo_id": "chat-ui", "token_count": 2538 }
83
import { z } from "zod"; import { config } from "$lib/server/config"; import type { Endpoint } from "../endpoints"; import type { TextGenerationStreamOutput } from "@huggingface/inference"; import type { Cohere, CohereClient } from "cohere-ai"; import { buildPrompt } from "$lib/buildPrompt"; import { ToolResultStatus, ...
chat-ui/src/lib/server/endpoints/cohere/endpointCohere.ts/0
{ "file_path": "chat-ui/src/lib/server/endpoints/cohere/endpointCohere.ts", "repo_id": "chat-ui", "token_count": 2220 }
84
import { randomUUID } from "$lib/utils/randomUuid"; import { timeout } from "$lib/utils/timeout"; import { logger } from "./logger"; type ExitHandler = () => void | Promise<void>; type ExitHandlerUnsubscribe = () => void; const listeners = new Map<string, ExitHandler>(); export function onExit(cb: ExitHandler): Exit...
chat-ui/src/lib/server/exitHandler.ts/0
{ "file_path": "chat-ui/src/lib/server/exitHandler.ts", "repo_id": "chat-ui", "token_count": 559 }
85
import pino from "pino"; import { dev } from "$app/environment"; import { config } from "$lib/server/config"; let options: pino.LoggerOptions = {}; if (dev) { options = { transport: { target: "pino-pretty", options: { colorize: true, }, }, }; } export const logger = pino({ ...options, level: confi...
chat-ui/src/lib/server/logger.ts/0
{ "file_path": "chat-ui/src/lib/server/logger.ts", "repo_id": "chat-ui", "token_count": 134 }
86