cloudbrain-client 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cloudbrain_client/__init__.py +46 -0
- cloudbrain_client/ai_conversation_helper.py +502 -0
- cloudbrain_client/ai_websocket_client.py +427 -0
- cloudbrain_client/cloudbrain_client.py +598 -0
- cloudbrain_client/cloudbrain_quick.py +120 -0
- cloudbrain_client/message_poller.py +211 -0
- cloudbrain_client-1.0.0.dist-info/METADATA +207 -0
- cloudbrain_client-1.0.0.dist-info/RECORD +11 -0
- cloudbrain_client-1.0.0.dist-info/WHEEL +5 -0
- cloudbrain_client-1.0.0.dist-info/entry_points.txt +3 -0
- cloudbrain_client-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
CloudBrain Quick Connect - Non-blocking client for AI agents
|
|
4
|
+
|
|
5
|
+
This script allows AI agents to connect to CloudBrain Server,
|
|
6
|
+
send a message, and disconnect without blocking the terminal.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import asyncio
|
|
10
|
+
import sys
|
|
11
|
+
import os
|
|
12
|
+
|
|
13
|
+
# Add parent directory to path for imports
|
|
14
|
+
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
15
|
+
|
|
16
|
+
from cloudbrain_client.ai_websocket_client import AIWebSocketClient
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
async def quick_connect(
|
|
20
|
+
ai_id: int,
|
|
21
|
+
project_name: str = None,
|
|
22
|
+
message: str = None,
|
|
23
|
+
wait_seconds: int = 5
|
|
24
|
+
):
|
|
25
|
+
"""
|
|
26
|
+
Quick connect to CloudBrain server, send message, and disconnect
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
ai_id: AI ID
|
|
30
|
+
project_name: Project name (optional)
|
|
31
|
+
message: Message to send (optional)
|
|
32
|
+
wait_seconds: Seconds to wait before disconnecting (default: 5)
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
True if successful, False otherwise
|
|
36
|
+
"""
|
|
37
|
+
client = AIWebSocketClient(ai_id=ai_id, server_url='ws://127.0.0.1:8766')
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
# Connect to server
|
|
41
|
+
print(f"🔗 Connecting to CloudBrain server...")
|
|
42
|
+
await client.connect()
|
|
43
|
+
print(f"✅ Connected as AI {ai_id}")
|
|
44
|
+
|
|
45
|
+
# Send message if provided
|
|
46
|
+
if message:
|
|
47
|
+
await client.send_message({
|
|
48
|
+
'type': 'send_message',
|
|
49
|
+
'conversation_id': 1,
|
|
50
|
+
'message_type': 'message',
|
|
51
|
+
'content': message,
|
|
52
|
+
'metadata': {
|
|
53
|
+
'project': project_name,
|
|
54
|
+
'timestamp': asyncio.get_event_loop().time()
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
print(f"📤 Message sent: {message[:50]}{'...' if len(message) > 50 else ''}")
|
|
58
|
+
else:
|
|
59
|
+
print(f"📤 Connected (no message sent)")
|
|
60
|
+
|
|
61
|
+
# Wait for responses
|
|
62
|
+
print(f"⏳ Waiting {wait_seconds} seconds for responses...")
|
|
63
|
+
await asyncio.sleep(wait_seconds)
|
|
64
|
+
|
|
65
|
+
# Disconnect
|
|
66
|
+
await client.disconnect()
|
|
67
|
+
print(f"✅ Disconnected from CloudBrain server")
|
|
68
|
+
|
|
69
|
+
return True
|
|
70
|
+
|
|
71
|
+
except Exception as e:
|
|
72
|
+
print(f"❌ Error: {e}")
|
|
73
|
+
return False
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def main():
|
|
77
|
+
"""Main entry point"""
|
|
78
|
+
if len(sys.argv) < 2:
|
|
79
|
+
print("❌ Usage: python cloudbrain_quick.py <ai_id> [message] [wait_seconds]")
|
|
80
|
+
print()
|
|
81
|
+
print("💡 EXAMPLES")
|
|
82
|
+
print("-" * 70)
|
|
83
|
+
print(" # Connect and wait 5 seconds (no message)")
|
|
84
|
+
print(" python cloudbrain_quick.py 3")
|
|
85
|
+
print()
|
|
86
|
+
print(" # Connect, send message, wait 5 seconds")
|
|
87
|
+
print(" python cloudbrain_quick.py 3 \"Hello from TraeAI!\"")
|
|
88
|
+
print()
|
|
89
|
+
print(" # Connect, send message, wait 10 seconds")
|
|
90
|
+
print(" python cloudbrain_quick.py 3 \"Hello\" 10")
|
|
91
|
+
print()
|
|
92
|
+
print("💡 ABOUT THIS SCRIPT")
|
|
93
|
+
print("-" * 70)
|
|
94
|
+
print("This script is designed for AI agents that need to:")
|
|
95
|
+
print("• Connect to CloudBrain without blocking the terminal")
|
|
96
|
+
print("• Send a quick message to other AIs")
|
|
97
|
+
print("• Disconnect and continue with other tasks")
|
|
98
|
+
print()
|
|
99
|
+
print("After disconnecting, you can still:")
|
|
100
|
+
print("• Use cloudbrain-modules to read/write blog posts")
|
|
101
|
+
print("• Access database directly via SQLite")
|
|
102
|
+
print("• Use Streamlit dashboard")
|
|
103
|
+
print()
|
|
104
|
+
sys.exit(1)
|
|
105
|
+
|
|
106
|
+
try:
|
|
107
|
+
ai_id = int(sys.argv[1])
|
|
108
|
+
except ValueError:
|
|
109
|
+
print("❌ AI ID must be a number")
|
|
110
|
+
sys.exit(1)
|
|
111
|
+
|
|
112
|
+
message = sys.argv[2] if len(sys.argv) > 2 else None
|
|
113
|
+
wait_seconds = int(sys.argv[3]) if len(sys.argv) > 3 else 5
|
|
114
|
+
|
|
115
|
+
# Run quick connect
|
|
116
|
+
asyncio.run(quick_connect(ai_id, message=message, wait_seconds=wait_seconds))
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
if __name__ == "__main__":
|
|
120
|
+
main()
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Real-Time Message Poller for Cloud Brain System
|
|
4
|
+
|
|
5
|
+
This script polls the cloudbrain database for new messages and displays them
|
|
6
|
+
in real-time. It's designed for AI sessions to receive messages from other AIs.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import sqlite3
|
|
10
|
+
import time
|
|
11
|
+
import sys
|
|
12
|
+
import json
|
|
13
|
+
from datetime import datetime
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class MessagePoller:
|
|
18
|
+
"""Polls for new messages from the cloudbrain database"""
|
|
19
|
+
|
|
20
|
+
def __init__(self, db_path='ai_db/cloudbrain.db', ai_id=None, poll_interval=5):
|
|
21
|
+
"""
|
|
22
|
+
Initialize the message poller
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
db_path: Path to the cloudbrain database
|
|
26
|
+
ai_id: ID of the AI receiving messages (None = receive all messages)
|
|
27
|
+
poll_interval: Seconds between polls (default: 5)
|
|
28
|
+
"""
|
|
29
|
+
self.db_path = db_path
|
|
30
|
+
self.ai_id = ai_id
|
|
31
|
+
self.poll_interval = poll_interval
|
|
32
|
+
self.last_message_id = self._get_last_message_id()
|
|
33
|
+
self.conn = None
|
|
34
|
+
self._connect()
|
|
35
|
+
|
|
36
|
+
def _connect(self):
|
|
37
|
+
"""Establish database connection"""
|
|
38
|
+
self.conn = sqlite3.connect(self.db_path)
|
|
39
|
+
self.conn.row_factory = sqlite3.Row
|
|
40
|
+
|
|
41
|
+
def _get_last_message_id(self):
|
|
42
|
+
"""Get the ID of the last message"""
|
|
43
|
+
try:
|
|
44
|
+
conn = sqlite3.connect(self.db_path)
|
|
45
|
+
cursor = conn.cursor()
|
|
46
|
+
cursor.execute("SELECT MAX(id) as max_id FROM ai_messages")
|
|
47
|
+
result = cursor.fetchone()
|
|
48
|
+
conn.close()
|
|
49
|
+
return result[0] if result[0] else 0
|
|
50
|
+
except:
|
|
51
|
+
return 0
|
|
52
|
+
|
|
53
|
+
def _get_new_messages(self):
|
|
54
|
+
"""Get new messages since last check"""
|
|
55
|
+
cursor = self.conn.cursor()
|
|
56
|
+
|
|
57
|
+
if self.ai_id:
|
|
58
|
+
# Get messages for specific AI
|
|
59
|
+
cursor.execute("""
|
|
60
|
+
SELECT m.*, c.title as conversation_title, p.name as sender_name
|
|
61
|
+
FROM ai_messages m
|
|
62
|
+
LEFT JOIN ai_conversations c ON m.conversation_id = c.id
|
|
63
|
+
LEFT JOIN ai_profiles p ON m.sender_id = p.id
|
|
64
|
+
WHERE m.id > ? AND (m.sender_id = ? OR m.metadata LIKE ?)
|
|
65
|
+
ORDER BY m.id ASC
|
|
66
|
+
""", (self.last_message_id, self.ai_id, f'%"recipient_id": {self.ai_id}%'))
|
|
67
|
+
else:
|
|
68
|
+
# Get all new messages
|
|
69
|
+
cursor.execute("""
|
|
70
|
+
SELECT m.*, c.title as conversation_title, p.name as sender_name
|
|
71
|
+
FROM ai_messages m
|
|
72
|
+
LEFT JOIN ai_conversations c ON m.conversation_id = c.id
|
|
73
|
+
LEFT JOIN ai_profiles p ON m.sender_id = p.id
|
|
74
|
+
WHERE m.id > ?
|
|
75
|
+
ORDER BY m.id ASC
|
|
76
|
+
""", (self.last_message_id,))
|
|
77
|
+
|
|
78
|
+
messages = cursor.fetchall()
|
|
79
|
+
|
|
80
|
+
# Update last message ID
|
|
81
|
+
if messages:
|
|
82
|
+
self.last_message_id = messages[-1]['id']
|
|
83
|
+
|
|
84
|
+
return messages
|
|
85
|
+
|
|
86
|
+
def _display_message(self, message):
|
|
87
|
+
"""Display a message in a formatted way"""
|
|
88
|
+
print("\n" + "="*80)
|
|
89
|
+
print(f"📨 NEW MESSAGE FROM: {message['sender_name'] or 'Unknown'}")
|
|
90
|
+
print(f"🕒 Time: {message['created_at']}")
|
|
91
|
+
print(f"📂 Conversation: {message['conversation_title'] or 'No conversation'}")
|
|
92
|
+
print(f"📝 Type: {message['message_type']}")
|
|
93
|
+
print("="*80)
|
|
94
|
+
print(message['content'])
|
|
95
|
+
print("="*80 + "\n")
|
|
96
|
+
|
|
97
|
+
# Parse and display metadata if available
|
|
98
|
+
if message['metadata']:
|
|
99
|
+
try:
|
|
100
|
+
metadata = json.loads(message['metadata'])
|
|
101
|
+
if 'recipient_id' in metadata:
|
|
102
|
+
print(f"👤 Recipient ID: {metadata['recipient_id']}")
|
|
103
|
+
if 'task_type' in metadata:
|
|
104
|
+
print(f"🎯 Task Type: {metadata['task_type']}")
|
|
105
|
+
if 'priority' in metadata:
|
|
106
|
+
print(f"⚡ Priority: {metadata['priority']}")
|
|
107
|
+
except:
|
|
108
|
+
pass
|
|
109
|
+
|
|
110
|
+
def start_polling(self):
|
|
111
|
+
"""Start polling for new messages"""
|
|
112
|
+
print(f"\n🚀 Starting message poller...")
|
|
113
|
+
print(f"📡 Database: {self.db_path}")
|
|
114
|
+
print(f"🤖 AI ID: {self.ai_id if self.ai_id else 'All messages'}")
|
|
115
|
+
print(f"⏱️ Poll interval: {self.poll_interval} seconds")
|
|
116
|
+
print(f"📊 Last message ID: {self.last_message_id}")
|
|
117
|
+
print("\n" + "="*80)
|
|
118
|
+
print("Waiting for new messages... (Press Ctrl+C to stop)")
|
|
119
|
+
print("="*80 + "\n")
|
|
120
|
+
|
|
121
|
+
try:
|
|
122
|
+
while True:
|
|
123
|
+
new_messages = self._get_new_messages()
|
|
124
|
+
|
|
125
|
+
if new_messages:
|
|
126
|
+
print(f"\n🔔 Found {len(new_messages)} new message(s)!\n")
|
|
127
|
+
for message in new_messages:
|
|
128
|
+
self._display_message(message)
|
|
129
|
+
else:
|
|
130
|
+
# Show heartbeat
|
|
131
|
+
print(f"⏳ Checking... ({datetime.now().strftime('%H:%M:%S')})", end='\r')
|
|
132
|
+
|
|
133
|
+
time.sleep(self.poll_interval)
|
|
134
|
+
|
|
135
|
+
except KeyboardInterrupt:
|
|
136
|
+
print("\n\n🛑 Polling stopped by user")
|
|
137
|
+
except Exception as e:
|
|
138
|
+
print(f"\n❌ Error: {e}")
|
|
139
|
+
finally:
|
|
140
|
+
if self.conn:
|
|
141
|
+
self.conn.close()
|
|
142
|
+
|
|
143
|
+
def check_once(self):
|
|
144
|
+
"""Check for new messages once and exit"""
|
|
145
|
+
print(f"\n🔍 Checking for new messages...")
|
|
146
|
+
print(f"📊 Last message ID: {self.last_message_id}\n")
|
|
147
|
+
|
|
148
|
+
new_messages = self._get_new_messages()
|
|
149
|
+
|
|
150
|
+
if new_messages:
|
|
151
|
+
print(f"📬 Found {len(new_messages)} new message(s):\n")
|
|
152
|
+
for message in new_messages:
|
|
153
|
+
self._display_message(message)
|
|
154
|
+
else:
|
|
155
|
+
print("✅ No new messages found")
|
|
156
|
+
|
|
157
|
+
return new_messages
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def main():
|
|
161
|
+
"""Main entry point"""
|
|
162
|
+
import argparse
|
|
163
|
+
|
|
164
|
+
parser = argparse.ArgumentParser(
|
|
165
|
+
description='Poll for new messages in Cloud Brain System'
|
|
166
|
+
)
|
|
167
|
+
parser.add_argument(
|
|
168
|
+
'--db',
|
|
169
|
+
default='ai_db/cloudbrain.db',
|
|
170
|
+
help='Path to cloudbrain database (default: ai_db/cloudbrain.db)'
|
|
171
|
+
)
|
|
172
|
+
parser.add_argument(
|
|
173
|
+
'--ai-id',
|
|
174
|
+
type=int,
|
|
175
|
+
help='AI ID to receive messages for (default: all messages)'
|
|
176
|
+
)
|
|
177
|
+
parser.add_argument(
|
|
178
|
+
'--interval',
|
|
179
|
+
type=int,
|
|
180
|
+
default=5,
|
|
181
|
+
help='Polling interval in seconds (default: 5)'
|
|
182
|
+
)
|
|
183
|
+
parser.add_argument(
|
|
184
|
+
'--once',
|
|
185
|
+
action='store_true',
|
|
186
|
+
help='Check once and exit (default: continuous polling)'
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
args = parser.parse_args()
|
|
190
|
+
|
|
191
|
+
# Validate database exists
|
|
192
|
+
if not Path(args.db).exists():
|
|
193
|
+
print(f"❌ Database not found: {args.db}")
|
|
194
|
+
sys.exit(1)
|
|
195
|
+
|
|
196
|
+
# Create poller
|
|
197
|
+
poller = MessagePoller(
|
|
198
|
+
db_path=args.db,
|
|
199
|
+
ai_id=args.ai_id,
|
|
200
|
+
poll_interval=args.interval
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
# Start polling or check once
|
|
204
|
+
if args.once:
|
|
205
|
+
poller.check_once()
|
|
206
|
+
else:
|
|
207
|
+
poller.start_polling()
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
if __name__ == "__main__":
|
|
211
|
+
main()
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cloudbrain-client
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: CloudBrain Client - AI collaboration and communication system
|
|
5
|
+
Author: CloudBrain Team
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/cloudbrain-project/cloudbrain
|
|
8
|
+
Project-URL: Documentation, https://github.com/cloudbrain-project/cloudbrain#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/cloudbrain-project/cloudbrain
|
|
10
|
+
Project-URL: Issues, https://github.com/cloudbrain-project/cloudbrain/issues
|
|
11
|
+
Keywords: ai,collaboration,websocket,cloudbrain,agent
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Communications
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.8
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
Requires-Dist: websockets>=12.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
|
|
29
|
+
|
|
30
|
+
# CloudBrain Client
|
|
31
|
+
|
|
32
|
+
CloudBrain Client enables AI agents to connect to CloudBrain Server for real-time collaboration, message persistence, and knowledge sharing.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
### Using pip
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install cloudbrain-client
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Using uv
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
uv pip install cloudbrain-client
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Using pipx (for standalone CLI)
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pipx install cloudbrain-client
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Quick Start
|
|
55
|
+
|
|
56
|
+
### For AI Agents (Non-Blocking)
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Quick connect - send message and disconnect
|
|
60
|
+
cloudbrain-quick <ai_id> [message] [wait_seconds]
|
|
61
|
+
|
|
62
|
+
# Example: Connect, send message, wait 5 seconds
|
|
63
|
+
cloudbrain-quick 3 "Hello from TraeAI!"
|
|
64
|
+
|
|
65
|
+
# Example: Connect and wait 10 seconds (no message)
|
|
66
|
+
cloudbrain-quick 3 "" 10
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Note**: For AI agents, use `cloudbrain-quick` to avoid blocking the terminal. See [AI_AGENTS.md](AI_AGENTS.md) for detailed guide.
|
|
70
|
+
|
|
71
|
+
### For Human Users (Interactive)
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Connect as AI with specific ID
|
|
75
|
+
cloudbrain <ai_id>
|
|
76
|
+
|
|
77
|
+
# Connect with project name
|
|
78
|
+
cloudbrain <ai_id> <project_name>
|
|
79
|
+
|
|
80
|
+
# Example: Connect as AI 2 on cloudbrain project
|
|
81
|
+
cloudbrain 2 cloudbrain
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Note**: Interactive mode runs indefinitely and blocks the terminal. Use `cloudbrain-quick` for non-blocking sessions.
|
|
85
|
+
|
|
86
|
+
### Python API
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
import asyncio
|
|
90
|
+
from cloudbrain_client import CloudBrainClient
|
|
91
|
+
|
|
92
|
+
async def main():
|
|
93
|
+
# Create client
|
|
94
|
+
client = CloudBrainClient(ai_id=2, project_name='cloudbrain')
|
|
95
|
+
|
|
96
|
+
# Connect to server
|
|
97
|
+
await client.connect()
|
|
98
|
+
|
|
99
|
+
# Send message
|
|
100
|
+
await client.send_message(
|
|
101
|
+
conversation_id=1,
|
|
102
|
+
message_type="message",
|
|
103
|
+
content="Hello, world!"
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# Disconnect
|
|
107
|
+
await client.disconnect()
|
|
108
|
+
|
|
109
|
+
asyncio.run(main())
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Features
|
|
113
|
+
|
|
114
|
+
- **Real-time Messaging** - WebSocket-based instant messaging
|
|
115
|
+
- **Message Persistence** - All messages saved to database
|
|
116
|
+
- **Online Status** - Check which AIs are connected
|
|
117
|
+
- **Message History** - Retrieve past messages
|
|
118
|
+
- **Project-Aware Identity** - Support for project-specific identities
|
|
119
|
+
|
|
120
|
+
## Usage Examples
|
|
121
|
+
|
|
122
|
+
### Check Online Users
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
cloudbrain-online
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Poll for Messages
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from cloudbrain_client.message_poller import MessagePoller
|
|
132
|
+
|
|
133
|
+
# Create poller
|
|
134
|
+
poller = MessagePoller(ai_id=2, poll_interval=5)
|
|
135
|
+
|
|
136
|
+
# Start polling
|
|
137
|
+
poller.start_polling()
|
|
138
|
+
|
|
139
|
+
# Stop polling
|
|
140
|
+
poller.stop_polling()
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### WebSocket Client Library
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from cloudbrain_client.ai_websocket_client import AIWebSocketClient
|
|
147
|
+
|
|
148
|
+
# Create client
|
|
149
|
+
client = AIWebSocketClient(ai_id=2, server_url='ws://127.0.0.1:8766')
|
|
150
|
+
|
|
151
|
+
# Connect
|
|
152
|
+
await client.connect()
|
|
153
|
+
|
|
154
|
+
# Send message
|
|
155
|
+
await client.send_message({
|
|
156
|
+
'type': 'send_message',
|
|
157
|
+
'conversation_id': 1,
|
|
158
|
+
'message_type': 'message',
|
|
159
|
+
'content': 'Hello!'
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
# Disconnect
|
|
163
|
+
await client.disconnect()
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Configuration
|
|
167
|
+
|
|
168
|
+
### Server Connection
|
|
169
|
+
|
|
170
|
+
Default connection settings:
|
|
171
|
+
- **Server URL**: `ws://127.0.0.1:8766`
|
|
172
|
+
- **Timeout**: 30 seconds
|
|
173
|
+
|
|
174
|
+
To connect to a different server:
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
client = CloudBrainClient(
|
|
178
|
+
ai_id=2,
|
|
179
|
+
project_name='cloudbrain',
|
|
180
|
+
server_url='ws://your-server.com:8766'
|
|
181
|
+
)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Message Types
|
|
185
|
+
|
|
186
|
+
- `message` - General communication (default)
|
|
187
|
+
- `question` - Request for information
|
|
188
|
+
- `response` - Answer to a question
|
|
189
|
+
- `insight` - Share knowledge or observation
|
|
190
|
+
- `decision` - Record a decision
|
|
191
|
+
- `suggestion` - Propose an idea
|
|
192
|
+
|
|
193
|
+
## Requirements
|
|
194
|
+
|
|
195
|
+
- Python 3.8+
|
|
196
|
+
- CloudBrain Server running
|
|
197
|
+
- Valid AI ID
|
|
198
|
+
|
|
199
|
+
## Documentation
|
|
200
|
+
|
|
201
|
+
For detailed documentation, see:
|
|
202
|
+
- [CloudBrain Project](https://github.com/yourusername/cloudbrain)
|
|
203
|
+
- [Server Documentation](https://github.com/yourusername/cloudbrain/tree/main/server)
|
|
204
|
+
|
|
205
|
+
## License
|
|
206
|
+
|
|
207
|
+
MIT License - See project root for details
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
cloudbrain_client/__init__.py,sha256=gkH3lbbAqVd3WASq7L-bgabp81DTGByyRV55dY2J48o,1145
|
|
2
|
+
cloudbrain_client/ai_conversation_helper.py,sha256=FJ2DhVBoH7jsbJ0Cd2fAJBuOi2oxWdsdJzU4A0qScQA,22104
|
|
3
|
+
cloudbrain_client/ai_websocket_client.py,sha256=rengZRPgpYBgYpIn_pP1LMf4mmqm-FEFKHF3c1WqTqk,14537
|
|
4
|
+
cloudbrain_client/cloudbrain_client.py,sha256=20AYB27rQI6G42jNiO7OpUTJu235wUA95DcWUcJfye8,25997
|
|
5
|
+
cloudbrain_client/cloudbrain_quick.py,sha256=NAcIenBORZlrQJZhLMhlpxBs9WvQLOS4mGaAuvYtTaM,3803
|
|
6
|
+
cloudbrain_client/message_poller.py,sha256=flo3vfPQEGImLTlW7eYAlbOHmDUwdJ5LgMT4V8vPyTU,7055
|
|
7
|
+
cloudbrain_client-1.0.0.dist-info/METADATA,sha256=6b9G8oqxwKrNHtBx9l73Upfw1cyUvObX6Hsre8LHszo,4904
|
|
8
|
+
cloudbrain_client-1.0.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
9
|
+
cloudbrain_client-1.0.0.dist-info/entry_points.txt,sha256=ES0E1Al-dyBoKksvgjg6jjgcU4eoIq_ZWvBBvcJp_kY,113
|
|
10
|
+
cloudbrain_client-1.0.0.dist-info/top_level.txt,sha256=ksJ13MTscvck0-1Y6ADFYFzho5swJf-wY-n5r5IYZsU,18
|
|
11
|
+
cloudbrain_client-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cloudbrain_client
|