Skip to content

Module-level Functions Catalog

Back to README

This document lists notable module-level functions in the parrot package. Methods inside classes are covered in CLASSES.md.

Note: Summaries are derived from code/docstrings. See source for signatures and edge cases.

Core and Utilities

  • parrot/__init__.pyget_project_root() -> Path: Resolve project root.
  • parrot/conf.pyresolve_cert(crt): Resolve certificate paths.
  • parrot/utils/uv.pyinstall_uvloop(): Install uvloop if available.

Handlers and Models

  • parrot/handlers/models.pydefault_embed_model() -> dict: Default embedding model config.
  • parrot/handlers/models.pycreated_at(*args, **kwargs) -> int: Epoch milliseconds.
  • parrot/handlers/models.pycreate_bot(bot_model: BotModel, bot_class=None): Build a bot from BotModel.
  • parrot/handlers/agents/abstract.pyregister_background_task(task, request=None, done_callback=None, *args, **kwargs) -> JobRecord: Enqueue an async task through BackgroundService; returns a job record with task_id.
  • parrot/handlers/agents/abstract.pyget_task_status(task_id, request=None) -> JSONResponse: Read job status from the background tracker (Redis-backed).
  • parrot/handlers/agents/abstract.pyfind_jobs(request) -> web.Response: Find jobs for the current user using tracker attributes.

Stores

  • parrot/stores/postgres.pyvector_distance(embedding_column, vector, op): SQL expr for vector distance.

Tools and Tooling

  • parrot/tools/toolkit.pytool_schema(schema: Type[BaseModel]) -> dict: Build tool schema from Pydantic model.
  • parrot/tools/pythonrepl.pybrace_escape(text: str) -> str: Escape braces for format strings.
  • parrot/tools/pythonrepl.pysanitize_input(query: str) -> str: Sanitize input for REPL.
  • parrot/tools/pdfprint.pycount_tokens(text: str, model: str = "gpt-4") -> int: Token estimator.
  • parrot/tools/gvoice.pystrip_markdown(text: str) -> str: Remove markdown.
  • parrot/tools/gvoice.pymarkdown_to_plain(md: str) -> str: Markdown → plain text.
  • parrot/tools/querytoolkit.pyis_collection_model(structured_obj: type) -> bool
  • parrot/tools/querytoolkit.pyget_model_from_collection(collection_model: type) -> type
  • parrot/tools/nextstop/base.pyis_collection_model(structured_obj: type) -> bool
  • parrot/tools/nextstop/base.pyget_model_from_collection(collection_model: type) -> type

Handlers (HTTP)

  • parrot/handlers/chat.py — within ChatHandler.post: validates required method parameters dynamically via inspect.signature; reports required_params when missing. Accepts query, search_type, return_sources, optional llm and model.

Agents & Background Jobs

  • parrot/handlers/agents/abstract.pyregister_background_task(...) -> JobRecord: Enqueue async tasks via BackgroundService.
  • parrot/handlers/agents/abstract.pyget_task_status(task_id, request=None) -> JSONResponse: Read job status from Redis tracker.
  • parrot/handlers/agents/abstract.pyfind_jobs(request) -> web.Response: Find jobs by tracker attributes.

DB Agents Factories

NextStop Helpers

  • resources/nextstop/handler.pyopen_prompt(prompt_file) -> str: Read a prompt file for the agent.
  • resources/nextstop/handler.pyask_agent(query=None, prompt_file=None, *args, **kwargs) -> Tuple[AgentResponse, AIMessage]: Execute the agent conversation and return structured response.
  • resources/nextstop/handler.py_generate_report(response) -> NextStopResponse: Produce transcript, PDF, and podcast; fill response metadata.

  • parrot/bots/db/sqlagent.pycreate_sql_agent(...) -> SQLDbAgent: SQL agent factory.

  • parrot/bots/db/elastic.pycreate_elasticsearch_agent(...) -> ElasticDbAgent: Elasticsearch agent factory.
  • parrot/bots/db/influx.pycreate_influxdb_agent(...) -> InfluxDBAgent: InfluxDB agent factory.
  • parrot/bots/db/multi.pyintegrate_with_parrot_bot(bot, database_configs) -> None: Compose DB capabilities into a bot.

Loaders and Media Helpers

  • parrot/loaders/youtube.pyextract_video_id(url: str) -> Optional[str]
  • parrot/loaders/basevideo.pyextract_video_id(url)
  • parrot/loaders/videolocal.pysplit_text(text, max_length)

Interfaces and Plugins

  • parrot/interfaces/http.pybad_gateway_exception(exc): Build standardized 502 response.
  • parrot/interfaces/images/plugins/exif.py_json_safe(obj), _make_serialisable(val), get_xmp_modify_date(...)

Models helpers

  • parrot/models/agents.pycreated_at(*args, **kwargs) -> int: Epoch ms helper.

Data prompts

  • parrot/bots/data.pybrace_escape(text: str) -> str: Escape braces in data prompts.

If a function is missing, it is likely private or a method; see source modules for details.