Skip to content

azure-architect/thoughts_sb

Repository files navigation

I'll help you continue developing your thought processing system. Let's focus on updating the main.py file to properly set up for Ollama integration without implementing it fully yet.

Here's how we can update the main.py file:

from crewai import Agent, Task, Crew
from langchain.llms import Ollama
import os
from dotenv import load_dotenv

# Load environment variables
load_dotenv()

# Initialize the LLM (commented out for now, will implement later)
# llm = Ollama(model="llama3")

# For now, we'll set up the structure but use a placeholder for the LLM
# This will be replaced with actual Ollama integration later
llm = None

# Define the agents for each stage of the thought processing workflow
capture_agent = Agent(
    role="Thought Capture Specialist",
    goal="Efficiently capture raw thoughts with minimal friction",
    backstory="You excel at preserving raw ideas exactly as they occur, without judgment or alteration. Your strength is in creating a frictionless capture process.",
    verbose=True,
    llm=llm
)

contextualize_agent = Agent(
    role="Context Provider",
    goal="Add relevant context to raw thoughts",
    backstory="You specialize in connecting raw thoughts to their broader context, identifying related information and situational factors.",
    verbose=True,
    llm=llm
)

clarify_agent = Agent(
    role="Thought Clarifier",
    goal="Make fuzzy thoughts precise and clear",
    backstory="You excel at transforming ambiguous or vague thoughts into clear, precise expressions.",
    verbose=True,
    llm=llm
)

categorize_agent = Agent(
    role="Information Taxonomist",
    goal="Organize thoughts into meaningful categories",
    backstory="You have expertise in knowledge organization systems and can identify patterns and relationships between ideas.",
    verbose=True,
    llm=llm
)

crystallize_agent = Agent(
    role="Insight Crystallizer",
    goal="Distill thoughts into their essential meaning",
    backstory="You can identify the core value and meaning in complex thoughts, reducing them to their most potent form.",
    verbose=True,
    llm=llm
)

connect_agent = Agent(
    role="Knowledge Connector",
    goal="Integrate new thoughts with existing knowledge",
    backstory="You excel at finding meaningful connections between new thoughts and established knowledge, creating a coherent knowledge network.",
    verbose=True,
    llm=llm
)

# Define the tasks for each stage
capture_task = Task(
    description="Capture raw thoughts exactly as they are presented, without modification or judgment.",
    agent=capture_agent
)

contextualize_task = Task(
    description="Add relevant context to the captured thought, considering factors like time, location, related events, and emotional state.",
    agent=contextualize_agent
)

clarify_task = Task(
    description="Transform vague or ambiguous thoughts into clear, precise expressions. Identify and resolve contradictions or ambiguities.",
    agent=clarify_agent
)

categorize_task = Task(
    description="Organize the thought into appropriate categories and tags for efficient retrieval and connection.",
    agent=categorize_agent
)

crystallize_task = Task(
    description="Distill the thought to its essential meaning and value, preserving its core while removing unnecessary elements.",
    agent=crystallize_agent
)

connect_task = Task(
    description="Integrate the processed thought with existing knowledge, identifying relationships with other thoughts and concepts.",
    agent=connect_agent
)

# Create the crew
thought_processing_crew = Crew(
    agents=[capture_agent, contextualize_agent, clarify_agent, categorize_agent, crystallize_agent, connect_agent],
    tasks=[capture_task, contextualize_task, clarify_task, categorize_task, crystallize_task, connect_task],
    verbose=2
)

# File handling functions
def ensure_directories_exist():
    """Ensure all six directories for the workflow stages exist."""
    directories = [
        "1-Capture",
        "2-Contextualize", 
        "3-Clarify", 
        "4-Categorize", 
        "5-Crystallize", 
        "6-Connect"
    ]
    
    for directory in directories:
        if not os.path.exists(directory):
            os.makedirs(directory)
            print(f"Created directory: {directory}")

def save_thought_to_stage(thought, stage):
    """Save a thought to the appropriate stage directory."""
    stage_map = {
        "capture": "1-Capture",
        "contextualize": "2-Contextualize",
        "clarify": "3-Clarify",
        "categorize": "4-Categorize",
        "crystallize": "5-Crystallize",
        "connect": "6-Connect"
    }
    
    directory = stage_map.get(stage.lower())
    if not directory:
        raise ValueError(f"Invalid stage: {stage}")
    
    # Create a timestamped filename
    import datetime
    timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
    filename = f"{directory}/thought_{timestamp}.txt"
    
    with open(filename, "w") as f:
        f.write(thought)
    
    return filename

def process_thought(raw_thought):
    """Process a thought through all six stages of the workflow."""
    # This is a placeholder function that will be implemented later
    # For now, it just demonstrates the structure
    
    # Stage 1: Capture
    captured_thought = raw_thought  # In a real implementation, this would be processed by capture_agent
    capture_file = save_thought_to_stage(captured_thought, "capture")
    print(f"Thought captured and saved to {capture_file}")
    
    # Other stages would follow a similar pattern
    # We'll implement the actual agent processing in a future update
    
    return "Thought processed through all stages"

# Main execution
if __name__ == "__main__":
    # Ensure directories exist
    ensure_directories_exist()
    
    print("Universal Thought Processing System")
    print("-----------------------------------")
    print("Enter a thought to process (or 'exit' to quit):")
    
    while True:
        user_input = input("> ")
        if user_input.lower() == "exit":
            break
        
        result = process_thought(user_input)
        print(result)

Now, let's also create a simple README.md file to document the project:

# Universal Thought Processing System

A six-stage thought processing workflow powered by CrewAI.

## Stages

1. **Capture**: Preserve raw thoughts exactly as they occur
2. **Contextualize**: Add relevant context to raw thoughts
3. **Clarify**: Make fuzzy thoughts precise and clear
4. **Categorize**: Organize thoughts into meaningful categories
5. **Crystallize**: Distill thoughts into their essential meaning
6. **Connect**: Integrate new thoughts with existing knowledge

## Setup

1. Clone the repository
2. Install dependencies: `pip install -r requirements.txt`
3. Create a `.env` file with your configuration (if needed)
4. Run the system: `python main.py`

## Requirements

- Python 3.8+
- CrewAI
- LangChain
- Ollama (to be configured later)

## Project Structure

universal-thought-processing/ ├── 1-Capture/ # Raw captured thoughts ├── 2-Contextualize/ # Thoughts with added context ├── 3-Clarify/ # Clarified thoughts ├── 4-Categorize/ # Categorized thoughts ├── 5-Crystallize/ # Crystallized thoughts ├── 6-Connect/ # Connected thoughts ├── main.py # Main application └── requirements.txt # Dependencies


## Usage

Run the main script and follow the prompts to enter thoughts for processing.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages