π Quick StartΒΆ
Get up and running with Ryoma in under 5 minutes! This guide covers the essentials to start analyzing data with AI.
π PrerequisitesΒΆ
Python 3.9+ - Ryoma requires Python 3.9 or higher
API Key - OpenAI API key or other supported LLM provider
Database (optional) - PostgreSQL, MySQL, SQLite, or other supported databases
π¦ InstallationΒΆ
Basic InstallationΒΆ
pip install ryoma_ai
With Database SupportΒΆ
# PostgreSQL support
pip install ryoma_ai[postgres]
# Snowflake support
pip install ryoma_ai[snowflake]
# All database connectors
pip install ryoma_ai[all]
π― Quick Start OptionsΒΆ
Option 1: CLI InterfaceΒΆ
The fastest way to get started:
# Set your API key
export OPENAI_API_KEY="your-api-key-here"
# Start the CLI
ryoma_ai --setup
# Or start with defaults
ryoma_ai
Then use natural language:
ryoma_ai> show me all tables in my database
ryoma_ai> what customers made purchases last month?
ryoma_ai> create a chart of sales by region
Option 2: Programmatic Usage (Recommended)ΒΆ
For integration into your applications:
from ryoma_ai import Ryoma
from ryoma_data import DataSource
# Set up data source
datasource = DataSource(
"postgres",
host="localhost",
port=5432,
database="mydb",
user="user",
password="password"
)
# Create Ryoma instance and agent
ryoma = Ryoma(datasource=datasource)
agent = ryoma.sql_agent(model="gpt-4", mode="enhanced")
# Ask questions in natural language
response = agent.stream("Show me the top 10 customers by revenue this month")
print(response)
Option 3: Pandas AgentΒΆ
For DataFrame analysis:
from ryoma_ai import Ryoma
import pandas as pd
# Create sample data
df = pd.DataFrame({
'customer_id': [1, 2, 3, 4, 5],
'revenue': [1000, 2500, 1800, 3200, 900],
'region': ['North', 'South', 'East', 'West', 'North']
})
# Create Ryoma and pandas agent
ryoma = Ryoma()
agent = ryoma.pandas_agent(model="gpt-4")
agent.add_dataframe(df, df_id="sales_data")
# Analyze with natural language
result = agent.stream("What's the average revenue by region?")
print(result)
π Advanced FeaturesΒΆ
Multiple DatasourcesΒΆ
from ryoma_ai import Ryoma
from ryoma_data import DataSource
# Create Ryoma instance
ryoma = Ryoma()
# Add multiple datasources
ryoma.add_datasource(
DataSource("postgres", host="localhost", database="sales", user="user", password="pass"),
name="sales"
)
ryoma.add_datasource(
DataSource("postgres", host="localhost", database="marketing", user="user", password="pass"),
name="marketing"
)
# Create agent (uses first datasource by default)
agent = ryoma.sql_agent(model="gpt-4", mode="enhanced")
# Query sales database
agent.stream("Show top products by revenue")
# Switch to marketing database
ryoma.set_active("marketing")
agent.stream("Show campaign performance")
Agent ModesΒΆ
# Basic mode - simple SQL generation
agent = ryoma.sql_agent(model="gpt-4", mode="basic")
# Enhanced mode - multi-step reasoning with safety validation
agent = ryoma.sql_agent(model="gpt-4", mode="enhanced")
# ReFoRCE mode - state-of-the-art with self-refinement
agent = ryoma.sql_agent(model="gpt-4", mode="reforce")
π§ ConfigurationΒΆ
Environment VariablesΒΆ
# Set your API key
export OPENAI_API_KEY="your-api-key-here"
# Optional: Configure other providers
export ANTHROPIC_API_KEY="your-anthropic-key"
β Verify InstallationΒΆ
Run this quick test to ensure everything is working:
from ryoma_ai import Ryoma
from ryoma_data import DataSource
# Create in-memory SQLite database
datasource = DataSource("sqlite", database=":memory:")
# Create Ryoma and agent
ryoma = Ryoma(datasource=datasource)
agent = ryoma.sql_agent(model="gpt-3.5-turbo", mode="basic")
print("β
Ryoma is ready to use!")
π― Next StepsΒΆ
Now that you have Ryoma running, explore these advanced features:
Database Profiling - Automatic metadata extraction
Enhanced SQL Agent - Advanced query generation
API Reference - Complete method documentation
Examples - Real-world use cases
π Need Help?ΒΆ
Documentation: docs.ryoma.dev
GitHub Issues: Report bugs or request features
Community: Join our discussions for support and tips