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 (GROQ, OpenAI, Anthropic, Google Gemini, 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 GROQ (default - recommended for speed and reliability)
export GROQ_API_KEY="your-groq-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 Google Gemini
export GOOGLE_API_KEY="your-google-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 with custom LLM
result-parser --file ./specific_result.txt --metrics "accuracy,precision" --provider openai --model gpt-4

# Use YAML configuration file
result-parser --config ./my_config.yaml --file ./results.txt --metrics "RPS,throughput"

# Override specific settings
result-parser --dir ./results --metrics "RPS" --provider groq --model llama3.1-70b-versatile --temperature 0.2

# 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, 
    get_groq_config, 
    get_openai_config,
    load_config_from_file,
    modify_config
)
import os

# Method 1: Use pre-configured provider configs
config = get_groq_config(
    model="llama3.1-8b-instant",
    metrics=["RPS", "latency", "throughput"]
)

# Method 2: Load from YAML file
config = load_config_from_file("./my_config.yaml")

# Method 3: Modify default config
config = modify_config(
    provider="openai",
    model="gpt-4",
    temperature=0.2,
    metrics=["accuracy", "precision", "recall"]
)

# Initialize agent
agent = ResultsParserAgent(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: "groq"                    # groq, openai, anthropic, google, ollama
    model: "llama3.1-8b-instant"        # Fast and efficient for parsing tasks
    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.2.1.tar.gz (132.5 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.2.1-py3-none-any.whl (30.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: result_parser_agent-0.2.1.tar.gz
  • Upload date:
  • Size: 132.5 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.2.1.tar.gz
Algorithm Hash digest
SHA256 35e27895c6df3b198c9de3be48b5e86db825097eac489feef9346f718abf6a53
MD5 27571212b2b8be79f0c6b9d69b1bf174
BLAKE2b-256 b34f0cffb0a95886e33181a525a987229da1d8ab7150054f2942212f9f21c92f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for result_parser_agent-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a06e5cccccac5930a58e53a4ca7aa82d13dc96d7d0eca5a175e2827866386a03
MD5 083e5aea935ae0d93c502e8143a8a93b
BLAKE2b-256 8f09b12473f95ecaa6c4d65926d1bb35e38d01feea2348dbcd25f795ca6f2474

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