Skip to main content

PyThermoAI is a Python package that leverages intelligent agents to search the web for thermodynamic data and equations, and seamlessly integrates the results into PyThermoDB.

Project description

PyThermoAI

PyPI Downloads PyPI Version Supported Python Versions License

🚀 Introduction

PyThermoAI is an intelligent Python package that revolutionizes thermodynamic data acquisition and processing by leveraging advanced AI agents and web search capabilities. This powerful tool seamlessly integrates thermodynamic data retrieval, equation solving, and database management into a unified platform.

Built with LangGraph for creating sophisticated multi-agent workflows, PyThermoAI employs intelligent agents that can reason, plan, and execute complex thermodynamic tasks. The system utilizes Tavily as its primary web search engine, enabling agents to efficiently discover and retrieve thermodynamic data from authoritative online sources.

PyThermoAI Architecture

Key Features

  • 🤖 AI-Powered Data Agents: Intelligent agents that automatically search and retrieve thermodynamic properties from authoritative sources (NIST, DIPPR, peer-reviewed literature)
  • 💾 Database Integration: Direct connection with PyThermoDB for data storage and management, with automatic conversion of retrieved thermodynamic data into the valid PyThermoDB format

Architecture Overview

PyThermoAI consists of several interconnected components:

  • Data Agent: Searches and validates thermodynamic properties
  • Equations Agent: Solves complex thermodynamic equations
  • MCP Manager: Handles Model Context Protocol integrations allows using multiple MCP servers for enhanced functionality

📦 Installation

Install PyThermoAI using pip:

pip install pythermoai

Requirements

  • Python 3.13+
  • API keys for LLM providers (OpenAI, Anthropic, Google, etc.)
  • Tavily API key for enhanced web search capabilities

🛠️ Quick Start

1. Launch the Web Interface

from pythermoai import thermo_chat

# mcp source configuration
mcp_source = {
    "tavily-remote": {
        "command": "npx",
        "args": [
            "-y",
            "mcp-remote",
            f"https://mcp.tavily.com/mcp/?tavilyApiKey={os.getenv('TAVILY_API_KEY')}"
        ],
        "transport": "stdio",
        "env": {}
    }
}

# Launch with OpenAI GPT-4
thermo_chat(
    model_provider="openai",
    model_name="gpt-4o-mini",
    mcp_source=mcp_source,
)

2. Create an AI Agent

import asyncio
from pythermoai.agents import create_agent
from pythermoai.memory import generate_thread

async def main():
    # Create a thermodynamic data agent
    agent = await create_agent(
        model_provider="openai",
        model_name="gpt-4o-mini",
        agent_name="data-agent",
        agent_prompt="You are a thermodynamic data expert...",
        mcp_source=mcp_source
    )

    # Generate conversation thread
    config = generate_thread()

    # Query for thermodynamic properties
    result = await agent.ainvoke({
        "messages": ["Find critical properties for methane"]
    }, config=config)

    print(result)

asyncio.run(main())

3. Create a FastAPI Service

from pythermoai.api import create_api
import uvicorn

# Create API with integrated agents
app = create_api(
    model_provider="openai",
    model_name="gpt-4o-mini",
    mcp_source=mcp_source
)

# Run the server
uvicorn.run(app, host="127.0.0.1", port=8000)

📋 Examples

Retrieve Thermodynamic Properties

# Request critical properties for multiple compounds
query = """
Find the following properties for methane, ethane, and propane:
- Critical Temperature (K)
- Critical Pressure (MPa)
- Critical Volume (m³/mol)
- Molecular Weight (g/mol)
"""

# The agent will automatically search, validate, and format the data
# Output will be structured in YAML format for easy integration

Convert Data to PyThermoDB Format

