airflow.providers.common.ai.utils.file_analysis¶
Helpers for building file-analysis prompts for LLM operators.
Attributes¶
Classes¶
Prepared prompt content and discovery metadata for the file-analysis operator. |
|
A Parquet or Avro file described for a model. |
Functions¶
|
Resolve files, normalize supported formats, and build prompt content for an LLM run. |
|
Return the codec a path's last suffix names, if this Python build can decompress it. |
|
Detect the logical file format and compression codec from a path suffix. |
|
Describe a Parquet or Avro file for a model: its schema, its first |
|
Read |
Module Contents¶
- airflow.providers.common.ai.utils.file_analysis.SUPPORTED_FILE_FORMATS: tuple[str, ...] = ('avro', 'csv', 'jpeg', 'jpg', 'json', 'log', 'md', 'parquet', 'pdf', 'png', 'txt')[source]¶
- class airflow.providers.common.ai.utils.file_analysis.FileAnalysisRequest[source]¶
Prepared prompt content and discovery metadata for the file-analysis operator.
- user_content: str | collections.abc.Sequence[pydantic_ai.messages.UserContent][source]¶
- class airflow.providers.common.ai.utils.file_analysis.ColumnarSample[source]¶
A Parquet or Avro file described for a model.
- airflow.providers.common.ai.utils.file_analysis.build_file_analysis_request(*, file_path, file_conn_id, prompt, multi_modal, max_files, max_file_size_bytes, max_total_size_bytes, max_text_chars, sample_rows)[source]¶
Resolve files, normalize supported formats, and build prompt content for an LLM run.
- airflow.providers.common.ai.utils.file_analysis.detect_compression(path)[source]¶
Return the codec a path’s last suffix names, if this Python build can decompress it.
- airflow.providers.common.ai.utils.file_analysis.detect_file_format(path)[source]¶
Detect the logical file format and compression codec from a path suffix.
- airflow.providers.common.ai.utils.file_analysis.sample_columnar_file(path, *, file_format, sample_rows, max_bytes)[source]¶
Describe a Parquet or Avro file for a model: its schema, its first
sample_rowsrows and its row count.- Raises:
LLMFileAnalysisLimitExceededError – if the file is larger than
max_bytes.
- airflow.providers.common.ai.utils.file_analysis.read_bytes(path, *, compression, max_bytes)[source]¶
Read
path, decompressing it withcompression, and refuse more thanmax_bytes.- Raises:
LLMFileAnalysisLimitExceededError – if the content is larger than
max_bytes.