Skip to main content

A deep agent for extracting metrics from raw result files using LangGraph and intelligent parsing

Project description

🎯 Results Parser Agent

A powerful, intelligent agent for extracting metrics from raw result files using LangGraph and AI-powered parsing. The agent automatically analyzes unstructured result files and extracts specific metrics into structured JSON output with high accuracy.

🚀 Features

  • 🤖 AI-Powered Parsing: Uses advanced LLMs (Google Gemini, OpenAI, Anthropic, Groq, Ollama) for intelligent metric extraction
  • 📁 Flexible Input: Process single files or entire directories of result files
  • 🎯 Pattern Recognition: Automatically detects and adapts to different file formats and structures
  • ⚙️ Rich Configuration: YAML/JSON configuration with environment variable support
  • 📊 Structured Output: Direct output in Pydantic schemas for easy integration
  • 🛠️ Professional CLI: Feature-rich command-line interface with comprehensive options
  • 🔧 Python API: Easy integration into existing Python applications
  • 🔄 Error Recovery: Robust error handling and retry mechanisms

📦 Installation

Quick Install (Recommended)

pip install result-parser-agent

Development Install

# Clone the repository
git clone https://github.com/yourusername/result-parser-agent.git
cd result-parser-agent

# Install with uv (recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync
uv pip install -e .

# Or install with pip
pip install -e .

🎯 Quick Start

1. Set up your API key

# For Google Gemini (default)
export GOOGLE_API_KEY="your-google-api-key-here"

# For OpenAI
export OPENAI_API_KEY="your-openai-api-key-here"

# For Anthropic
export ANTHROPIC_API_KEY="your-anthropic-api-key-here"

# For Groq
export GROQ_API_KEY="your-groq-api-key-here"

2. Use the CLI

# Parse a directory of result files
result-parser --dir ./benchmark_results --metrics "RPS,latency,throughput" --output results.json

# Parse a single file
result-parser --file ./specific_result.txt --metrics "accuracy,precision"

# Verbose output with debug info
result-parser --dir ./results --metrics "RPS" --verbose

# Custom output file
result-parser --file ./results.txt --metrics "throughput,latency" --output my_results.json

3. Use the Python API

from result_parser_agent import ResultsParserAgent, DEFAULT_CONFIG
import os

# Set your API key
os.environ["GOOGLE_API_KEY"] = "your-google-api-key-here"

# Initialize agent
agent = ResultsParserAgent(DEFAULT_CONFIG)

# Parse results (file or directory)
result_update = await agent.parse_results(
    input_path="./benchmark_results",  # or "./results.txt"
    metrics=["RPS", "latency", "throughput"]
)

# Output structured data
print(result_update.json(indent=2))

📋 Configuration

Configuration File Example

# config.yaml
agent:
  # LLM configuration
  llm:
    provider: "google"                  # google, openai, anthropic, groq, ollama
    model: "gemini-2.0-flash"          # Model to use
    api_key: null                       # Set to null to use environment variable
    temperature: 0.1                    # Temperature for LLM responses
    max_tokens: 4000                    # Maximum tokens for responses
  
  # Agent behavior
  max_retries: 3
  chunk_size: 2000
  timeout: 300

parsing:
  # Metrics to extract from result files
  metrics:
    - "RPS"
    - "latency"
    - "throughput"
    - "accuracy"
    - "precision"
    - "recall"
    - "f1_score"
  
  # Parsing options
  case_sensitive: false
  fuzzy_match: true
  min_confidence: 0.7

output:
  format: "json"
  pretty_print: true
  include_metadata: true

logging:
  level: "INFO"
  format: "{time} | {level} | {message}"
  file: null

Environment Variables

You can also configure the agent using environment variables:

# API Keys
export GOOGLE_API_KEY="your-google-api-key-here"
export OPENAI_API_KEY="your-openai-api-key-here"
export ANTHROPIC_API_KEY="your-anthropic-api-key-here"
export GROQ_API_KEY="your-groq-api-key-here"

# Configuration
export PARSER_AGENT__LLM__PROVIDER="google"
export PARSER_AGENT__LLM__MODEL="gemini-2.0-flash"
export PARSER_PARSING__METRICS='["RPS", "latency", "throughput"]'
export PARSER_OUTPUT__FORMAT="json"

🛠️ CLI Reference

Command Options

result-parser [OPTIONS]

Options:
  -d, --dir TEXT              Directory containing result files to parse (use --dir OR --file)
  -f, --file TEXT             Single result file to parse (use --dir OR --file)
  -m, --metrics TEXT          Comma-separated list of metrics to extract (required, e.g., 'RPS,latency,throughput')
  -o, --output PATH           Output JSON file path (default: results.json)
  -v, --verbose               Enable verbose logging
  --log-level TEXT            Logging level [default: INFO]
  --pretty-print              Pretty print JSON output [default: True]
  --no-pretty-print           Disable pretty printing
  --help                      Show this message and exit

Usage Examples

# Parse all files in a directory
result-parser --dir ./benchmark_results --metrics "RPS,latency" --output results.json

# Parse a single file
result-parser --file ./specific_result.txt --metrics "accuracy,precision"

# Verbose output for debugging
result-parser --dir ./results --metrics "RPS" --verbose

# Custom output file
result-parser --file ./results.txt --metrics "throughput,latency" --output my_results.json

# Compact JSON output
result-parser --dir ./results --metrics "accuracy" --no-pretty-print

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

result_parser_agent-0.1.1.tar.gz (129.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

result_parser_agent-0.1.1-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file result_parser_agent-0.1.1.tar.gz.

File metadata

  • Download URL: result_parser_agent-0.1.1.tar.gz
  • Upload date:
  • Size: 129.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for result_parser_agent-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6641ee4bfe82f5971ba91c8d5b66161a4da73b885aff2cdb63bbcbe5e0ac76cf
MD5 f0b946638464574a999002218b1d95cc
BLAKE2b-256 10c884fdcf2ff35fcd9e6789a74da3f311122b72a602b8f2c9d91f5e1893c1c2

See more details on using hashes here.

File details

Details for the file result_parser_agent-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for result_parser_agent-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1de21c1ddba0759baffab346050dae15bda6960b31d5404642ce3de93222fe65
MD5 e234c2b80d5a072564d03487e1a0bed0
BLAKE2b-256 e4a9dc5127c94a9373a3a5a14a14f1e093ec7cc1cfa063261a20ba440f704fa8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page