Skip to main content

Reasoning Playground

The Reasoning Playground is an interactive interface that allows you to visualize and experiment with how Reeflect uses stored memories to reason and generate responses.

Reasoning Playground Interface

Key Features

Interactive Reasoning

See step-by-step how the system processes a query using stored memories, with visualization of each reasoning step.

Memory Manipulation

Add, remove, or modify memories to see how changes affect the reasoning outcome, helping you understand impact.

Alternative Paths

Explore different reasoning strategies and compare outcomes to understand how the system makes decisions.

Confidence Scoring

View confidence scores for each reasoning step and final conclusion, highlighting areas of certainty and uncertainty.

Using the Playground

You can access the Reasoning Playground in several ways:

1. Web Interface

from reeflect.visualization import ReasoningPlayground

# Launch the interactive playground in a web browser
playground = ReasoningPlayground(memory_system)
playground.launch(
port=8050,
namespaces=["user_preferences", "user_health"],
default_query="What restaurant should I recommend to the user?"
)

2. Jupyter Notebook Integration

# Use in Jupyter Notebook
from reeflect.visualization import ReasoningPlaygroundWidget

# Create interactive widget
playground_widget = ReasoningPlaygroundWidget(memory_system)
playground_widget.display(
namespaces=["user_preferences"],
height=600,
width=900
)

3. React Component

import React, { useState } from 'react';
import { ReasoningPlayground } from 'reeflect-react';

const PlaygroundDemo = () => {
const [query, setQuery] = useState("What are the user's dietary preferences?");
const [namespace, setNamespace] = useState("user_health");

return (
<div className="playground-container">
<div className="playground-controls mb-4">
<input
type="text"
value={query}
onChange={(e) => setQuery(e.target.value)}
className="w-full p-2 bg-gray-800 rounded mb-2"
placeholder="Enter your query"
/>
<select
value={namespace}
onChange={(e) => setNamespace(e.target.value)}
className="p-2 bg-gray-800 rounded"
>
<option value="user_health">Health Information</option>
<option value="user_preferences">User Preferences</option>
<option value="user_behavior">User Behavior</option>
</select>
</div>

<ReasoningPlayground
apiKey="your_api_key"
apiEndpoint="https://api.reeflect.ai/v1"
query={query}
namespace={namespace}
height={600}
showConfidence={true}
enableMemoryManipulation={true}
/>
</div>
);
};

Customizing the Playground

The Reasoning Playground can be customized to fit your specific needs:

# Customize the playground experience
playground.launch(
port=8050,
namespaces=["user_preferences", "user_health"],
default_query="What restaurant should I recommend to the user?",

# Layout customization
layout="horizontal", # Options: horizontal, vertical, three-panel
theme="dark", # Options: dark, light, system

# Feature configuration
show_confidence=True,
enable_memory_manipulation=True,
enable_alternative_paths=True,
max_reasoning_steps=5,

# Advanced options
reasoning_strategies=["chain_of_thought", "tree_of_thought"],
visualize_embeddings=True,
export_formats=["pdf", "json"],

# Authentication (for multi-user environments)
require_authentication=True,
auth_provider="internal" # Options: internal, oauth, saml
)

Understanding the Reasoning Process

The Reasoning Playground visualizes the multi-step reasoning process:

1. Memory Retrieval

In this phase, the system retrieves memories relevant to the query. The playground shows:

  • Retrieved memories ranked by relevance
  • Similarity scores for each memory
  • Memory attributes (importance, recency, etc.)

2. Reasoning Steps

The reasoning phase shows how the system processes the retrieved memories:

  • Step-by-step thought process
  • Memories considered at each step
  • Intermediate conclusions
  • Confidence scores for each step

3. Final Answer Generation

The final phase shows how the system formulates its response:

  • Final conclusion
  • Support for the conclusion
  • Memories that most influenced the answer
  • Overall confidence score

Interactive Exploration

The playground offers several interactive features:

Memory Manipulation

You can modify the memory set to see how different memories affect reasoning:

  • Add hypothetical memories
  • Temporarily remove memories
  • Adjust memory importance
  • Modify memory content

Alternative Reasoning Strategies

Compare different reasoning approaches:

  • Chain of Thought: Linear step-by-step reasoning
  • Tree of Thought: Branching reasoning that explores multiple possibilities
  • Memory-First: Prioritizes memory content over relationships
  • Relationship-First: Prioritizes relationships between memories

What-If Analysis

Explore counterfactual scenarios:

  • "What if this memory had different content?"
  • "What if these memories were contradictory?"
  • "What if this memory had higher importance?"
  • "What if these memories weren't available?"

Educational Use Cases

The Reasoning Playground is an excellent tool for:

  1. Transparency: Help users understand how AI makes decisions based on memory
  2. Debugging: Identify reasoning errors or problematic memories
  3. Training: Teach developers how memory-based reasoning works
  4. Demonstration: Show stakeholders the value of memory in AI systems
  5. Testing: Validate reasoning patterns before deploying to production
Teaching Tool

The Reasoning Playground is an excellent tool for educating stakeholders about how AI systems use memory to make decisions. It provides transparency and builds trust by making the "black box" of AI reasoning visible and understandable.

Case Study: Memory-Driven Recommendations

Here's a complete example of using the Reasoning Playground to understand restaurant recommendations:

# Set up the playground with specific memories
from reeflect import Reeflect
from reeflect.adapters.openai import OpenAIAdapter
from reeflect.visualization import ReasoningPlayground

# Initialize memory system
memory = Reeflect(
adapter=OpenAIAdapter(api_key="your_api_key"),
storage_config={"type": "local", "path": "./memory"}
)

# Add test memories
memory.batch_create([
{
"content": "The user is allergic to peanuts and tree nuts.",
"namespace": "user_health",
"importance": 0.9,
"tags": ["allergy", "food", "health"]
},
{
"content": "The user enjoys Italian and Mexican cuisines.",
"namespace": "user_preferences",
"importance": 0.7,
"tags": ["food", "preference"]
},
{
"content": "The user prefers restaurants with quiet atmospheres.",
"namespace": "user_preferences",
"importance": 0.6,
"tags": ["ambiance", "preference"]
},
{
"content": "The user recently mentioned wanting to try new Mediterranean restaurants.",
"namespace": "user_conversations",
"importance": 0.8,
"tags": ["food", "recent"]
},
{
"content": "The user typically dines out on Friday evenings.",
"namespace": "user_behavior",
"importance": 0.5,
"tags": ["schedule", "behavior"]
}
])

# Launch playground with specific query
playground = ReasoningPlayground(memory)
playground.launch(
default_query="What restaurant should I recommend to the user for dinner this weekend?",
namespaces=["user_health", "user_preferences", "user_conversations", "user_behavior"],
show_confidence=True,
enable_memory_manipulation=True,
reasoning_strategies=["chain_of_thought", "tree_of_thought"]
)

Next Steps

Learn about related topics: