UltraGPT: A modular library for advanced GPT-based reasoning and step pipelines
Project description
🤖 UltraGPT
A powerful and modular library for advanced GPT-based reasoning and step pipelines
🌟 Features
-
📝 Steps Pipeline: Break down complex tasks into manageable steps
- Automatic step generation and processing
- Verification at each step
- Detailed progress tracking
-
🧠 Reasoning Pipeline: Advanced reasoning capabilities
- Multi-iteration thought process
- Building upon previous reasoning
- Comprehensive analysis
-
🛠️ Tool Integration:
- Web search (Google Custom Search API, with scraping)
- Calculator functionality
- Extensible tool framework
📦 Installation
pip install git+https://github.com/Kawai-Senpai/UltraGPT.git
🚀 Quick Start
from ultragpt import UltraGPT
if __name__ == "__main__":
# Initialize UltraGPT (OpenAI only)
ultragpt = UltraGPT(
api_key="your-openai-api-key",
verbose=True
)
# Example chat session
result = ultragpt.chat([
{"role": "user", "content": "Write a story about an elephant."}
])
print("Final Output:", result["output"])
print("Total tokens used:", result["total_tokens"])
🌐 Web Search (Google) & Scraping
UltraGPT now supports Google Custom Search API for web search, with optional scraping of result pages for deeper context.
🔑 Google API Setup
- Get a Google Custom Search API key from Google Cloud Console
- Create a Custom Search Engine at cse.google.com
- Note your API key and Search Engine ID
🛠️ Usage Example
from ultragpt import UltraGPT
ultra = UltraGPT(
api_key="your-openai-api-key",
google_api_key="your-google-api-key",
search_engine_id="your-search-engine-id",
verbose=True
)
# Configure web search tool (scraping enabled, max 3 results)
tools_config = {
"web-search": {
"max_results": 3,
"enable_scraping": True,
"max_scrape_length": 2000
}
}
messages = [
{"role": "user", "content": "What are the latest trends in AI?"}
]
response = ultra.chat(
messages=messages,
tools=["web-search"],
tools_config=tools_config,
steps_pipeline=False,
reasoning_pipeline=False
)
print(response["output"])
🔄 Override Search Engine ID per Call
You can override the search engine for a specific chat call:
tools_config = {
"web-search": {
"search_engine_id": "another-engine-id",
"max_results": 2
}
}
🛡️ Error Handling
- All web search errors (API, quota, scraping) return an empty string to the AI (never error text)
- Errors are logged via
self.logand shown in verbose mode, but never contaminate the AI's output - Scraping failures are skipped silently
🕷️ Scraping
- Set
enable_scraping: Trueto extract main content from result pages - Control length with
max_scrape_length - Respects robots.txt and rate limits
📚 Advanced Usage
Customizing Pipeline Settings
ultragpt = UltraGPT(
api_key="your-openai-api-key",
model="gpt-4o", # Specify model
temperature=0.7, # Adjust creativity
reasoning_iterations=3, # Set reasoning depth
steps_pipeline=True,
reasoning_pipeline=True,
verbose=True
)
Using Tools
ultragpt = UltraGPT(
api_key="your-openai-api-key",
tools=["web-search", "calculator", "math-operations"],
tools_config={
"web-search": {
"max_results": 1,
"model": "gpt-4o"
},
"calculator": {
"model": "gpt-4o"
},
"math-operations": {
"model": "gpt-4o"
}
}
)
🆕 New Features
Advanced Mathematical Operations Tool
UltraGPT now includes a powerful math operations tool that can handle complex mathematical queries and multiple operations in a single request:
# Example: Multiple operations in one request
response = ultragpt.chat([{
"role": "user",
"content": """
Please perform these calculations:
1. Check if [1, 5, 8] lie between 0 and 10
2. Are 17, 23, 29 prime numbers?
3. Get statistical summary of [1, 2, 3, 4, 5]
4. Find outliers in [1, 2, 3, 100]
"""
}], tools=["math-operations"])
# Example: Multiple range checks
response = ultragpt.chat([{
"role": "user",
"content": "Check if [1, 5, 8] lie between 0-10 and [15, 20, 25] lie between 10-30"
}], tools=["math-operations"])
Available Operations:
- Range checking (numbers between bounds) - supports multiple ranges
- Outlier detection (IQR and z-score methods) - multiple datasets
- Proximity checking (numbers close to target) - multiple proximity checks
- Statistical summaries (mean, median, std dev, etc.) - multiple datasets
- Prime number checking - multiple number sets
- Factor analysis and prime factorization - multiple numbers
- Sequence analysis (arithmetic/geometric) - multiple sequences
- Percentage calculations and ratios - multiple calculations
Model Control for Pipelines
You can now use different models for different parts of the pipeline:
ultragpt = UltraGPT(api_key="your-key")
response = ultragpt.chat(
messages=[{"role": "user", "content": "Solve this complex problem"}],
model="gpt-4o", # Main model for final response
steps_model="gpt-4o-mini", # Cheaper model for step generation
reasoning_model="gpt-4o-mini", # Cheaper model for reasoning
reasoning_iterations=3
)
This allows you to:
- Save costs by using cheaper models for intermediate steps
- Optimize performance by using faster models for simple operations
- Maintain quality by using premium models for final outputs
🔧 Configuration Options
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str | Required | Your OpenAI API key |
model |
str | "gpt-4o" | Model to use |
temperature |
float | 0.7 | Output randomness |
reasoning_iterations |
int | 3 | Number of reasoning steps |
tools |
list | [] | Enabled tools |
verbose |
bool | False | Enable detailed logging |
🌐 Tool System
UltraGPT supports various tools to enhance its capabilities:
Web Search
- Performs intelligent web searches
- Summarizes findings
Calculator
- Advanced mathematical calculations
- Expression evaluation
Math Operations
- Range checking and validation
- Statistical analysis and outlier detection
- Prime number checking and factorization
- Sequence analysis (arithmetic/geometric patterns)
- Percentage calculations and ratios
- Proximity checking with tolerance
- Integrates results into responses
Calculator
- Handles mathematical operations
- Supports complex calculations
- Provides step-by-step solutions
Math Operations
- Range checking (numbers between bounds)
- Outlier detection (IQR and z-score methods)
- Proximity checking (numbers close to target)
- Statistical summaries (mean, median, std dev, etc.)
- Prime number checking
- Factor analysis and prime factorization
- Sequence analysis (arithmetic/geometric)
- Percentage calculations and ratios
🔄 Pipeline System
Steps Pipeline
- Task Analysis
- Step Generation
- Step-by-Step Execution
- Progress Verification
- Final Compilation
Reasoning Pipeline
- Initial Analysis
- Multi-iteration Thinking
- Thought Development
- Conclusion Formation
📋 Requirements
- Python 3.6+
- OpenAI API key
- Internet connection (for web tools)
🤝 Contributing
Contributions are always welcome! Here's how you can help:
- Fork the repository
- Create a new branch (
git checkout -b feature/improvement) - Make changes
- Commit (
git commit -am 'Add new feature') - Push (
git push origin feature/improvement) - Open a Pull Request
📝 License
This project is MIT licensed - see the LICENSE file for details.
👥 Author
Ranit Bhowmick
- Email: bhowmickranitking@duck.com
- GitHub: @Kawai-Senpai
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ultragpt-3.1.0.tar.gz.
File metadata
- Download URL: ultragpt-3.1.0.tar.gz
- Upload date:
- Size: 27.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6c383b662bf3e7813d08b5eb595abd04fb89db6ad8874ff267e3e0cf2a1a5ae
|
|
| MD5 |
528d1199d1f294976a9b017cbedda8a1
|
|
| BLAKE2b-256 |
5497e58d4f2248d3857e93c461b0fe74ce9d2ddb2d68077764ad326c34a62731
|
File details
Details for the file ultragpt-3.1.0-py3-none-any.whl.
File metadata
- Download URL: ultragpt-3.1.0-py3-none-any.whl
- Upload date:
- Size: 30.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
954fff5fee560e8e6494846efb06d2368a21669444752611eafcd2a5f20b077d
|
|
| MD5 |
1738cabd662c79bd02216cfef1bdb7b0
|
|
| BLAKE2b-256 |
7ac7a614f3e158971f15b9741fd58d61d49c6135e81f8746f8dd6170d5395835
|