MCPcopy Create free account

hub / github.com/coleam00/dark-factory-experiment / functions

Functions964 in github.com/coleam00/dark-factory-experiment

↓ 87 callersMethodexecute
(self, *args, **kwargs)
app/backend/tests/conftest.py:94
↓ 32 callersFunction_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 callersFunction_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 callersFunction_signup
(client: AsyncClient, email: str)
app/backend/tests/test_admin.py:148
↓ 16 callersFunctionuseStreamingResponse
(conversationId: string | null)
app/frontend/src/hooks/useStreamingResponse.ts:17
↓ 15 callersFunctionget_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 callersFunctionbuild_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 callersMethodfetch
(self, *args, **kwargs)
app/backend/tests/conftest.py:100
↓ 13 callersFunctionrequest
(path: string, options?: RequestInit)
app/frontend/src/lib/api.ts:125
↓ 13 callersFunctionuseConversations
(searchQuery?: string)
app/frontend/src/hooks/useConversations.ts:4
↓ 12 callersFunction_signup
( client: AsyncClient, email: str, password: str = "password123", )
app/backend/tests/test_signup_rate_limit.py:143
↓ 11 callersFunction_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 callersMethodacquire
(self)
app/backend/tests/conftest.py:133
↓ 11 callersFunctionget_pg_pool
Return the live pool. Raises if `init_pg_pool` was not called.
app/backend/db/postgres.py:68
↓ 11 callersFunctionrecall_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 callersFunction_extract_text_from_sse
Reconstruct assistant text from a list of SSE event strings.
app/backend/routes/messages.py:337
↓ 10 callersFunction_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 callersFunctionexpand_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 callersFunctionme
()
app/frontend/src/lib/authApi.ts:119
↓ 10 callersFunctionmean_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 callersFunction_chunk
(cid: str, vid: str = "v1")
app/backend/tests/test_citations.py:164
↓ 9 callersFunction_count
(db: asyncpg.Connection, outcome: str | None = None)
app/backend/tests/test_signup_rate_limit.py:161
↓ 9 callersFunction_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 callersFunctionchunk_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 callersFunctioncreate_video
( *, title: str, description: str, url: str, transcript: str, channel_id: str | None =
app/backend/db/repository.py:54
↓ 9 callersFunctionexportConversationAsMarkdown
( conversation: Conversation, messages: Message[], )
app/frontend/src/lib/exportMarkdown.ts:66
↓ 9 callersMethodfetchrow
(self, *args, **kwargs)
app/backend/tests/conftest.py:97
↓ 9 callersFunctionformatCitation
(citation: Citation)
app/frontend/src/lib/exportMarkdown.ts:21
↓ 9 callersFunctionformatTimestamp
(seconds: number)
app/frontend/src/lib/exportMarkdown.ts:14
↓ 9 callersFunctionget_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 callersFunctionmake_mock_channel_videos
Return a sync function that returns MockChannelVideosResult (SDK is sync).
app/backend/tests/test_channel_sync.py:118
↓ 8 callersFunction_add
(key: str, value: str)
scripts/transcribe_all.py:104
↓ 8 callersFunction_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 callersFunction_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 callersFunctionchunk_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 callersFunctioncreate_conversation
(*, user_id: str, title: str = "New Conversation")
app/backend/db/repository.py:418
↓ 8 callersFunctionfetch_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 callersFunctionformatTimestamp
(seconds: number)
app/frontend/src/components/CitationModal.tsx:9
↓ 8 callersFunctionget_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 callersFunctionsearch_videos_admin
Videos with chunk_count where title/description/channel_title contains substring (case-insensitive).
app/backend/db/repository.py:358
↓ 8 callersFunctionstream_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 callersFunction_new_id
()
app/backend/db/repository.py:23
↓ 7 callersFunction_parse_sources
(body: str)
app/backend/tests/test_citations.py:158
↓ 7 callersFunction_parse_timestamp
Parse a SQLite ISO timestamp string to Postgres TIMESTAMPTZ format.
app/backend/scripts/migrate_sqlite_to_pg.py:36
↓ 7 callersFunction_post_message
Post one chat message and return the SSE body. Mocks LLM + DB.
app/backend/tests/test_citations.py:97
↓ 7 callersFunction_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 callersFunctionembed_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 callersMethodfetchval
(self, *args, **kwargs)
app/backend/tests/conftest.py:103
↓ 7 callersFunctionmakeSseStream
(chunks: string[])
app/frontend/src/hooks/useStreamingResponse.test.ts:14
↓ 7 callersFunctionretrieve_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 callersFunctionuseAuth
()
app/frontend/src/hooks/useAuth.tsx:127
↓ 6 callersFunction_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 callersFunction_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 callersFunctioncompute_category_metrics
Aggregate metrics for a category.
app/backend/scripts/eval_retrieval.py:171
↓ 6 callersFunctionencode_token
Create a signed JWT for the given user UUID.
app/backend/auth/tokens.py:24
↓ 6 callersFunctionformatSources
(sources: Citation[])
app/frontend/src/lib/exportMarkdown.ts:61
↓ 6 callersFunctionmake_mock_transcript
Return a sync function that returns MockTranscriptResult (SDK is sync).
app/backend/tests/test_channel_sync.py:131
↓ 6 callersFunctionsearch_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 callersMethod_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 callersMethod_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 callersFunction_do
(c: asyncpg.Connection)
app/backend/db/users_repo.py:109
↓ 5 callersFunction_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 callersFunction_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 callersFunction_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 callersFunction_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 callersFunction_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 callersFunctionexecute_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 callersFunctionexecute_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 callersFunctionparse_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 callersFunctionrun_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 callersMethodtransaction
(self)
app/backend/tests/conftest.py:106
↓ 5 callersFunctionuseAdminVideos
(searchQuery?: string, enabled = true)
app/frontend/src/hooks/useAdminVideos.ts:4
↓ 4 callersFunction_blocks_text
Concatenate all text blocks into a single string for easy assertions.
app/backend/tests/test_system_prompt.py:16
↓ 4 callersFunction_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 callersFunction_hash_body
(body: str)
app/backend/ingest/dynamous.py:133
↓ 4 callersFunction_mock_transcript_string
Build a Transcript-like object with string content (SDK text mode).
app/backend/tests/test_video_ingest.py:119
↓ 4 callersFunction_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 callersFunction_parse_args
Parse tool arguments. Returns None on invalid JSON.
app/backend/rag/tools.py:148
↓ 4 callersFunction_run_stream_chat
( mock_create: AsyncMock, )
app/backend/tests/test_stream_chat_max_tokens.py:55
↓ 4 callersFunction_signup
(email: str = "alice@example.com", password: str = "password123")
app/backend/tests/test_rate_limit.py:187
↓ 4 callersFunctionauthRequest
(path: string, init: RequestInit)
app/frontend/src/lib/authApi.ts:71
↓ 4 callersFunctionexecute_search_keyword
Keyword-only (tsvector FTS) search.
app/backend/rag/tools.py:439
↓ 4 callersFunctionextract_cited_chunk_ids
Return the set of chunk_ids referenced via ``[c:<id>]`` markers.
app/backend/rag/citations.py:28
↓ 4 callersFunctionmockJson
(body: unknown, status = 200)
app/frontend/src/__tests__/adminApi.test.ts:13
↓ 4 callersFunctionserialize_tool_result
Convert an executor result into the `role: tool` message content.
app/backend/rag/tools.py:633
↓ 3 callersFunction_as_uuid
(user_id: UUID | str)
app/backend/db/user_messages_repo.py:22
↓ 3 callersFunction_clamp_top_k
Coerce top_k to a sane integer in [1, maximum].
app/backend/rag/tools.py:161
↓ 3 callersFunction_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 callersFunction_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 callersFunctionchunk_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 callersFunctionclose_pg_pool
Close the pool on shutdown. Idempotent.
app/backend/db/postgres.py:60
↓ 3 callersFunctioncreateSSEStream
* Create a mock ReadableStream for SSE response
app/frontend/src/__tests__/ChatArea-refreshConversationsRef.test.tsx:105
↓ 3 callersFunctiondeferredJson
(body: unknown, status = 200)
app/frontend/src/__tests__/authApi.test.ts:13
↓ 3 callersFunctiondeleteVideo
(id: string)
app/frontend/src/lib/api.ts:225
↓ 3 callersFunctionexecute_search_hybrid
Hybrid (keyword + semantic via RRF) search.
app/backend/rag/tools.py:409
↓ 3 callersFunctionexecute_search_semantic
Semantic-only (pgvector cosine) search.
app/backend/rag/tools.py:474
↓ 3 callersFunctioninit_pg_pool
Create the asyncpg pool if not already created. Idempotent.
app/backend/db/postgres.py:42
↓ 3 callersFunctionload_baseline
Load baseline metrics if present.
app/backend/scripts/eval_retrieval.py:55
↓ 3 callersFunctionload_cases
Load test cases from the fixture file.
app/backend/scripts/eval_retrieval.py:44
↓ 3 callersFunctionmakeAssistantMessage
(citation: Citation)
app/frontend/src/__tests__/ChatArea-handleCitationClick.test.tsx:98
next →1–100 of 964, ranked by callers