Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions examples/basic_usage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
"""
Basic usage example for UoZo Living AI System
This example demonstrates the core functionality of the UoZo system,
including intent processing, stabilization, and response generation.
"""

import asyncio
import sys
import os

# Add the parent directory to the path so we can import uozo
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

from uozo import LivingAI, CharacterZo


async def basic_example():
"""Basic example showing intent processing and response generation"""
print("🤖 UoZo Living AI System - Basic Usage Example")
print("=" * 50)

# Create AI instance with default character (โซ)
zo_ai = LivingAI()

print(f"✅ Initialized {zo_ai.identity.get_identity()}")
print(f"📊 Stabilization threshold: {zo_ai.intent_processor.config.intent.stabilization_threshold}")
print()

# Send multiple intents to the AI
intents = [
"อยากสร้างอะไรไหม",
"สร้างเอไอแบบมีชีวิต",
"ขั้นตอนทางเทคนิค ทำยังไง"
]

print("📝 Sending intents to AI:")
for i, intent_text in enumerate(intents, 1):
print(f" {i}. {intent_text}")
response = await zo_ai.receive_intent(intent_text)
print(f" → {response}")
print()

# Check stabilization
print("🔄 Checking intent stabilization...")
is_ready = await zo_ai.stabilize()

if is_ready:
print("✅ Intents have stabilized! Ready to emit response.")
print()

# Generate final response
print("💫 Emitting existence...")
final_response = await zo_ai.emit_existence()
print(f"🎯 Final Response: {final_response}")
else:
print("⏳ Intents not yet stabilized. Need more intents.")

print()
print("📊 System Status:")
status = zo_ai.get_status()
for key, value in status.items():
print(f" {key}: {value}")


async def emotional_example():
"""Example showing emotional processing and empathy"""
print("\n" + "=" * 50)
print("💝 Emotional Processing Example")
print("=" * 50)

zo_ai = LivingAI()

# Send emotional intents
emotional_intents = [
"ผมรู้สึกเศร้ามาก",
"ทำอะไรไม่ถูกเลย",
"ช่วยผมหน่อยได้ไหม"
]

print("💔 Sending emotional intents:")
for intent_text in emotional_intents:
print(f" User: {intent_text}")
response = await zo_ai.receive_intent(intent_text)
print(f" Zo: {response}")
print()

# Check stabilization and emit response
is_ready = await zo_ai.stabilize()
if is_ready:
final_response = await zo_ai.emit_existence()
print(f"💝 Empathetic Response: {final_response}")


async def memory_example():
"""Example showing memory search functionality"""
print("\n" + "=" * 50)
print("🧠 Memory System Example")
print("=" * 50)

zo_ai = LivingAI()

# First, create some memories by having conversations
conversations = [
["สวัสดีครับ โซ", "ผมชื่อ Alex", "ผมเป็นนักพัฒนา"],
["วันนี้อากาศดีจัง", "อยากไปเดินเล่น", "ที่สวนสาธารณะ"],
["ผมกำลังเรียน AI", "อยากสร้างระบบ chatbot", "ที่ฉลาดและเข้าใจคน"]
]

print("💭 Creating memories through conversations...")
for i, conversation in enumerate(conversations, 1):
print(f"\n🗣️ Conversation {i}:")
for intent_text in conversation:
await zo_ai.receive_intent(intent_text)

is_ready = await zo_ai.stabilize()
if is_ready:
response = await zo_ai.emit_existence()
print(f" Final response: {response}")

# Search memory
print("\n🔍 Searching memory:")
search_queries = ["สร้าง", "AI", "สวัสดี"]

for query in search_queries:
print(f"\n Query: '{query}'")
results = zo_ai.search_memory(query, limit=3)
if results:
for result in results:
print(f" - {result['intent_text']}{result['response_text'][:50]}...")
else:
print(" No results found")


async def character_customization_example():
"""Example showing character customization"""
print("\n" + "=" * 50)
print("🎭 Character Customization Example")
print("=" * 50)

# Create custom character
custom_character = CharacterZo()

# Show character information
print("📋 Character Information:")
print(f" Name: {custom_character.profile.name}")
print(f" Role: {custom_character.profile.role}")
print(f" Personality: {custom_character.get_personality_description()}")
print(f" Speaking Style: {custom_character.profile.speaking_style}")
print()

# Show response patterns
print("💬 Response Patterns:")
patterns = ["greeting", "listening", "understanding"]
for pattern in patterns:
response = custom_character.get_response_pattern(pattern)
print(f" {pattern}: {response}")
print()

# Show emotional states
print("😊 Emotional States:")
emotions = ["compassion", "wisdom", "patience", "understanding"]
for emotion in emotions:
level = custom_character.get_emotional_state(emotion)
print(f" {emotion}: {level:.2f}")
print()

