-
Notifications
You must be signed in to change notification settings - Fork 0
CogChat
AutoBotSolutions edited this page Apr 27, 2026
·
1 revision
CogChat is the interactive chat interface for the Cognitive Engine.
CogChat provides a conversational interface to interact with the Cognitive Engine. It supports multiple modes:
- CLI Mode: Command-line interface for terminal users
- Server Mode: WebSocket server for web-based chat
- Chat Mode: Interactive chat with the Cognitive Engine
Core chat functionality for interacting with the Cognitive Engine.
Key Features:
- Session management
- Conversation history
- Context awareness
- Multi-turn conversations
Command-line interface for CogChat.
Usage:
python -m cogchat.cliFeatures:
- Interactive terminal chat
- Command history
- Color-coded output
- Session persistence
WebSocket server for web-based chat interface.
Usage:
python -m cogchat.serverFeatures:
- Real-time WebSocket communication
- Multiple concurrent sessions
- Session management
- CORS support
Configuration for CogChat components.
Configuration Options:
- Server host and port
- Session timeout
- History retention
- Debug mode
# Start CLI chat
python -m cogchat.cli
# Interactive session
You: What is artificial intelligence?
CogChat: AI is the simulation of human intelligence in machines...# Start WebSocket server
python -m cogchat.server --host 0.0.0.0 --port 8080
# Connect from client
# WebSocket URL: ws://localhost:8080/wsfrom cogchat.chat import CogChat
# Initialize chat
chat = CogChat()
# Send message
response = chat.send_message("What is AI?")
print(response)# Server configuration
COGCHAT_HOST=0.0.0.0
COGCHAT_PORT=8080
COGCHAT_DEBUG=false
# Session configuration
SESSION_TIMEOUT=3600
HISTORY_LIMIT=100Create cogchat_config.yaml:
server:
host: "0.0.0.0"
port: 8080
debug: false
session:
timeout: 3600
history_limit: 100
persistence: true
engine:
min_iterations: 3
max_iterations: 50
confidence_threshold: 0.7class CogChat:
"""Main chat interface class."""
def __init__(self, config=None):
"""Initialize CogChat with optional configuration."""
def send_message(self, message, session_id=None):
"""Send a message and get response."""
def get_session(self, session_id):
"""Get session information."""
def clear_session(self, session_id):
"""Clear session history."""Connect: ws://localhost:8080/ws
Message Format:
{
"type": "message",
"session_id": "optional-session-id",
"content": "Your message here"
}Response Format:
{
"type": "response",
"content": "Response from Cognitive Engine",
"confidence": 0.87,
"iterations": 5
}const ws = new WebSocket('ws://localhost:8080/ws');
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'response') {
console.log(data.content);
}
};
ws.send(JSON.stringify({
type: 'message',
content: 'What is AI?'
}));import websocket
import json
def on_message(ws, message):
data = json.loads(message)
print(data['content'])
ws = websocket.WebSocketApp('ws://localhost:8080/ws')
ws.on_message = on_message
ws.run_forever()from cogchat.chat import CogChat
chat = CogChat()
# Create session
session_id = chat.create_session()
# Send message in session
response = chat.send_message("Hello", session_id=session_id)
# Get session history
history = chat.get_session_history(session_id)
# Clear session
chat.clear_session(session_id)CogChat maintains context across conversations:
# First message
response1 = chat.send_message("What is Python?")
# Follow-up question (uses context)
response2 = chat.send_message("What about JavaScript?")Customize the chat prompts:
from cogchat.chat import CogChat
chat = CogChat()
chat.set_system_prompt("You are a helpful AI assistant specializing in Python programming.")Issue: Server fails to start
Solution:
- Check if port is available
- Verify configuration
- Check logs for errors
Issue: Cannot connect to WebSocket server
Solution:
- Verify server is running
- Check firewall settings
- Verify URL is correct
Issue: Session data is lost
Solution:
- Check session timeout settings
- Enable session persistence
- Check disk space
- Use HTTPS/WSS in production
- Implement authentication
- Rate limit connections
- Sanitize user input
- Session encryption
For CogChat issues:
- Email: autobotsolution@gmail.com
- Address: Flushing MI
- Check logs for error messages