o-reasonable
Advanced tools
+1
-1
| { | ||
| "name": "o-reasonable", | ||
| "version": "0.0.6", | ||
| "version": "0.0.7", | ||
| "description": "O-Reasonable is a lightweight reasoning agent designed to mimic logical planning and problem-solving capabilities using cost-effective OpenAI models. It generates step-by-step plans, executes them sequentially, and synthesizes a final answer, making it a practical tool for structured reasoning tasks.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
+122
-8
@@ -61,9 +61,63 @@ # O-Reasonable 🧠 | ||
| interface OReasonableConfig { | ||
| model?: string; // OpenAI model to use (default: "gpt-4o-mini") | ||
| apiKey?: string; // Optional API key override | ||
| baseURL?: string; // Custom base URL for OpenAI-compatible APIs | ||
| enableLogs?: boolean; // Enable/disable console logs (default: false) | ||
| model?: string; // OpenAI model to use (default: "gpt-4o-mini") | ||
| apiKey?: string; // Optional API key override | ||
| baseURL?: string; // Custom base URL for OpenAI-compatible APIs | ||
| enableLogs?: boolean; // Enable/disable console logs (default: false) | ||
| enableReflection?: boolean; // Enable step validation and reflection (default: true) | ||
| minConfidence?: number; // Minimum confidence threshold for steps (default: 0.6) | ||
| maxRetries?: number; // Maximum retries for low-confidence steps (default: 1) | ||
| } | ||
| ``` | ||
| ## Enhanced Reasoning Features | ||
| O-Reasonable now includes advanced reasoning capabilities that significantly improve the quality and reliability of the generated responses: | ||
| ### 🔍 **Step Validation & Reflection** | ||
| Each reasoning step is automatically validated for: | ||
| - **Confidence**: How certain the AI is about the step's accuracy | ||
| - **Relevance**: How well the step contributes to solving the original task | ||
| - **Logical soundness**: Whether the reasoning is well-founded | ||
| ### 🧠 **Smart Context Management** | ||
| - **Context Summarization**: Automatically summarizes previous steps to maintain focus | ||
| - **Conversation Threading**: Builds coherent conversation history between steps | ||
| - **Relevance Filtering**: Keeps only the most important information for subsequent steps | ||
| ### 🔄 **Adaptive Execution** | ||
| - **Quality Thresholds**: Automatically retries steps that don't meet confidence requirements | ||
| - **Enhanced Planning**: Uses proven reasoning frameworks (analytical, comparative, causal, creative) | ||
| - **Self-Evaluation**: Reflects on the overall reasoning process quality | ||
| ### 📊 **Confidence Tracking** | ||
| - Individual step confidence scores | ||
| - Overall reasoning confidence | ||
| - Quality metrics for each step | ||
| ```typescript | ||
| // Enhanced reasoning with validation | ||
| const result = await runAgent("Analyze the impact of remote work on productivity", { | ||
| enableReflection: true, // Enable step validation and reflection | ||
| minConfidence: 0.7, // Require high confidence (0.0-1.0) | ||
| maxRetries: 2, // Retry low-confidence steps up to 2 times | ||
| enableLogs: true | ||
| }); | ||
| // Access enhanced results | ||
| console.log(result.steps); // Array of StepResult objects with confidence scores | ||
| console.log(result.overallConfidence); // Overall reasoning confidence (0.0-1.0) | ||
| console.log(result.reflections); // Self-evaluation of reasoning quality | ||
| ``` | ||
| ### Step Result Structure | ||
| ```typescript | ||
| interface StepResult { | ||
| content: string; // The step's reasoning content | ||
| confidence: number; // Confidence score (0.0-1.0) | ||
| relevance: number; // Relevance to original task (0.0-1.0) | ||
| isValid: boolean; // Whether the step passed validation | ||
| reasoning: string; // Explanation of the validation | ||
| } | ||
| ``` | ||
| ## Using OpenAI-Compatible APIs | ||
@@ -116,12 +170,72 @@ | ||
| The `runAgent` function returns a promise that resolves to an `AgentResult`: | ||
| The `runAgent` function returns a promise that resolves to an enhanced `AgentResult`: | ||
| ```typescript | ||
| interface AgentResult { | ||
| steps: string[]; // Results from each reasoning step | ||
| finalQuestion: string; // The final question that was asked | ||
| finalAnswer: string; // The synthesized final answer | ||
| steps: StepResult[]; // Enhanced step results with confidence scores | ||
| finalQuestion: string; // The final question that was asked | ||
| finalAnswer: string; // The synthesized final answer | ||
| overallConfidence: number; // Overall confidence in the reasoning (0.0-1.0) | ||
| reflections: string[]; // Self-evaluation and reflection insights | ||
| } | ||
| ``` | ||
| ## Examples | ||
| ### Quick Start | ||
| ```bash | ||
| # Try the quick example | ||
| node quickstart.js | ||
| ``` | ||
| ### Comprehensive Examples | ||
| ```bash | ||
| # Run all examples (JavaScript) | ||
| node example.js | ||
| # Run TypeScript examples (requires ts-node) | ||
| npx ts-node example.ts | ||
| # Try different configurations | ||
| node examples/configurations.js | ||
| ``` | ||
| ### Basic Usage | ||
| ```typescript | ||
| import { runAgent } from 'o-reasonable'; | ||
| const result = await runAgent("What are the key factors in choosing a programming language?"); | ||
| console.log(result.finalAnswer); | ||
| console.log(`Confidence: ${result.overallConfidence.toFixed(2)}`); | ||
| ``` | ||
| ### Advanced Reasoning Configuration | ||
| ```typescript | ||
| // High-quality reasoning with strict validation | ||
| const result = await runAgent("Design a sustainable urban transportation system", { | ||
| enableReflection: true, | ||
| minConfidence: 0.8, // Require very high confidence | ||
| maxRetries: 3, // Allow more retries for quality | ||
| enableLogs: true, | ||
| model: "gpt-4" | ||
| }); | ||
| // Analyze step quality | ||
| result.steps.forEach((step, i) => { | ||
| console.log(`Step ${i+1}: Confidence ${step.confidence.toFixed(2)}, Relevance ${step.relevance.toFixed(2)}`); | ||
| }); | ||
| ``` | ||
| ### Debugging and Analysis | ||
| ```typescript | ||
| const result = await runAgent("Solve this complex business problem", { | ||
| enableLogs: true, // See detailed reasoning process | ||
| enableReflection: true // Get self-evaluation insights | ||
| }); | ||
| // Review the reasoning process | ||
| console.log("Reflections on reasoning quality:"); | ||
| result.reflections.forEach(reflection => console.log(reflection)); | ||
| ``` | ||
| ## Development | ||
@@ -128,0 +242,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
426479
3.53%8245
2.08%266
75%