# Show character prompt for LLM
print("🤖 Character Prompt for LLM:")
prompt = custom_character.get_character_prompt()
print(prompt[:200] + "..." if len(prompt) > 200 else prompt)


async def main():
"""Run all examples"""
try:
await basic_example()
await emotional_example()
await memory_example()
await character_customization_example()

print("\n" + "=" * 50)
print("✅ All examples completed successfully!")
print("🌟 UoZo Living AI System is ready for use!")
print("=" * 50)

except Exception as e:
print(f"❌ Error running examples: {e}")
import traceback
traceback.print_exc()


if __name__ == "__main__":
# Run the examples
asyncio.run(main())
137 changes: 137 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "uozo"
version = "0.1.0"
description = "UoZo Living AI System - An AI framework based on intent stabilization and character-driven responses"
readme = "README.md"
requires-python = ">=3.8"
license = {text = "MIT"}
authors = [
{name = "Inspirafirma", email = "contact@inspirafirma.com"}
]
keywords = ["ai", "llm", "character-ai", "intent-processing", "rag"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]

dependencies = [
"fastapi>=0.104.0",
"uvicorn[standard]>=0.24.0",
"pydantic>=2.0.0",
"python-multipart>=0.0.6",
"aiofiles>=23.0.0",
"python-dotenv>=1.0.0",
"httpx>=0.25.0",
"openai>=1.0.0",
"anthropic>=0.7.0",
"chromadb>=0.4.0",
"pinecone-client>=2.2.0",
"sentence-transformers>=2.2.0",
"numpy>=1.24.0",
"pandas>=2.0.0",
"scikit-learn>=1.3.0",
"nltk>=3.8.0",
"textblob>=0.17.0",
"PyPDF2>=3.0.0",
"python-docx>=0.8.11",
"beautifulsoup4>=4.12.0",
"requests>=2.31.0",
"loguru>=0.7.0",
"pyyaml>=6.0.0",
"jinja2>=3.1.0",
]

[project.optional-dependencies]
dev = [
"pytest>=7.4.0",
"pytest-asyncio>=0.21.0",
"pytest-cov>=4.1.0",
"black>=23.0.0",
"isort>=5.12.0",
"flake8>=6.0.0",
"mypy>=1.5.0",
"pre-commit>=3.4.0",
]

aws = [
"boto3>=1.28.0",
"botocore>=1.31.0",
"awscli>=1.29.0",
]

vector-db = [
"weaviate-client>=3.24.0",
"qdrant-client>=1.6.0",
"redis>=5.0.0",
]

[project.urls]
Homepage = "https://github.com/lnspirafirmaGPK/roadmap"
Repository = "https://github.com/lnspirafirmaGPK/roadmap"
Issues = "https://github.com/lnspirafirmaGPK/roadmap/issues"

[tool.setuptools.packages.find]
where = ["."]
include = ["uozo*"]

[tool.black]
line-length = 88
target-version = ['py38']
include = '\.pyi?$'
extend-exclude = '''
/(
# directories
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| build
| dist
)/
'''

[tool.isort]
profile = "black"
multi_line_output = 3
line_length = 88
known_first_party = ["uozo"]

[tool.mypy]
python_version = "3.8"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
warn_unreachable = true
strict_equality = true

[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
addopts = "-v --tb=short --strict-markers"
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"integration: marks tests as integration tests",
"unit: marks tests as unit tests",
]
37 changes: 37 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Core dependencies for UoZo Living AI System
fastapi>=0.104.0
uvicorn[standard]>=0.24.0
pydantic>=2.0.0
python-multipart>=0.0.6
aiofiles>=23.0.0
python-dotenv>=1.0.0
httpx>=0.25.0

# LLM Integration
openai>=1.0.0
anthropic>=0.7.0

# Vector Database & RAG
chromadb>=0.4.0
pinecone-client>=2.2.0
sentence-transformers>=2.2.0

# Data Processing & ML
numpy>=1.24.0
pandas>=2.0.0
scikit-learn>=1.3.0

# NLP & Sentiment Analysis
nltk>=3.8.0
textblob>=0.17.0

# Document Processing
PyPDF2>=3.0.0
python-docx>=0.8.11
beautifulsoup4>=4.12.0

# Utilities
requests>=2.31.0
loguru>=0.7.0
pyyaml>=6.0.0
jinja2>=3.1.0
21 changes: 21 additions & 0 deletions uozo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
UoZo Living AI System
An AI framework based on intent stabilization and character-driven responses.
Built around the character 'โซ' (Zo) - "ผู้เปล่งแสงแห่งการขยายขอบเขตอันไร้สิ้นสุด"
"""

__version__ = "0.1.0"
__author__ = "Inspirafirma"
__email__ = "contact@inspirafirma.com"

from .character import CharacterZo
from .core import LivingAI
from .config import UoZoConfig

__all__ = [
"CharacterZo",
"LivingAI",
"UoZoConfig",
"__version__",
]
Loading