Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/coleam00/dark-factory-experiment
/ functions
Functions
964 in github.com/coleam00/dark-factory-experiment
⨍
Functions
964
◇
Types & classes
150
↳
Endpoints
31
↓ 87 callers
Method
execute
(self, *args, **kwargs)
app/backend/tests/conftest.py:94
↓ 32 callers
Function
_acquire
Return the pool's acquire context manager. Callers must use it as `async with _acquire() as conn:` — NOT `async with await _acquire()`. async
app/backend/db/repository.py:38
↓ 30 callers
Function
_is_refusal
Returns True if the assistant text explicitly declines to answer because the query falls outside the video context. This check prevents
app/backend/routes/messages.py:356
↓ 18 callers
Function
_signup
(client: AsyncClient, email: str)
app/backend/tests/test_admin.py:148
↓ 16 callers
Function
useStreamingResponse
(conversationId: string | null)
app/frontend/src/hooks/useStreamingResponse.ts:17
↓ 15 callers
Function
get_transcript
Fetch a YouTube video transcript via Supadata. Args: video_id: YouTube video ID (11 characters) lang: Language code (default
app/backend/services/supadata.py:95
↓ 13 callers
Function
build_system_prompt
Build the system prompt as a list of content blocks. Returns a multi-block array suitable for ``{"role": "system", "content": [...]}``. When
app/backend/llm/openrouter.py:117
↓ 13 callers
Method
fetch
(self, *args, **kwargs)
app/backend/tests/conftest.py:100
↓ 13 callers
Function
request
(path: string, options?: RequestInit)
app/frontend/src/lib/api.ts:125
↓ 13 callers
Function
useConversations
(searchQuery?: string)
app/frontend/src/hooks/useConversations.ts:4
↓ 12 callers
Function
_signup
( client: AsyncClient, email: str, password: str = "password123", )
app/backend/tests/test_signup_rate_limit.py:143
↓ 11 callers
Function
_with_ip
Force the route's `_client_ip` helper to return a specific IP. ASGITransport's synthetic `request.client.host` is `testclient` — patching at
app/backend/tests/test_signup_rate_limit.py:151
↓ 11 callers
Method
acquire
(self)
app/backend/tests/conftest.py:133
↓ 11 callers
Function
get_pg_pool
Return the live pool. Raises if `init_pg_pool` was not called.
app/backend/db/postgres.py:68
↓ 11 callers
Function
recall_at_k
Fraction of expected video IDs present in the top-k retrieved video IDs. Duplicates in retrieved list are collapsed before checking.
app/backend/scripts/eval_retrieval.py:70
↓ 10 callers
Function
_extract_text_from_sse
Reconstruct assistant text from a list of SSE event strings.
app/backend/routes/messages.py:337
↓ 10 callers
Function
_rrf_merge
Reciprocal Rank Fusion (RRF) to merge ranked results from two retrieval methods. RRF score = Σ 1 / (k + rank_i) across all methods where
app/backend/rag/retriever_hybrid.py:164
↓ 10 callers
Function
expand_and_merge
Expand each retrieved chunk by its neighbors and merge into contiguous spans. Args: chunks: List of citation-shaped chunk dicts from
app/backend/rag/expansion.py:18
↓ 10 callers
Function
me
()
app/frontend/src/lib/authApi.ts:119
↓ 10 callers
Function
mean_reciprocal_rank
Mean of 1/rank for each expected video ID that appears in top-k. Rank is 1-indexed. If none found, 0.
app/backend/scripts/eval_retrieval.py:82
↓ 9 callers
Function
_chunk
(cid: str, vid: str = "v1")
app/backend/tests/test_citations.py:164
↓ 9 callers
Function
_count
(db: asyncpg.Connection, outcome: str | None = None)
app/backend/tests/test_signup_rate_limit.py:161
↓ 9 callers
Function
_now
Return an aware UTC datetime. All created_at / updated_at columns are TIMESTAMPTZ in Postgres. asyncpg requires a datetime.datetime for those
app/backend/db/repository.py:27
↓ 9 callers
Function
chunk_video_timestamped
Chunk timestamped transcript segments using Docling HybridChunker. Each segment already has precise start/end timestamps from the source
app/backend/rag/chunker.py:93
↓ 9 callers
Function
create_video
( *, title: str, description: str, url: str, transcript: str, channel_id: str | None =
app/backend/db/repository.py:54
↓ 9 callers
Function
exportConversationAsMarkdown
( conversation: Conversation, messages: Message[], )
app/frontend/src/lib/exportMarkdown.ts:66
↓ 9 callers
Method
fetchrow
(self, *args, **kwargs)
app/backend/tests/conftest.py:97
↓ 9 callers
Function
formatCitation
(citation: Citation)
app/frontend/src/lib/exportMarkdown.ts:21
↓ 9 callers
Function
formatTimestamp
(seconds: number)
app/frontend/src/lib/exportMarkdown.ts:14
↓ 9 callers
Function
get_video_description
Return the YouTube video description, or None if the lookup fails. Calls YouTube Data API v3 videos.list?part=snippet when YOUTUBE_API_KEY is
app/backend/services/youtube_meta.py:92
↓ 9 callers
Function
make_mock_channel_videos
Return a sync function that returns MockChannelVideosResult (SDK is sync).
app/backend/tests/test_channel_sync.py:118
↓ 8 callers
Function
_add
(key: str, value: str)
scripts/transcribe_all.py:104
↓ 8 callers
Function
_apply_per_video_cap
Limit how many chunks from any single video reach the final context. Walks chunks in their input ranking order and drops a chunk once its vid
app/backend/rag/tools.py:311
↓ 8 callers
Function
_signup_and_get_client
Create a fresh signed-in client (cookie set) for the given user.
app/backend/tests/test_conversation_scoping.py:115
↓ 8 callers
Function
chunk_video_fallback
Chunk a video using the existing plain-text chunk_video() function, then add evenly-spaced estimated timestamps. Used when no precise se
app/backend/rag/chunker.py:189
↓ 8 callers
Function
create_conversation
(*, user_id: str, title: str = "New Conversation")
app/backend/db/repository.py:418
↓ 8 callers
Function
fetch_video_for_ingest
Fetch transcript + segments + title for a YouTube URL. Args: url: Full YouTube video URL (watch, shorts, or youtu.be short form).
app/backend/services/video_ingest.py:45
↓ 8 callers
Function
formatTimestamp
(seconds: number)
app/frontend/src/components/CitationModal.tsx:9
↓ 8 callers
Function
get_video_title
Return the (video_title, channel_title) from YouTube oEmbed, or (None, None) on failure. Never raises — a missing title falls back to the caller'
app/backend/services/youtube_meta.py:57
↓ 8 callers
Function
search_videos_admin
Videos with chunk_count where title/description/channel_title contains substring (case-insensitive).
app/backend/db/repository.py:358
↓ 8 callers
Function
stream_chat
Stream a chat completion via OpenRouter. When tools + executor are supplied, execute tool calls in a loop until finish_reason=stop. All RAG r
app/backend/llm/openrouter.py:204
↓ 7 callers
Function
_new_id
()
app/backend/db/repository.py:23
↓ 7 callers
Function
_parse_sources
(body: str)
app/backend/tests/test_citations.py:158
↓ 7 callers
Function
_parse_timestamp
Parse a SQLite ISO timestamp string to Postgres TIMESTAMPTZ format.
app/backend/scripts/migrate_sqlite_to_pg.py:36
↓ 7 callers
Function
_post_message
Post one chat message and return the SSE body. Mocks LLM + DB.
app/backend/tests/test_citations.py:97
↓ 7 callers
Function
_set_circle
Patch circle.verify_paid_member. fail=True simulates Circle being down (the production verify_paid_member never raises, so we just return False
app/backend/tests/test_auth_circle.py:119
↓ 7 callers
Function
embed_batch
Embed a list of text strings via OpenRouter in a single batched API call. Args: texts: A list of strings. May be empty (returns [] i
app/backend/rag/embeddings.py:76
↓ 7 callers
Method
fetchval
(self, *args, **kwargs)
app/backend/tests/conftest.py:103
↓ 7 callers
Function
makeSseStream
(chunks: string[])
app/frontend/src/hooks/useStreamingResponse.test.ts:14
↓ 7 callers
Function
retrieve_hybrid
Hybrid retrieval via Reciprocal Rank Fusion (RRF). Args: query_text: Original user query string (used for keyword search) qu
app/backend/rag/retriever_hybrid.py:38
↓ 7 callers
Function
useAuth
()
app/frontend/src/hooks/useAuth.tsx:127
↓ 6 callers
Function
_build_tool_status_label
Build a human-readable, tool-aware label for a tool_call_start event. Search tools render the query in quotes; get_video_transcript resolves
app/backend/llm/openrouter.py:174
↓ 6 callers
Function
_migrate_table
Migrate one table: SELECT from SQLite, INSERT into Postgres. Returns the number of rows inserted.
app/backend/scripts/migrate_sqlite_to_pg.py:49
↓ 6 callers
Function
compute_category_metrics
Aggregate metrics for a category.
app/backend/scripts/eval_retrieval.py:171
↓ 6 callers
Function
encode_token
Create a signed JWT for the given user UUID.
app/backend/auth/tokens.py:24
↓ 6 callers
Function
formatSources
(sources: Citation[])
app/frontend/src/lib/exportMarkdown.ts:61
↓ 6 callers
Function
make_mock_transcript
Return a sync function that returns MockTranscriptResult (SDK is sync).
app/backend/tests/test_channel_sync.py:131
↓ 6 callers
Function
search_conversations_by_title
Return conversations owned by user where title contains substring (case-insensitive). Ported from the SQLite era: uses ILIKE in Postgres so the m
app/backend/db/repository.py:506
↓ 5 callers
Method
_collect
Drive `stream_chat` with a canned two-round flow and return emitted chunks. Round 1: model streams a single tool_call. Tool executor:
app/backend/tests/test_sse_status_events.py:74
↓ 5 callers
Method
_collect
Drive `stream_chat` end-to-end with a canned two-round flow. Round 1: model streams tool_call args (many chunks, no content). Tool ex
app/backend/tests/test_sse_heartbeat.py:72
↓ 5 callers
Function
_do
(c: asyncpg.Connection)
app/backend/db/users_repo.py:109
↓ 5 callers
Function
_embed_query
Embed a query, optionally memoizing the result within a turn. The same user turn can issue both ``search_videos`` and ``semantic_search_video
app/backend/rag/tools.py:392
↓ 5 callers
Function
_extract_youtube_id
Extract the YouTube video ID from a URL like ``https://www.youtube.com/watch?v=XXXXXXXXXXX``. Returns ``""`` if the URL is empty or doesn
app/backend/scripts/eval_retrieval.py:147
↓ 5 callers
Function
_format_search_results
Format chunks as the LLM-facing tool result text. Each chunk is prefixed with a literal ``[c:<chunk_id>]`` marker — the same form the model i
app/backend/rag/tools.py:220
↓ 5 callers
Function
_format_transcript
Render chunks as [mm:ss]-annotated transcript. If ``max_chars`` is supplied and the rendered transcript would exceed it, truncate at the last
app/backend/rag/tools.py:341
↓ 5 callers
Function
_parse_segments
Convert a body with `## [HH:MM:SS] heading` markers into segments. Each segment is `{start, end, text, heading}`. The end of a segment is the
app/backend/ingest/dynamous.py:88
↓ 5 callers
Function
execute_get_video_transcript
Full transcript of one video. video_id_whitelist guards against the model hallucinating ids; None disables the check (tests). Defense-in-dept
app/backend/rag/tools.py:508
↓ 5 callers
Function
execute_tool
Dispatch by tool name. Unknown names return an error dict so the model sees the refusal and stops calling. ``embedding_cache`` is optional pe
app/backend/rag/tools.py:600
↓ 5 callers
Function
parse_youtube_url
Extract and validate a YouTube video ID from a URL string. Args: url: A string that may be a YouTube URL. Returns: A Pa
app/backend/ingest/youtube_url.py:30
↓ 5 callers
Function
run_case
Run a single test case through the retrieval pipeline. Returns a dict with computed metrics and retrieved video IDs.
app/backend/scripts/eval_retrieval.py:102
↓ 5 callers
Method
transaction
(self)
app/backend/tests/conftest.py:106
↓ 5 callers
Function
useAdminVideos
(searchQuery?: string, enabled = true)
app/frontend/src/hooks/useAdminVideos.ts:4
↓ 4 callers
Function
_blocks_text
Concatenate all text blocks into a single string for easy assertions.
app/backend/tests/test_system_prompt.py:16
↓ 4 callers
Function
_extract_tool_subject
Extract a human-readable subject from tool arguments for status events. Returns a short string suitable for display in a "Searching: ..." indicat
app/backend/llm/openrouter.py:154
↓ 4 callers
Function
_hash_body
(body: str)
app/backend/ingest/dynamous.py:133
↓ 4 callers
Function
_mock_transcript_string
Build a Transcript-like object with string content (SDK text mode).
app/backend/tests/test_video_ingest.py:119
↓ 4 callers
Function
_normalize_chunk_shape
Project a chunk dict onto the canonical citation shape. Different retrieval paths produce slightly different dicts — hybrid retrieval adds an
app/backend/rag/tools.py:270
↓ 4 callers
Function
_parse_args
Parse tool arguments. Returns None on invalid JSON.
app/backend/rag/tools.py:148
↓ 4 callers
Function
_run_stream_chat
( mock_create: AsyncMock, )
app/backend/tests/test_stream_chat_max_tokens.py:55
↓ 4 callers
Function
_signup
(email: str = "alice@example.com", password: str = "password123")
app/backend/tests/test_rate_limit.py:187
↓ 4 callers
Function
authRequest
(path: string, init: RequestInit)
app/frontend/src/lib/authApi.ts:71
↓ 4 callers
Function
execute_search_keyword
Keyword-only (tsvector FTS) search.
app/backend/rag/tools.py:439
↓ 4 callers
Function
extract_cited_chunk_ids
Return the set of chunk_ids referenced via ``[c:<id>]`` markers.
app/backend/rag/citations.py:28
↓ 4 callers
Function
mockJson
(body: unknown, status = 200)
app/frontend/src/__tests__/adminApi.test.ts:13
↓ 4 callers
Function
serialize_tool_result
Convert an executor result into the `role: tool` message content.
app/backend/rag/tools.py:633
↓ 3 callers
Function
_as_uuid
(user_id: UUID | str)
app/backend/db/user_messages_repo.py:22
↓ 3 callers
Function
_clamp_top_k
Coerce top_k to a sane integer in [1, maximum].
app/backend/rag/tools.py:161
↓ 3 callers
Function
_expand_with_neighbors
Apply small-to-big neighbor expansion to already-normalized chunks. Wrapper that imports lazily (expansion.py pulls asyncio.gather over a DB
app/backend/rag/tools.py:290
↓ 3 callers
Function
_parse_frontmatter
Split a markdown file into (frontmatter dict, body). Tolerates simple `key: value` and `key: "quoted value"` pairs. Numeric values stay as st
app/backend/ingest/dynamous.py:64
↓ 3 callers
Function
chunk_video
Chunk a video's transcript using Docling HybridChunker. Args: video: A dict with at minimum 'title' and 'transcript' keys. Retu
app/backend/rag/chunker.py:29
↓ 3 callers
Function
close_pg_pool
Close the pool on shutdown. Idempotent.
app/backend/db/postgres.py:60
↓ 3 callers
Function
createSSEStream
* Create a mock ReadableStream for SSE response
app/frontend/src/__tests__/ChatArea-refreshConversationsRef.test.tsx:105
↓ 3 callers
Function
deferredJson
(body: unknown, status = 200)
app/frontend/src/__tests__/authApi.test.ts:13
↓ 3 callers
Function
deleteVideo
(id: string)
app/frontend/src/lib/api.ts:225
↓ 3 callers
Function
execute_search_hybrid
Hybrid (keyword + semantic via RRF) search.
app/backend/rag/tools.py:409
↓ 3 callers
Function
execute_search_semantic
Semantic-only (pgvector cosine) search.
app/backend/rag/tools.py:474
↓ 3 callers
Function
init_pg_pool
Create the asyncpg pool if not already created. Idempotent.
app/backend/db/postgres.py:42
↓ 3 callers
Function
load_baseline
Load baseline metrics if present.
app/backend/scripts/eval_retrieval.py:55
↓ 3 callers
Function
load_cases
Load test cases from the fixture file.
app/backend/scripts/eval_retrieval.py:44
↓ 3 callers
Function
makeAssistantMessage
(citation: Citation)
app/frontend/src/__tests__/ChatArea-handleCitationClick.test.tsx:98
next →
1–100 of 964, ranked by callers