text stringlengths 185 73.3k | repo stringlengths 7 100 | path stringlengths 4 146 | language stringclasses 7
values | hash stringlengths 16 16 | score float64 7 8.5 | stars int64 0 237k |
|---|---|---|---|---|---|---|
"""
Discord channel adapter for RagLeap Core.
Receives Discord messages via webhook, answers them using the core RAG
pipeline (core.chat.ask), and sends the response back. Single-tenant:
one bot, one document set, configured entirely via .env.
"""
import os
import logging
import requests
from core.chat import ask
fr... | antonyrag/ragleap-core | channels/discord/router.py | .py | 8b3742ae6f302ccf | 7.45 | 7 |
"""
Telegram channel adapter for RagLeap Core.
Receives Telegram messages via webhook, answers them using the core RAG
pipeline (core.chat.ask), and sends the response back. Single-tenant:
one bot, one document set, configured entirely via .env.
"""
import os
import hmac
import hashlib
import logging
import requests
... | antonyrag/ragleap-core | channels/telegram/router.py | .py | 71bf37e0c20ea5ac | 7.45 | 7 |
"""
Speech-to-text and text-to-speech for the RagLeap Core voice channel.
v1 supports OpenAI Whisper (STT) and OpenAI TTS only — Deepgram and
ElevenLabs are documented as good-first-issue additions, not yet implemented.
"""
import io
import logging
import requests
logger = logging.getLogger(__name__)
OPENAI_STT_URL ... | antonyrag/ragleap-core | channels/voice/audio.py | .py | 1852e1902a0e462d | 7.45 | 7 |
"""
WhatsApp channel adapter for RagLeap Core.
Receives WhatsApp messages via Twilio or Gupshup webhooks, answers them
using the core RAG pipeline (core.chat.ask), and sends the response back.
Single-tenant: one bot, one document set, configured entirely via .env.
No workspace concept, no Manager AI, no lead capture —... | antonyrag/ragleap-core | channels/whatsapp/router.py | .py | f40977f77a26c3db | 7.45 | 7 |
"""
Chat Pipeline for RagLeap Core
Wires together: query language detection -> embedding the query -> hybrid
(dense + sparse, graph-boosted) retrieval -> answer generation (blocking
or streaming).
"""
import logging
from typing import Iterator, Optional
from core.embedding import EmbeddingService
from core.retrieval i... | antonyrag/ragleap-core | core/chat.py | .py | a90f05957dcda201 | 7.45 | 7 |
"""
Text Chunking Service for RagLeap Core
Adapted from RagLeap's production chunking logic — Django dependency removed,
now uses plain constructor defaults instead of settings.py.
"""
import re
from typing import List
import logging
logger = logging.getLogger(__name__)
DEFAULT_CHUNK_SIZE = 512
DEFAULT_CHUNK_OVERLAP ... | antonyrag/ragleap-core | core/chunker.py | .py | 990bc73d2eb15946 | 7.45 | 7 |
"""
Embedding Service for RagLeap Core
Uses Google Gemini embeddings (gemini-embedding-001, 3072 dimensions) —
the same embedding technology used in RagLeap's production platform.
Bring-your-own-key only: this service NEVER falls back to a shared or
system-provided key. You must supply your own GEMINI_API_KEY.
"""
imp... | antonyrag/ragleap-core | core/embedding.py | .py | 1f560093ccc8a918 | 7.45 | 7 |
"""
Owner-configurable default role per channel, plus a deterministic
intent-based override for a safe subset of customer-facing roles.
Design choice, stated plainly: automatic intent detection is
deliberately scoped to roles already marked customer-facing in their
own DEFAULT_ROLES channels config (support, sales, ma... | antonyrag/ragleap-core | core/employees/channel_roles.py | .py | 33def66bb62c5116 | 7.45 | 7 |
"""
Real outcome signal for outcome-weighted memory: tracks the last
role-based reply per (channel, chat_id) so an owner can send a quick
feedback command afterward (thumbs up/down, "helpful"/"not helpful")
that gets attributed to the correct employee_memory entries via
core.employees.learning.record_role_memory_outcom... | antonyrag/ragleap-core | core/employees/feedback.py | .py | c2c149d683797b76 | 7.45 | 7 |
"""
Single-tenant learned-memory store for AI Employees.
Same design as production's skill_context.py write path (dedupe by content
hash, importance-weighted, semantic + tag-fallback retrieval) but backed by
its own employee_memory table instead of the multi-tenant MemoryEntry system.
"""
import hashlib
import json
imp... | antonyrag/ragleap-core | core/employees/memory.py | .py | ceece1c34cd3183b | 7.45 | 7 |
"""AI Employee role CRUD — single-tenant port of production's AIEmployeeRole model."""
import json
import logging
from datetime import datetime
from typing import Dict, List, Optional
from core.employees._db import get_connection
from core.employees.defaults import DEFAULT_ROLES
logger = logging.getLogger(__name__)
... | antonyrag/ragleap-core | core/employees/roles.py | .py | fe13f1d6355edae5 | 7.45 | 7 |
"""Read path: get_role_skills / get_role_personality / get_capability_summary."""
import logging
from core.employees import memory, roles
from core.employees.defaults import ROLE_SKILL_TAGS, DEFAULT_ROLES
from core.employees._db import get_connection
logger = logging.getLogger(__name__)
def get_role_skills(role: st... | antonyrag/ragleap-core | core/employees/skills.py | .py | 38f78737935fd0cd | 7.45 | 7 |
"""
Answer Generation Service for RagLeap Core
Bring-your-own-key only — no system key, no fallback provided by RagLeap
itself. You can configure your OWN fallback chain across providers you
have keys for (see LLM_FALLBACK_PROVIDERS below).
Supports multiple LLM providers via LLM_PROVIDER env var (default: gemini).
Na... | antonyrag/ragleap-core | core/generation.py | .py | f10fd7595857d3e0 | 7.45 | 7 |
"""
Knowledge Graph Service for RagLeap Core.
Neo4j-backed entity extraction and graph traversal, layered on top of the
existing pgvector retrieval. Single-tenant: no workspace scoping needed,
all graph nodes belong to this one deployment.
Ported from RagLeap's production retrieval/graph_service.py — same entity
extr... | antonyrag/ragleap-core | core/graph.py | .py | 71835ed4895363ba | 7.45 | 7 |
"""
Document Ingestion Pipeline for RagLeap Core
Wires together: chunking -> embedding -> database storage -> knowledge graph
-> language detection.
"""
import os
import logging
import uuid
from core.chunker import TextChunker
from core.embedding import EmbeddingService
from core.graph import graph_service
from core.l... | antonyrag/ragleap-core | core/ingest.py | .py | 8d66456da212981c | 7.45 | 7 |
"""
Base classes for RagLeap Core's data source integrations.
Ported from production's api/addon_models.py + api/addon_services.py —
Django model fields replaced with a plain dataclass, Fernet encryption
kept (same library, no Django dependency), workspace scoping removed
(single-tenant).
"""
import os
import logging
f... | antonyrag/ragleap-core | core/integrations/base.py | .py | 6d88134bdf4f0555 | 7.45 | 7 |
"""
CSV connector for RagLeap Core integrations.
Content is stored directly in Postgres (data_sources.csv_content) rather
than on disk — the app container has no persistent volume mount, so a
file saved to the container filesystem would be lost on the next
`docker compose up --build`.
"""
import csv
import io
import lo... | antonyrag/ragleap-core | core/integrations/csv_connector.py | .py | 76f80c20bd58995e | 7.45 | 7 |
"""
Data source CRUD and sync orchestration for RagLeap Core integrations.
Talks directly to Postgres (plain psycopg2, matching core/ingest.py and
core/retrieval.py's pattern) rather than through an ORM.
"""
import os
import json
import logging
import uuid
from typing import Dict, Any, List, Optional
from core.integra... | antonyrag/ragleap-core | core/integrations/service.py | .py | 8291040082429579 | 7.45 | 7 |
"""
Document text extraction for RagLeap Core.
Supports .txt, .pdf, .docx — extracts plain text so core.ingest.ingest_document
can chunk/embed/store it exactly the same way regardless of source format.
"""
import io
import logging
logger = logging.getLogger(__name__)
SUPPORTED_EXTENSIONS = {".txt", ".pdf", ".docx"}
... | antonyrag/ragleap-core | core/parsers.py | .py | 36fd96a35163c670 | 7.45 | 7 |
"""
Vector Retrieval Service for RagLeap Core
Adapted from RagLeap's production pgvector cosine-distance search —
rewritten as plain SQL (psycopg2), no Django ORM, no multi-tenancy.
Supports dense (vector), sparse (Postgres full-text), and hybrid
(Reciprocal Rank Fusion of both) retrieval, optionally boosted by the
kno... | antonyrag/ragleap-core | core/retrieval.py | .py | 8cf6aaf07be4f8b6 | 7.45 | 7 |
"""
Example: Ingest a document and ask a question about it.
Prerequisites:
- RagLeap Core running locally (docker compose up --build -d)
- A .txt, .pdf, or .docx file to test with
Usage:
python examples/01_ingest_and_query.py path/to/document.txt "Your question here"
"""
import sys
import requests
API_URL = ... | antonyrag/ragleap-core | examples/01_ingest_and_query.py | .py | a676a2855d621057 | 7.45 | 7 |
"""
Example: Test a channel adapter's RAG-answering logic directly,
without needing real WhatsApp/Telegram/Discord credentials configured.
Useful for verifying document Q&A works correctly before wiring up
real webhook credentials for any channel.
Usage:
python examples/02_test_channel_directly.py <channel> <ques... | antonyrag/ragleap-core | examples/02_test_channel_directly.py | .py | 7bac006ef5de7099 | 7.95 | 7 |
"""
Audit logging for ragleap-graph (v0.6.6+), backed by Postgres.
Fully optional. If GraphIndex is constructed without an AuditConfig (or
with one that has no database_url set), no audit logging occurs and no
psycopg2 import is even attempted - this module has zero effect unless
explicitly configured.
Graceful-degra... | antonyrag/ragleap-core | packages/ragleap-graph/src/ragleap_graph/_audit.py | .py | 30dd11f287fa1f9d | 7.45 | 7 |
#!/usr/bin/env python3
"""
Seqcore Usage Examples - Real-World Scenarios
Author: Dr. Pritam Kumar Panda @ Stanford University
Run these examples to see seqcore in action with real biological data.
"""
import seqcore as sc
import numpy as np
def example_1_sequence_analysis():
"""Example 1: Analyze DNA sequences ... | pritampanda15/Seqcore | examples/usage_examples.py | .py | 2458f1d21b8fd369 | 7.5 | 9 |
"""Sequence alignment and pattern matching operations.
Provides pairwise alignment, pattern searching, and motif finding.
"""
from __future__ import annotations
import re
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any
import numpy as np
if TYPE_CHECKING:
from seqcore.core.arrays import... | pritampanda15/Seqcore | seqcore/alignment/__init__.py | .py | e466bd4017bc9bf1 | 7.5 | 9 |
"""Core biological sequence array implementations.
Provides efficient, memory-optimized storage for biological sequences
with optional GPU acceleration.
Optimized for high-performance batch operations using NumPy vectorization.
"""
from __future__ import annotations
from abc import ABC
from collections.abc import I... | pritampanda15/Seqcore | seqcore/core/arrays.py | .py | 8d08e1dcc7e950c6 | 7.5 | 9 |
"""Device management for GPU acceleration and performance controls.
Provides a unified interface for CPU/GPU device selection and
memory management.
"""
from __future__ import annotations
import time
import warnings
from contextlib import contextmanager
from typing import Any
# Global state
_current_device = "cpu"
... | pritampanda15/Seqcore | seqcore/core/device.py | .py | 114c9d8232e79f1d | 7.5 | 9 |
"""K-mer extraction and analysis operations.
Provides efficient k-mer counting, extraction, and spectrum analysis.
"""
from __future__ import annotations
from collections import Counter
from typing import TYPE_CHECKING
import numpy as np
if TYPE_CHECKING:
from seqcore.core.arrays import BioArray
def extract_... | pritampanda15/Seqcore | seqcore/core/kmers.py | .py | b1d2e862c8590bf7 | 7.5 | 9 |
"""Structure array for 3D molecular structures.
Provides efficient storage and operations for protein/nucleic acid structures.
"""
from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING
import numpy as np
if TYPE_CHECKING:
import pandas as pd
@dataclass
class At... | pritampanda15/Seqcore | seqcore/core/structure.py | .py | 095b8c9cd9870a5e | 7.5 | 9 |
"""Phylogenetic tree construction and analysis.
Provides distance-based tree building methods and tree operations.
"""
from __future__ import annotations
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any
import numpy as np
if TYPE_CHECKING:
from seqcore.core.arrays import BioArray
... | pritampanda15/Seqcore | seqcore/phylogenetics/__init__.py | .py | 5d9b39bfc997d609 | 7.5 | 9 |
"""Structural biology operations.
Provides operations for protein/nucleic acid 3D structures including
distance calculations, contact analysis, RMSD, and more.
"""
from __future__ import annotations
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any
import numpy as np
if TYPE_CHECKING:
fro... | pritampanda15/Seqcore | seqcore/structure/__init__.py | .py | 9c3fd564990f44be | 7.5 | 9 |
"""Tests for core seqcore functionality."""
import numpy as np
import pytest
class TestDNAArray:
"""Tests for DNAArray class."""
def test_single_sequence(self):
"""Test creating DNAArray from single sequence."""
from seqcore.core.arrays import DNAArray
dna = DNAArray("ACGT")
... | pritampanda15/Seqcore | tests/test_core.py | .py | 13987a9aa0e3b71e | 7 | 9 |
"""Comprehensive tests for all supported file formats.
Author: Dr. Pritam Kumar Panda @ Stanford University
"""
import os
import numpy as np
import pytest
# Get the test data directory
TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
class TestSequenceFormats:
"""Tests for sequence file formats... | pritampanda15/Seqcore | tests/test_file_formats.py | .py | 7382ed4b496f637a | 7 | 9 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""Tests for the mechanical documentation checks.
Each check is exercised against a synthetic tree rather than the repository, so
a test pins the rule instead of the state of today's docs. The repository is
covered by one end-to-end case: the hook... | fractalyze/zorch | tools/testing/lint_docs_test.py | .py | e9407f2824254fe1 | 8.06 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""Byte-oriented Fiat-Shamir transcript: the `ByteTranscript` seam and a
Merlin-over-hash duplex (`ByteHashTranscript`) parameterized by a `ByteHash`.
This is the HOST-side, byte-oriented sibling of the device-resident algebraic
`DuplexTranscript`... | fractalyze/zorch | zorch/byte_transcript.py | .py | ee47016e1342aa2a | 7.56 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""Shared Fiat-Shamir challenge-field policy."""
from __future__ import annotations
from dataclasses import dataclass
from typing import Any
import frx.numpy as fnp
from frx import Array
from zk_dtypes import efinfo
from zorch.transcript import... | fractalyze/zorch | zorch/challenge.py | .py | 272563fa50925d77 | 7.56 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""Reed-Solomon over a binary field's additive-NTT domain; implements
FoldableCode.
A binary field has no power-of-two multiplicative subgroup (the unit group's
order is odd) and `x == -x` in characteristic 2, so `ReedSolomon`'s
`(x, -x)`-conjugat... | fractalyze/zorch | zorch/coding/additive_reed_solomon.py | .py | fb8bb110d708f10e | 7.56 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""The FoldableCode seam: a LinearCode whose codewords fold round-by-round.
BaseFold-style IOPPs (FRI, BaseFold) need more than linearity from their code.
Layer `level` (length `block_len >> level`; layer 0 is the fresh codeword)
pairs entries `(j... | fractalyze/zorch | zorch/coding/foldable_code.py | .py | 830f0051ad0cbaa4 | 7.56 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""The LinearCode seam every encoding builds on.
A linear code maps a length-`message_len` message to a length-`block_len`
codeword over a single field dtype (`block_len > message_len`; the rate is
`message_len / block_len`). `encode` acts on the ... | fractalyze/zorch | zorch/coding/linear_code.py | .py | 76023ce9aec8124d | 7.56 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""The TensorCode seam: a LinearCode whose codeword coordinates are *point
evaluations* of the committed message's multilinear extension.
Ligerito recurses by reading each proximity right-hand side
`<G[s], w> = encode(w)[s]` as an eval-claim `ŵ(p_... | fractalyze/zorch | zorch/coding/tensor_code.py | .py | f2ec61347ba74ac1 | 7.56 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""Reed-Solomon encode and the FRI fold: checked against independent oracles.
The oracle never reuses the encoder. The NTT evaluation domain is recovered
straight from `lax.ntt` of an impulse (NTT(e_1)_j = w^j), then the codeword is
compared to a ... | fractalyze/zorch | zorch/coding/testing/reed_solomon_test.py | .py | 57d2c19c52998bbc | 7.06 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""The TensorCode seam, checked against an independent multilinear oracle.
The oracle shares no code with `eval_point`: it converts the message coefficients
to the hypercube-evaluation basis (`mle_coeffs_to_evals`) and evaluates that MLE
(`eval_ml... | fractalyze/zorch | zorch/coding/testing/tensor_code_test.py | .py | d71c13578bc54046 | 8.06 | 12 |
"""Module-lattice commitments beside the Merkle tree — Ajtai, and BDLOP for hiding.
The lattice counterpart of `merkle`: scheme-agnostic, with no domain
separator, no transcript, and no challenge — those belong to the consumer's
commitment scheme. What lives here is the algebra and the opening predicate:
- **Ajtai**:... | fractalyze/zorch | zorch/commit/ajtai.py | .py | 0d4266783a9ddc8c | 7.56 | 12 |
"""Layer-by-layer k-ary Merkle commitment — scheme-agnostic, on Sponge + Compression.
`commit` hashes each matrix row to a leaf digest (Sponge), then folds sibling
groups per layer (Compression, whose `arity` sets the tree's) down to a single
root, returning `(raw_root, digest_layers)` (leaf digests first, root last).... | fractalyze/zorch | zorch/commit/merkle.py | .py | ea8b5621b1cfabab | 7.56 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""SP1 single-matrix commitment (SMCS) over zorch's Merkle blocks.
Semantically SP1's ``CudaTcsProver::commit_tensors`` for one matrix of
power-of-two height: hash each row to a leaf, fold sibling pairs to a Merkle
root (zorch's ``MerkleTree`` ove... | fractalyze/zorch | zorch/commit/smcs.py | .py | 6f222ddd6879a6d7 | 7.56 | 12 |
"""Query-strided binary Merkle commitment — scheme-agnostic, on Sponge + Compression.
A plain Merkle tree pairs *adjacent* leaves (0-1, 2-3, …), so authenticating a
leaf opens one row and one sibling path. Some PCS query phases instead open a
whole *coset* of ``rows_per_query`` rows at once, and those rows sit a fixed... | fractalyze/zorch | zorch/commit/strided_merkle.py | .py | f24173ca0bfb134b | 7.56 | 12 |
"""Ajtai/BDLOP commit — roundtrip, homomorphism, and the opening predicate.
Structural correctness without goldens, like `merkle_test`: a valid opening
re-commits to the committed value, the additive homomorphism (the folding
prerequisite) is checked as algebra, and an over-bound or substituted opening
is rejected by ... | fractalyze/zorch | zorch/commit/testing/ajtai_test.py | .py | c77ec31a1ad24ce4 | 8.06 | 12 |
"""koalabear-16 Merkle stack fixture — TEST only.
The Poseidon2(koalabear-16) -> Sponge -> Compression -> MerkleTree wiring used by
merkle_test. Lives under commit/ rather than next to the permutation fixture in
`zorch/testkit/koalabear16.py`, so that fixture stays free of a back-dependency
on the commit layer.
"""
f... | fractalyze/zorch | zorch/commit/testing/koalabear16.py | .py | 8388d0b19717b6c9 | 7.06 | 12 |
"""MerkleTree.commit — structure, digest coherence, and open->verify roundtrip.
Correctness here is structural and does not need a golden vector: an independent
reconstruction of the root from each leaf digest plus its sibling path (using the
same compressor) must equal the committed root. Plonky3 merkle-root golden
v... | fractalyze/zorch | zorch/commit/testing/merkle_test.py | .py | a584fd1e05938a0d | 7.06 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""SMCS.commit — Merkle root + SP1 domain separator.
The raw Merkle root and the domain-separated commitment are pinned to SP1's
koalabear16 parameterization (the powers-of-two internal diagonal, distinct
from the Plonky3 instance zorch's merkle_t... | fractalyze/zorch | zorch/commit/testing/smcs_test.py | .py | 073b1193b7a8cd57 | 8.06 | 12 |
"""StridedMerkleTree.commit — plain-tree equivalence, strided structure, and an
opened-rows -> root reconstruction roundtrip.
Correctness is structural, no golden vector: rebuilding the root from one query's
opened rows (re-hashed and folded through the strided levels) plus its sibling
path must equal the committed ro... | fractalyze/zorch | zorch/commit/testing/strided_merkle_test.py | .py | cfb2e3038d8be3a0 | 8.06 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""Proof-of-work grind search: the lowest counter whose candidate passes.
One engine for every transcript's grind. Each `lax.while_loop` step tests a
`window`-wide counter batch IN PARALLEL through the caller-supplied predicate
and keeps the lowes... | fractalyze/zorch | zorch/grind.py | .py | cdf7a8e5c444cf77 | 7.56 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""The LNP challenge space `C ⊆ S_κ^{σ₋₁}` over an injected byte stream.
LNP proofs (eprint 2022/284, §2.7) draw challenges from
C = { c ∈ S_κ : σ₋₁(c) = c, ²ᵏ√‖σ₋₁(cᵏ)·cᵏ‖₁ ≤ η },
polynomials of `Z[X]/(X^d + 1)` with coefficients in `[-κ, ... | fractalyze/zorch | zorch/lnp/challenge.py | .py | 9edd44578d7736c1 | 7.56 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""Π_many — ZK opening of an ABDLOP commitment with N linear relations.
The first protocol layer of the LNP framework (eprint 2022/284, Fig. 4):
prove knowledge of `(s1, s2)` opening `t_A = A1·s1 + A2·s2` — with the
message implicitly `m = t_B − B... | fractalyze/zorch | zorch/lnp/opening.py | .py | 7cef636ac606ff57 | 7.56 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""LNP challenge space — structure, the η gate, and the byte-stream contract.
Structural correctness without goldens, like `ajtai_test`: every property the
challenge space definition states (σ₋₁-invariance, the ℓ∞ bound, the
operator-norm gate, in... | fractalyze/zorch | zorch/lnp/testing/challenge_test.py | .py | e5ea4592831d13b5 | 8.06 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""Π_eval — completeness, the constant-coefficient claim, and its soundness.
Structural correctness without goldens, like `opening_test`. The statement
this layer proves is weaker than the one below it, and the tests are built
around exactly that ... | fractalyze/zorch | zorch/lnp/testing/eval_test.py | .py | f3de609303b04cf5 | 8.06 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""The exact ℓ2 bound (Fig. 10, eq. 53) — the two evaluations it builds, and
the end-to-end proof they buy, at `E = I` and at a general affine image.
The weight here is on the *algebra*, for the reason it is one layer down: a
prove/verify round-tr... | fractalyze/zorch | zorch/lnp/testing/exact_test.py | .py | a13cf7811fa7bdfd | 7.06 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""The LNP test parameter point, and the fixtures every protocol suite
builds on it.
One definition, because the numbers below are *derived* — from Lemma
2.14-1, from the Figure-3 challenge point, from a rejection budget — and a
suite that copies ... | fractalyze/zorch | zorch/lnp/testing/lnp_fixture.py | .py | b568ca7c17acad4d | 8.06 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""Π_many opening — completeness, soundness rejections, and the FS chain.
Structural correctness without goldens, like `ajtai_test`: an honest prover's
proof verifies (the budgeted repeat loop included — at the test's repetition
rates most proofs ... | fractalyze/zorch | zorch/lnp/testing/opening_test.py | .py | e435631069982f85 | 8.06 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""Π_eval^(2) (Fig. 8) — completeness, soundness, the wire contract, and
the lift layout the whole protocol is indexed against.
Two honest statements are built here, and they are built differently on
purpose. A *relation* vanishes as a ring elemen... | fractalyze/zorch | zorch/lnp/testing/quadratic_eval_test.py | .py | 75c7defcf0f94471 | 8.06 | 12 |
# Copyright 2026 The Zorch Authors. SPDX-License-Identifier: Apache-2.0
"""Π^(2) (Fig. 6) and Π_many^(2) (Fig. 7) — completeness, soundness, and
the wire contract.
The honest statement is built the only way a quadratic one can be without
solving for a witness: pick `R2` and `r1` freely, then *define*
`r0 := −(sᵀR2s + ... | fractalyze/zorch | zorch/lnp/testing/quadratic_test.py | .py | f32571ddcfeb5d80 | 8.06 | 12 |
import numpy as np
from typing import Tuple, List, Union, Any
import bittensor
from numpy import ndarray, dtype, floating, complexfloating
U32_MAX = 4294967295
U16_MAX = 65535
def normalize_max_weight(x: np.ndarray, limit: float = 0.1) -> np.ndarray:
r"""Normalizes the numpy array x so that sum(x) = 1 and the ma... | leadpoet/leadpoet | Leadpoet/base/utils/weight_utils.py | .py | c5cfa9ef6ab646ca | 7.54 | 11 |
# Copyright © 2025 Leadpoet
import typing
import bittensor as bt
class LeadRequest(bt.Synapse):
num_leads: int
business_desc: str = ""
industry: typing.Optional[str] = ""
region: typing.Optional[str] = ""
leads: typing.Optional[typing.List[dict]] = None
def deserialize(self) -> typing.... | leadpoet/leadpoet | Leadpoet/protocol.py | .py | 136414f4f128d273 | 7.54 | 11 |
"""Compatibility helpers for Bittensor extrinsic responses."""
from __future__ import annotations
from contextlib import contextmanager
from dataclasses import dataclass
from types import SimpleNamespace
from typing import Any, Iterator
@dataclass(frozen=True)
class ExtrinsicOutcome:
"""Normalized result from a... | leadpoet/leadpoet | Leadpoet/utils/bittensor_sdk.py | .py | c76345a0572b25a9 | 7.54 | 11 |
"""
Shared hashing utilities for the lead fulfillment commit-reveal scheme.
Lives in Leadpoet/utils/ so both miners and the gateway import the same
``hash_lead()`` function — single source of truth for hash agreement.
"""
import json
import hashlib
HASH_SCHEMA_VERSION = 1
_JSON_NATIVE_TYPES = (str, int, float, bool... | leadpoet/leadpoet | Leadpoet/utils/hashing.py | .py | d8b6a77ee7ac74b0 | 7.54 | 11 |
"""
Source Provenance Validation Module
Validates lead sources against regulatory requirements:
- Checks against restricted data broker denylist
- Validates domain age (≥7 days)
- Verifies URL reachability
- Categorizes source types for compliance tracking
"""
import aiohttp
import bittensor as bt
import hashlib
impo... | leadpoet/leadpoet | Leadpoet/utils/source_provenance.py | .py | 8838ce3c911cb359 | 7.54 | 11 |
import os
import time
import requests
import jwt as pyjwt
from datetime import datetime, timedelta
from typing import Optional
import logging
import bittensor as bt
logger = logging.getLogger(__name__)
class TokenManager:
"""
Manages JWT token lifecycle for Supabase authentication.
Automatically refreshe... | leadpoet/leadpoet | Leadpoet/utils/token_manager.py | .py | 9d9c2bbaea059286 | 7.54 | 11 |
"""
Consensus calculation for distributed validator ranking.
Implements weighted consensus where each validator's ranking is weighted
by their trust value: S_lead = Σ(S_v * V_v) for all validators
"""
import bittensor as bt
from typing import List, Dict, Tuple
from collections import defaultdict
from Leadpoet.utils.ut... | leadpoet/leadpoet | Leadpoet/validator/consensus.py | .py | 8a7cac561f3f29dc | 7.54 | 11 |
"""
TEE Attestation Endpoint
This endpoint returns the TEE attestation document, which provides
cryptographic proof that the gateway is running the canonical code from GitHub.
Anyone (miners, validators, auditors) can call this endpoint to verify:
1. The attestation signature (proves it came from AWS Nitro hardware)
... | leadpoet/leadpoet | gateway/api/attest.py | .py | a05eadda4babd33e | 8.04 | 11 |
#!/usr/bin/env python3
"""Remap comment[proteomics data acquisition method] to PRIDE:0000659 policy.
Rules (see issue #31 / design 2026-08-10):
- Wrong/foreign AC → map by recognized method to recommended PRIDE NT+AC
- Valid known AC with casing/order drift → normalize to NT=<lowercase>;AC=<accession>
- Plain free-tex... | bigbio/sdrf-annotated-datasets | scripts/remap_acquisition_method.py | .py | 4e1f8c142a203ef8 | 7.5 | 9 |
import numpy as np
import torch
import torchaudio
import yaml
from utils.commons.dwt import separate_signal_dwt
from utils.commons.shc import subharmonics_correction
from .base import BaseSVC
class Svc(BaseSVC):
def __init__(
self,
svc_model_path=None,
svc_config_path=None... | castlechoi/VibE-SVC2 | inference/infer_vibesvcII.py | .py | 7aba89972f8e5c6f | 7.62 | 16 |
import numpy as np
class F0Predictor(object):
def compute_f0(self, wav, p_len):
"""
input: wav:[signal_length]
p_len:int
output: f0:[signal_length//hop_length]
"""
pass
def compute_f0_uv(self, wav, p_len):
"""
input: wav:[signal_length]
... | castlechoi/VibE-SVC2 | modules/F0Predictor/F0Predictor.py | .py | 48a0a45109ed4692 | 7.62 | 16 |
from typing import Optional, Union
try:
from typing import Literal
except Exception:
from typing_extensions import Literal
import numpy as np
import torch
import torchcrepe
from torch import nn
from torch.nn import functional as F
#from:https://github.com/fishaudio/fish-diffusion
def repeat_expand(
conte... | castlechoi/VibE-SVC2 | modules/F0Predictor/crepe.py | .py | ea2517c28a4f25a0 | 7.62 | 16 |
import sys
from functools import reduce
import librosa
import numpy as np
import torch
from torch.nn.modules.module import _addindent
from .constants import * # noqa: F403
def cycle(iterable):
while True:
for item in iterable:
yield item
def summary(model, file=sys.stdout):
def repr(m... | castlechoi/VibE-SVC2 | modules/F0Predictor/rmvpe/utils.py | .py | f1c5b8b755781020 | 7.62 | 16 |
import math
import torch
from torch import nn
from torch.nn import functional as F
import modules.commons as commons
from modules.DSConv import weight_norm_modules
from modules.modules import LayerNorm
class FFT(nn.Module):
def __init__(self, hidden_channels, filter_channels, n_heads, n_layers=1, kernel_size=1, p... | castlechoi/VibE-SVC2 | modules/attentions.py | .py | 66a0af869c21a412 | 7.62 | 16 |
import torch
def feature_loss(fmap_r, fmap_g):
loss = 0
for dr, dg in zip(fmap_r, fmap_g):
for rl, gl in zip(dr, dg):
rl = rl.float().detach()
gl = gl.float()
loss += torch.mean(torch.abs(rl - gl))
return loss * 2
def discriminator_loss(disc_real_outputs, disc_generated_outputs):
los... | castlechoi/VibE-SVC2 | modules/losses.py | .py | 947d96e530127f2c | 7.62 | 16 |
#!/usr/bin/env python3
"""Validate the component inventory and its coverage of tracked files."""
from __future__ import annotations
import argparse
import json
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
MANIFEST_PATH = ROOT / "components" / "manifest.json"
sys.p... | conorbronsdon/agent-context-os | scripts/component-manifests.py | .py | 6e68ba51ff2c054b | 7.6 | 15 |
"""Loading and provenance helpers for the Minari-derived ``.npz`` datasets
baseline orchestrators train on, shared across baseline orchestrators.
"""
from __future__ import annotations
import hashlib
import json
from pathlib import Path
import subprocess
import numpy as np
DEFAULT_DATASET_KEYS = (
"observations"... | JaimeParker/rl-garden | baselines/core/dataset.py | .py | bb0201fab7d37596 | 7.48 | 8 |
"""Reader for ``baselines/baselines.yaml``.
The manifest is the single source of truth for what's registered as a
runnable baseline (git submodule under ``3rd_party/`` + a dedicated venv +
an ``baselines/<name>/`` orchestrator) versus a read-only reference
clone. ``scripts/install_baseline.sh`` reads it through this m... | JaimeParker/rl-garden | baselines/core/manifest.py | .py | 7326260b0c23241c | 7.48 | 8 |
"""ACRLPD: Q-chunking's action-chunked RLPD (``3rd_party/qc/agents/acrlpd.py``).
Extends rl-garden's existing ``RLPD`` (itself a thin ``SAC`` extension --
ensemble critics, LayerNorm, high UTD, ``PriorDataReplayMixin``'s
ratio-mixed offline/online sampling from step 0) with action chunking:
``horizon_length`` consecut... | JaimeParker/rl-garden | rl_garden/algorithms/acrlpd.py | .py | 6dc29390d3ba0080 | 7.48 | 8 |
"""Base algorithm: seeding / logger / device / checkpoint I/O.
Minimal counterpart to SB3's ``BaseAlgorithm``. We deliberately keep this
thin so GPU-parallel specifics live in ``OffPolicyAlgorithm``.
"""
from __future__ import annotations
from abc import ABC, abstractmethod
from collections import defaultdict
from pa... | JaimeParker/rl-garden | rl_garden/algorithms/base_algorithm.py | .py | 9624ad6bb101ee1f | 7.48 | 8 |
"""Cal-QL algorithm layer.
Cal-QL extends CQL by lower-bounding OOD Q-values with Monte Carlo returns from
the replay sample. The rest of the SAC/REDQ/CQL update path is inherited from
``CQL``.
"""
from __future__ import annotations
import warnings
from typing import Any, Literal, Optional
import torch
import torch.... | JaimeParker/rl-garden | rl_garden/algorithms/calql.py | .py | 3652763830c0160d | 7.48 | 8 |
"""DAgger (Ross et al. 2011): interactive imitation learning via a
beta-mixed scripted-expert rollout that always labels the aggregated dataset
with the expert's action, alternated with BC-style retraining.
Composes two existing, unmodified pieces rather than introducing new
machinery: ``BC`` (``algorithms/bc.py``, po... | JaimeParker/rl-garden | rl_garden/algorithms/dagger.py | .py | 1f915d0d5a9e8c85 | 7.48 | 8 |
"""EDAC: SAC-N (offline SAC, large critic ensemble) plus a gradient-
diversity penalty across the ensemble.
Ported from ``3rd_party/CORL/algorithms/offline/edac.py`` (arXiv
2110.01548). ``OfflineSAC`` (``rl_garden/algorithms/offline_sac.py``)
already implements everything EDAC needs except the diversity term: full
cri... | JaimeParker/rl-garden | rl_garden/algorithms/edac.py | .py | d0f60406c9c08abb | 7.48 | 8 |
"""Generic offline-to-online (off2on) transition machinery.
``Off2OnReplayMixin`` owns every offline->online transition mechanic that is
generic across off2on algorithm families (Cal-QL, IQL, ...): offline/online
replay bookkeeping (``switch_to_online_mode``, mixed-batch sampling with a
fixed or adaptive ``offline_dat... | JaimeParker/rl-garden | rl_garden/algorithms/off2on.py | .py | 14c612a100e5b88c | 7.48 | 8 |
"""Original Cal-QL paper's own offline-to-online design, built on the shared shell.
``Off2OnCalQL`` adds no behavior on top of ``_CalQLRolloutTrainingShell``
beyond a construction-time preset: no warmup by default (unlike ``WSRL``),
offline data retained and mixed throughout online fine-tuning by default, and
the CQL/... | JaimeParker/rl-garden | rl_garden/algorithms/off2on_calql.py | .py | 28c3c7b55a8b8282 | 7.48 | 8 |
from __future__ import annotations
from typing import Any
from core.storage.base import BaseVectorStorage
from core.utils import logger
class VectorWriteBatch:
"""Coalesce vector mutations and apply the final state in one write.
Merge logic can update the same entity several times while processing a
do... | Preciso-GR/preciso-graphrag | core/storage/vector_write_batch.py | .py | 6ccac03a77722c48 | 7.42 | 6 |
from __future__ import annotations
from config import SUMMARY_MARKER
# Reason surfaced on the merge return tuple (and mirrored into the pending-summary
# queue record) when compression is needed. Preciso never compresses descriptions
# itself — see preciso_mcp/tools/pending_summaries_tool.py, which is the only path
... | Preciso-GR/preciso-graphrag | core/summary.py | .py | 4735ad3d9dd70bbc | 7.42 | 6 |
"""
reconciler.py
Reconciles multiple subagent extraction outputs into a single
unified extraction dict ready for ingestion.
Called by ingest_with_reconciliation MCP tool.
"""
import re
import time
def _normalize(name: str) -> str:
"""
Normalize entity name for comparison.
Uppercase, remove punctuation... | Preciso-GR/preciso-graphrag | ingest/reconciler.py | .py | c4b83abd10ce4194 | 7.42 | 6 |
from __future__ import annotations
from collections.abc import Mapping, Sequence
from config import GRAPH_FIELD_SEP
def namespace_source_id(
source_id: str,
document_id: str,
chunk_part_ids: Mapping[str, Sequence[str]] | None = None,
) -> str:
"""Prefix each chunk id referenced by `source_id` with `... | Preciso-GR/preciso-graphrag | ingest/transformer.py | .py | e209ba6691020776 | 7.42 | 6 |
"""
reconcile_tool.py
MCP tool: ingest_with_reconciliation
Called by orchestrator agent after all subagents finish.
Reads multiple extraction files, reconciles them into
one unified extraction, writes unified file to disk,
then runs the ingestion pipeline.
"""
import json
import re
import time
from pathlib import Pa... | Preciso-GR/preciso-graphrag | preciso_mcp/tools/reconcile_tool.py | .py | ddcfef1806f07f25 | 7.42 | 6 |
"""Deterministic offline stubs shared by the pytest suite.
Mirrors the stubs used by test/summary_merge_manual.py and
test/marker_leak_manual.py so no Ollama/network is ever required.
"""
from __future__ import annotations
import json
from config import GRAPH_FIELD_SEP, SOURCE_IDS_LIMIT_METHOD_KEEP, SUMMARY_MARKER
... | Preciso-GR/preciso-graphrag | tests/_stubs.py | .py | f4505ff9f7d6964a | 7.92 | 6 |
"""Domain heuristics moved from core/query.py into config.py (Tier 4):
comparison-query detection reads its phrase list from global_config, and the
rag_response persona is configurable with a domain-neutral default."""
from __future__ import annotations
from config import DEFAULT_YOY_SIGNAL_PHRASES, PROMPTS, build_gl... | Preciso-GR/preciso-graphrag | tests/test_query_heuristics.py | .py | 84e01463992eaa75 | 7.92 | 6 |
"""Binary sensor platform for xComfort integration with Home Assistant."""
import logging
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.hel... | javydekoning/ha-xcomfort-bridge | custom_components/xcomfort_bridge/binary_sensor.py | .py | 12a95ba6f37de0b4 | 7.63 | 17 |
"""Support for xComfort Bridge cover shades."""
import logging
from homeassistant.components.cover import (
ATTR_POSITION,
CoverDeviceClass,
CoverEntity,
CoverEntityFeature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.e... | javydekoning/ha-xcomfort-bridge | custom_components/xcomfort_bridge/cover.py | .py | f1f2c108196af379 | 7.63 | 17 |
"""Helpers for Home Assistant device registry metadata."""
from __future__ import annotations
from typing import TYPE_CHECKING
from homeassistant.helpers.device_registry import DeviceInfo
from .const import DOMAIN
from .xcomfort.constants import ComponentTypes
if TYPE_CHECKING:
from .hub import XComfortHub
... | javydekoning/ha-xcomfort-bridge | custom_components/xcomfort_bridge/device_info.py | .py | b8b90a2bde246e33 | 7.63 | 17 |
"""Helpers for safe Rx subscriptions on Home Assistant entities."""
from __future__ import annotations
from collections import defaultdict
import logging
from typing import Any
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__)
_DROP_LOG_COUNTS = {1, 2, 3, 5, 10, 25, 50, 100}
d... | javydekoning/ha-xcomfort-bridge | custom_components/xcomfort_bridge/entity_lifecycle.py | .py | 388624b4761e0d2f | 7.63 | 17 |
"""Support for xComfort buttons."""
import asyncio
import logging
from homeassistant.components.event import EventDeviceClass, EventEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.device_registry import DeviceInfo
from homea... | javydekoning/ha-xcomfort-bridge | custom_components/xcomfort_bridge/event.py | .py | 1dcb5c47390b3029 | 7.63 | 17 |
"""Class used to communicate with xComfort bridge."""
from __future__ import annotations
import asyncio
import logging
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from .const import DOMAIN
from .xcomfort.bridge import Bridge
_LOGGER = logging.getLogger(__name__... | javydekoning/ha-xcomfort-bridge | custom_components/xcomfort_bridge/hub.py | .py | dc9d713e1604fa78 | 7.63 | 17 |
"""Support for xComfort lights."""
from functools import cached_property
import logging
from math import ceil
from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.... | javydekoning/ha-xcomfort-bridge | custom_components/xcomfort_bridge/light.py | .py | e580b5a9ba31cd36 | 7.63 | 17 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.