query = """
These are thermodynamic data for Methane

Experimental data for CH4 (Methane)
22 02 02 11 45
Other names
Biogas; Fire damp; Marsh gas; Methane; Methyl hydride; R 50;
INChI	INChIKey	SMILES	IUPAC name
InChI=1S/CH4/h1H4	VNWKTOKETHGBQD-UHFFFAOYSA-N	C	Methane
State	Conformation
1A1	TD
Enthalpy of formation (Hfg), Entropy, Integrated heat capacity (0 K to 298.15 K) (HH), Heat Capacity (Cp)
Property	Value	Uncertainty	units	Reference	Comment
Hfg(298.15K) enthalpy of formation	-74.60	0.30	kJ mol-1	Gurvich
Hfg(0K) enthalpy of formation	-66.63	0.30	kJ mol-1	Gurvich
Entropy (298.15K) entropy	186.37	 	J K-1 mol-1	Gurvich
Integrated Heat Capacity (0 to 298.15K) integrated heat capacity	10.02	 	kJ mol-1	Gurvich
Heat Capacity (298.15K) heat capacity	35.69	 	J K-1 mol-1	Gurvich

Give me the yaml formatted data for PyThermoDB
"""

# Automated retrieval and validation from multiple sources

🔧 Advanced Configuration

MCP Server Integration

# Configure multiple MCP servers for enhanced functionality
mcp_source = {
    "tavily-remote": {
        "command": "npx",
        "args": [
            "-y",
            "mcp-remote",
            f"https://mcp.tavily.com/mcp/?tavilyApiKey={os.getenv('TAVILY_API_KEY')}"
        ],
        "transport": "stdio",
        "env": {}
    },
    "custom-mcp": {
        "command": "path/to/custom/mcp-server",
        "args": ["--option", "value"],
        "transport": "stdio",
        "env": {}
    }
}

Custom Agent Prompts

from pythermoai.agents import DATA_AGENT_PROMPT, EQUATIONS_AGENT_PROMPT

# Customize agent behavior with specialized prompts
custom_prompt = """
You are a specialized petrochemical data expert.
Focus on hydrocarbon properties and refinery applications.
Always include uncertainty estimates and data sources.
"""

📚 API Reference

Core Functions

  • thermo_chat(): Launch the complete web application
  • create_agent(): Create specialized AI agents
  • create_api(): Generate FastAPI application
  • generate_thread(): Create conversation memory threads

Supported Models

  • OpenAI: GPT-4, GPT-4o, GPT-4o-mini
  • Anthropic: Claude 3.5 Sonnet
  • Google: Gemini Pro
  • X.AI: Grok models

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request to improve the project.

📝 License

This project is licensed under the Apache License 2.0. You are free to use, modify, and distribute this software in your own applications or projects, provided that you comply with the terms of the Apache License. This includes providing proper attribution, including a copy of the license, and indicating any changes made to the original code. For more details, please refer to the LICENSE file.

❓ FAQ

For any questions, contact me on LinkedIn.

👨‍💻 Authors


Star this repository if you find it useful for your chemical engineering projects!

🐛 Report issues or 💡 suggest new features in the Issues section.

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

pythermoai-0.1.1.tar.gz (239.0 kB view details)

Uploaded Source

Built Distribution

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

pythermoai-0.1.1-py3-none-any.whl (245.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pythermoai-0.1.1.tar.gz
  • Upload date:
  • Size: 239.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.8

File hashes

Hashes for pythermoai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 53933eab3d6db8ef4f22017c48a6af3704a60201b9cc2b72a6ca56ca15530832
MD5 a7dba2891a22ab4e47f3de41b8f707a7
BLAKE2b-256 42539997ecfa6175f744da13cd93bc4676ea6310b38cf2c88eb12f1caeb5b406

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pythermoai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 245.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.8

File hashes

Hashes for pythermoai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 56d50d92c9ef3bc885a7e49b6300f404e7b0dab2e45769a52510b0a76e668d79
MD5 23fef5cfe5eb54a8c66efd674c36942c
BLAKE2b-256 84dc8037d36e13a5a007059a1907c14451ea9a0168bb612337f508bf2c7cbf90

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