Skip to content

YBIGTA/26th-conference-Legent

Repository files navigation

26TH-CONFERENCE-LEGENT

Accelerate insights. Transform justice.

license last-commit repo-top-language repo-language-count

Built with the tools and technologies:

JSON Ollama Streamlit SQLAlchemy tqdm NumPy Python
Neo4j AIOHTTP pandas OpenAI Google%20Gemini Pydantic

Table of Contents


Overview


Features

Component Details
⚙️ Architecture
  • Modular design based on directories (e.g., models, data, utils)
  • Uses multiple libraries for different tasks (see Dependencies)
  • Likely uses a pipeline architecture for processing data and generating outputs
🔌 Integrations
  • Integrates with various APIs: OpenAI, Google Cloud Text-to-Speech, ChromaDB, Milvus, Neo4j, etc.
  • Uses multiple databases: MongoDB, Oracle, MySQL
  • Leverages cloud services (Google Cloud)
📦 Dependencies
  • Many dependencies across various domains (NLP, databases, cloud services, audio/video processing)
  • See requirements.txt for a full list
  • Dependency management using pip is indicated

Project Structure

└── 26th-conference-Legent/
    ├── README.md
    ├── app
    │   └── app.py
    ├── config.py
    ├── data
    │   ├── graph
    │   └── jsons
    ├── front
    │   └── app.py
    ├── legent-463917-0e7c6442775b.json
    ├── models
    │   ├── .gitignore
    │   ├── LICENSE
    │   ├── README.md
    │   ├── __init__.py
    │   ├── graph_contexts.json
    │   ├── hypergraphrag
    │   ├── requirements.txt
    │   ├── script_construct.py
    │   ├── script_query.py
    │   └── video
    ├── output
    │   ├── final_video_20250625_220626.mp4
    │   ├── final_video_20250625_234630.mp4
    │   ├── final_video_20250626_110138.mp4
    │   └── final_video_20250626_122001.mp4
    ├── preprocessing
    │   ├── document_preprocessing.py
    │   ├── testing
    │   ├── utils
    │   └── zzam_tong
    ├── requirements.txt
    ├── tts_output
    └── utils
        ├── __init__.py
        ├── accident_video_analyzer.py
        └── file_handler.py

Project Index

26TH-CONFERENCE-LEGENT/
__root__
⦿ __root__
File Name Summary
legent-463917-0e7c6442775b.json - The JSON file stores Google Cloud service account credentials
- It provides authentication information, including a private key, for a service account named legent-user within the legent-463917 Google Cloud project
- These credentials enable secure access to Google Cloud Platform services on behalf of the application using this file
- The files role is essential for secure and authorized interaction with Google Cloud resources.
requirements.txt - Requirements.txt specifies all project dependencies
- It encompasses core libraries for web application development, large language model interaction, data science, database management, media processing, natural language processing, and various utility functions
- The comprehensive list ensures the projects functionality across diverse modules.
config.py - Config.py` centralizes the applications API keys
- It securely loads sensitive credentials, namely OpenAI and Upstage API keys, from an environment file (.env), making them readily accessible to other project modules without hardcoding sensitive information directly into the source code
- This promotes secure configuration management and improves the applications portability.
front
⦿ front
File Name Summary
app.py - The front/app.py file serves as the main entry point for the user interface of the accident video analysis application
- It orchestrates the flow of video processing, from upload and analysis to report generation, leveraging other modules within the project (indicated by imports like utils and models) to handle individual tasks such as file handling, video analysis, script generation, and text-to-speech conversion
- Essentially, it glues together the backend processing components to provide a user-friendly experience.
app
⦿ app
File Name Summary
app.py - The app.py script constitutes the Streamlit applications main interface
- It provides a user-friendly web application for uploading traffic accident videos, optionally adding descriptive text
- The application processes videos using AI, generating analysis reports and, if selected, producing a stylized video summary
- The application manages user interaction, data flow, and integrates various modules for video processing and analysis.
tts_output
⦿ tts_output
File Name Summary
tts_manifest.json - The tts_manifest.json file catalogs text-to-speech (TTS) output
- It records metadata for generated audio files, including scene identification, file paths, durations, and corresponding narration scripts
- This manifest facilitates the management and retrieval of synthesized audio within the larger project, linking audio to its source text and providing essential timing information
- The files timestamp indicates generation details.
preprocessing
⦿ preprocessing
File Name Summary
document_preprocessing.py - PDF conversion to text, schema extraction to identify accident cases, and data structuring into JSON format
- The script processes a PDF, generating structured JSON data suitable for downstream analysis within the larger project.
zzam_tong
⦿ preprocessing.zzam_tong
File Name Summary
test_page.py - The script processes a JSON file containing web page data, filtering and extracting specific page content (pages 71-72)
- It uses BeautifulSoup to parse HTML, retaining relevant fields like category and HTML content
- The processed data is then saved into separate JSON files, one for each target page, within the data directory
- This contributes to the projects data preprocessing stage.
IE_negligence_ratio.py - The IE_negligence_ratio.py script processes a PDF document to extract information using the Upstage AI API
- It first generates an extraction schema from the PDF, then uses that schema to extract structured data
- The extracted information is saved as a JSON file, enabling downstream analysis or integration within a larger data processing pipeline
- The script leverages base64 encoding for efficient data handling.
test.py - The test.py script within the preprocessing/zzam_tong directory performs image-based information extraction
- It encodes a sample image as a base64 string and sends it to the Upstage AI API for processing
- The API, using a defined JSON schema, extracts specific data (in this case, the bank name) from the image and returns the result, demonstrating a component of the larger projects data preprocessing pipeline.
DP_title.py - DP_title.py extracts text from a PDF document using the Upstage AI API
- It sends the PDF to the API for OCR processing, specifically targeting table extraction
- The script then cleans and concatenates the extracted text, saving the result to a new text file within the data directory
- This function contributes to the preprocessing stage, preparing data for downstream tasks in the larger project pipeline.
utils
⦿ preprocessing.utils
File Name Summary
document_schema.py - The script processes pre-merged text blocks from a JSON file, extracting information according to a predefined JSON schema
- It uses an external API to structure the extracted data, creating a structured JSON output containing accident case details
- The structured data is then saved to a new JSON file, enhancing data organization within the negligence ratio analysis pipeline.
DP_negligence_ratio.py - The DP_negligence_ratio.py script processes PDF files containing negligence ratios
- It leverages the Upstage API for OCR and document parsing, converting the PDF into structured HTML and cleaned text formats
- Output is saved as JSON files, facilitating subsequent data analysis within the larger projects data preprocessing pipeline
- The script efficiently handles multi-page PDFs by merging and cleaning text from pairs of pages.
document_to_json.py - The document_to_json.py script processes JSON files containing accident case data
- It parses the response field of each record into a valid JSON structure, adding a parsed_response field while preserving the original data
- Records failing parsing are saved for manual review
- The script outputs a new JSON file with the parsed data, enhancing data quality for downstream analysis within the larger negligence ratio project.
models
⦿ models
File Name Summary
script_query.py - The script_query.py module facilitates accident report analysis
- It leverages a HyperGraphRAG instance to process accident data from a JSON file, augmented by a user-defined query
- The module retrieves data, constructs a query string, and returns analysis results
- This functionality integrates into a larger system for traffic accident classification and liability assessment.
script_construct.py - Script_construct.py populates a knowledge graph within the larger project
- It leverages the
HyperGraphRAG library to ingest context data from graph_contexts.json, creating a persistent knowledge base residing in the data/graph` directory
- This structured data is subsequently used by other project components for question answering or similar tasks.
requirements.txt - Requirements.txt` specifies the projects external library dependencies
- It supports various functionalities including machine learning (PyTorch, transformers), large language models (tiktoken, openai, llama), database interaction (multiple drivers), graph analysis (graspologic, networkx), and vector databases (hnswlib, pymilvus, nano-vectordb)
- These dependencies enable the broader applications core operations and integrations.
graph_contexts.json - The graph_contexts.json file stores guideline text for managing elevated blood pressure and hypertension
- It forms part of a larger projects knowledge base, providing readily accessible clinical information
- This data supports the projects goal of delivering evidence-based recommendations for healthcare professionals, facilitating improved patient care
- The content includes updated guidelines, definitions, risk assessments, and recommendations for treatment.
LICENSE - The LICENSE file specifies the MIT open-source license governing the projects code
- It grants users broad permissions to use, modify, and distribute the software, disclaiming any liability for its use
- This ensures legal clarity and facilitates collaboration within the broader software community
- The license is located within the models directory, suggesting its relevance to the projects core model components.
video
⦿ models.video
File Name Summary
phase3_script.py - The phase3_script.py file within the models/video directory uses Googles Gemini API (via the google.generativeai library) to estimate the duration of text-to-speech (TTS) output in Korean
- This functionality likely contributes to a larger video production or processing pipeline, enabling more accurate timing and scheduling within the overall video creation process
- The improved accuracy suggests this script is a later iteration, refining an existing TTS duration estimation component.
phase6_render.py - The phase6_render.py file is responsible for the final video rendering stage within a larger video processing pipeline
- It takes a processed timeline JSON file (presumably generated by a previous processing phase) and the path to the source video as input
- Using this information, it generates and saves the final rendered video to the specified output directory
- The files core function is to synthesize the video based on the instructions contained within the timeline JSON, effectively representing the culmination of the video editing process.
phase2A_timestamp.py - The phase2A_timestamp.py module processes video analysis results
- Leveraging the Gemini API, it extracts timestamps of key events from a provided analysis report
- The output is a structured JSON containing event start and end times, along with descriptions, facilitating the creation of a chronologically ordered event log for traffic accident videos within a larger video processing pipeline.
phase4_tts.py - The phase4_tts.py module generates audio narration from script data using Google Cloud Text-to-Speech
- It processes scene-based narration, creating individual MP3 files and a manifest containing audio paths, durations, and metadata
- A secondary function handles single narration text input for backward compatibility
- The module leverages Google Cloud credentials for authentication and produces output in a specified directory.
phase5_timeline.py - The phase5_timeline.py module generates a JSON timeline for video editing
- It leverages the Gemini API to intelligently determine optimal video segment start times based on provided script, TTS data, and video information
- A fallback mechanism uses even time distribution if the API is unavailable
- The output conforms to a predefined JSON schema, suitable for MoviePy, ensuring synchronization between video and audio.
hypergraphrag
⦿ models.hypergraphrag
File Name Summary
utils.py - The models/hypergraphrag/utils.py file provides utility functions for the HypergraphRAG model
- It focuses on supporting tasks such as logging, encoding/decoding text (implicitly referencing an encoder defined elsewhere), handling concurrency limitations (via UnlimitedSemaphore and concurrent_limit), and data processing (handling various data formats like CSV, JSON, and XML)
- These utilities streamline various aspects of the models operation and are crucial for its overall functionality within the larger HypergraphRAG system.
base.py - The base.py file defines base classes for various data storage components within the hypergraphrag model
- These classes, including vector, key-value, and graph storage, provide a consistent interface for data interaction, abstracting away specific implementation details
- They handle querying, upserting, and managing data, supporting different data structures and query modes.
hypergraphrag.py - Embedding generation, knowledge graph querying (kg_query), entity extraction, and LLM interaction (using functions like gpt_4o_mini_complete)
- The file leverages different storage mechanisms (defined in models/hypergraphrag/storage.py such as JsonKVStorage, NanoVectorDBStorage, and NetworkXStorage) to manage knowledge and embeddings
- In essence, this file acts as the central controller for the RAG pipeline, managing data flow and coordinating the retrieval and generation processes within the larger project.
prompt.py - The models/hypergraphrag/prompt.py file defines a set of constant strings used as prompts and delimiters within the larger HypergraphRAG model
- These prompts guide the entity extraction and relationship identification process, specifying formatting conventions (e.g., delimiters for tuples and records) and providing instructions for the models behavior
- Essentially, this file acts as a central repository for controlling the input format and instructions given to the core HypergraphRAG model during its operation.
operate.py - The models/hypergraphrag/operate.py file provides core operational functions for the HypergraphRAG model
- It leverages utility functions (defined within the same module) to handle tasks such as text chunking (based on token size), data cleaning, and encoding/decoding using TikToken
- These functions likely support the models ability to process and manage textual data efficiently for question answering or knowledge retrieval, as evidenced by the inclusion of prompt templates (PROMPTS) and data structures like TextChunkSchema
- The code interacts with other modules (indicated by imports from .base and .utils) which manage data storage (e.g., graph, key-value, vector databases) within the broader HypergraphRAG system.
llm.py - The llm.py file within the models/hypergraphrag directory provides the core Large Language Model (LLM) interaction functionality for the project
- It acts as an abstraction layer, handling communication with various LLM providers (OpenAI, Azure OpenAI, Ollama) and managing potential errors like rate limits and connection issues
- This allows the rest of the application to interact with LLMs in a consistent and robust manner, irrespective of the underlying provider.
storage.py - Storage.py` provides data persistence for the HypergraphRAG model
- It offers key-value storage, vector database functionality using NanoVectorDB for embeddings, and NetworkX graph storage
- These components facilitate efficient data management, including node and edge manipulation, embedding storage and retrieval, and graph persistence within the larger project.
kg
⦿ models.hypergraphrag.kg
File Name Summary
tidb_impl.py - The tidb_impl.py file provides a database interface for the Hypergraph RAG system, specifically utilizing TiDB as the backend database
- It acts as a crucial component within the models/hypergraphrag/kg/ module, handling data persistence and retrieval for the knowledge graph
- This allows the larger Hypergraph RAG system to store and access vector embeddings and key-value pairs efficiently within a TiDB database instance.
neo4j_impl.py - Neo4JStorage provides asynchronous interaction with a Neo4j graph database
- It handles node and edge creation, updates, retrieval, and existence checks
- The class integrates with the broader architecture by implementing the BaseGraphStorage interface, offering a persistent knowledge graph storage solution within the hypergraphrag system
- Node embeddings are supported but currently unimplemented.
chroma_impl.py - ChromaVectorDBStorage provides a vector database implementation using ChromaDB within the Hypergraph RAG project
- It handles vector storage, upsert operations, and similarity searches, leveraging asynchronous operations for efficiency
- The component integrates with a configurable embedding function and offers cosine similarity-based filtering for query results
- Persistence is managed internally by ChromaDB.
mongo_impl.py - MongoKVStorage provides a persistent key-value storage solution within the HyperGraphRAG project, leveraging MongoDB as its backend
- It facilitates efficient data access operations, including retrieval by ID, batch retrieval, filtering, and upserting
- The component integrates seamlessly with the broader systems data management strategy, ensuring reliable storage and retrieval of key-value pairs.
milvus_impl.py - MilvusVectorDBStorge provides a vector database interface for the hypergraphrag knowledge graph
- It uses Milvus to store and manage embeddings, enabling efficient similarity search
- The module handles embedding generation, batch insertion, and querying, leveraging asynchronous operations for performance
- Results are formatted for seamless integration with the broader knowledge graph system.
oracle_impl.py - The oracle_impl.py file provides a database interaction layer for the larger HypergraphRAG project, specifically using OracleDB as the knowledge graph storage backend
- It acts as an adapter, abstracting away the specifics of Oracle database communication to allow the rest of the system to interact with the knowledge graph data uniformly
- This module facilitates data retrieval and potentially storage within the Oracle database, contributing to the overall knowledge graph management capabilities of the HypergraphRAG system.
utils
⦿ utils
File Name Summary
accident_video_analyzer.py - AccidentVideoAnalyzer processes traffic accident videos to produce structured JSON reports
- Leveraging Google Geminis capabilities, it analyzes video content, identifying key details like involved parties, actions, and violations, according to a predefined workflow and strict guidelines
- The resulting JSON facilitates objective accident reconstruction and liability assessment
- Error handling and file management are incorporated.
file_handler.py - File_handler.py` manages temporary video storage within the application
- It provides functions to save uploaded videos to temporary files, returning their paths for processing elsewhere in the system
- A cleanup function ensures these temporary files are deleted after use, preventing unnecessary disk space consumption
- This module supports the applications core video processing workflow.

Getting Started

Prerequisites

This project requires the following dependencies:

  • Programming Language: Python
  • Package Manager: Pip

Installation

Build 26th-conference-Legent from the source and intsall dependencies:

  1. Clone the repository:

    ❯ git clone https://github.com/YBIGTA/26th-conference-Legent
  2. Navigate to the project directory:

    cd 26th-conference-Legent
  3. Install the dependencies:

<!-- [![pip][pip-shield]][pip-link] -->
<!-- REFERENCE LINKS -->
<!-- [pip-shield]: https://img.shields.io/badge/Pip-3776AB.svg?style={badge_style}&logo=pypi&logoColor=white -->
<!-- [pip-link]: https://pypi.org/project/pip/ -->

**Using [pip](https://pypi.org/project/pip/):**

```sh
❯ pip install -r requirements.txt, models/requirements.txt
```

Usage

Run the project with:

Using pip:

python {entrypoint}

Testing

26th-conference-legent uses the {test_framework} test framework. Run the test suite with:

Using pip:

pytest

Contributing

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your github account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone https://github.com/YBIGTA/26th-conference-Legent
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to github: Push the changes to your forked repository.
    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!

License

26th-conference-legent is protected under the LICENSE License. For more details, refer to the LICENSE file.


Acknowledgments

  • Junho Kim — Team Leader, RAG pipeline
  • Jungmook Kang — Prompt Engineering, Frontend
  • Jungyang Park — RAG Pipeline, Graph Generation
  • Haneul Park — Video Generation
  • Jaeyoung Lee — Document Parsing, Video Generation, Frontend
  • Dogeun Lee — Frontend

전체 시스템 파이프라인

graph TD
    subgraph "사용자 입력"
        U1[비디오 업로드] --> V1[Vision Model]
        V1 --> Q0[사고 설명 생성]

        U2[자연어 Query 입력] --> Q2

        Q0 --> Q2[Query 정제 LLM]
        


        Q2 --> VEC[벡터화]
        VEC --> RAG[RAG System]
        RAG --> LLM[LLM Model]

        LLM --> OUT[결과 출력 Streamlit]
    end

    subgraph "문서 파이프라인 (비동기)"
        D1[문서 업로드 or 스케줄링]
        D1 --> D2[Document Parser]
        D2 --> VDB[Pinecone 저장]
        VDB --> RAG
        D2 --> MDB[MongoDB 저장]
    end
Loading

데이터 흐름 (확장 포함)

sequenceDiagram
    participant User
    participant UI as Streamlit UI
    participant VM as Vision Model
    participant QLLM as Query 정제 LLM
    participant VEC as 벡터화
    participant RAG as RAG System
    participant LLM as LLM Model
    participant DOC as Document Parser
    participant VDB as Vector DB (Pinecone)
    participant MDB as MongoDB

    %% 사용자 입력 루트
    User->>UI: 비디오 업로드
    User->>UI: 자연어 Query 입력
    UI->>VM: Vision 모델에 비디오 전달
    VM->>QLLM: 사고 설명 생성 → Query로 정제
    UI->>QLLM: Query 정제
    
    QLLM->>VEC: 벡터화
    VEC->>RAG: 유사 사례 검색
    RAG->>LLM: 유사 사례 + Query 전달
    LLM->>UI: 최종 분석 결과 반환

    %% 문서 파이프라인 (비동기)
    User->>UI: 문서 업로드
    UI->>DOC: 문서 전달
    DOC->>VDB: 벡터화 후 저장
    DOC->>MDB: 원문 내용 저장 (Async)
    VDB->>RAG: 유사사례 검색용 인덱스 구축
Loading

About

26th-conference-Legent

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages