PraisonAI 1.0.2__cp312-cp312-manylinux_2_35_x86_64.whl → 1.0.4__cp312-cp312-manylinux_2_35_x86_64.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.
Potentially problematic release.
This version of PraisonAI might be problematic. Click here for more details.
- praisonai/deploy.py +1 -1
- praisonai/ui/chat.py +256 -131
- praisonai/ui/code.py +2 -5
- praisonai/ui/sql_alchemy.py +28 -26
- {praisonai-1.0.2.dist-info → praisonai-1.0.4.dist-info}/METADATA +1 -1
- {praisonai-1.0.2.dist-info → praisonai-1.0.4.dist-info}/RECORD +9 -9
- {praisonai-1.0.2.dist-info → praisonai-1.0.4.dist-info}/LICENSE +0 -0
- {praisonai-1.0.2.dist-info → praisonai-1.0.4.dist-info}/WHEEL +0 -0
- {praisonai-1.0.2.dist-info → praisonai-1.0.4.dist-info}/entry_points.txt +0 -0
praisonai/deploy.py
CHANGED
|
@@ -56,7 +56,7 @@ class CloudDeployer:
|
|
|
56
56
|
file.write("FROM python:3.11-slim\n")
|
|
57
57
|
file.write("WORKDIR /app\n")
|
|
58
58
|
file.write("COPY . .\n")
|
|
59
|
-
file.write("RUN pip install flask praisonai==1.0.
|
|
59
|
+
file.write("RUN pip install flask praisonai==1.0.4 gunicorn markdown\n")
|
|
60
60
|
file.write("EXPOSE 8080\n")
|
|
61
61
|
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
|
62
62
|
|
praisonai/ui/chat.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import chainlit as cl
|
|
2
2
|
from chainlit.input_widget import TextInput
|
|
3
|
-
from chainlit.types import ThreadDict
|
|
3
|
+
from chainlit.types import ThreadDict
|
|
4
4
|
from litellm import acompletion
|
|
5
5
|
import os
|
|
6
6
|
import sqlite3
|
|
@@ -9,7 +9,6 @@ from typing import Dict, List, Optional
|
|
|
9
9
|
from dotenv import load_dotenv
|
|
10
10
|
load_dotenv()
|
|
11
11
|
import chainlit.data as cl_data
|
|
12
|
-
from chainlit.step import StepDict
|
|
13
12
|
from literalai.helper import utc_now
|
|
14
13
|
import logging
|
|
15
14
|
import json
|
|
@@ -20,6 +19,8 @@ import asyncio
|
|
|
20
19
|
from PIL import Image
|
|
21
20
|
import io
|
|
22
21
|
import base64
|
|
22
|
+
from sqlalchemy import text
|
|
23
|
+
from sqlalchemy.exc import DatabaseError
|
|
23
24
|
|
|
24
25
|
# Set up logging
|
|
25
26
|
logger = logging.getLogger(__name__)
|
|
@@ -48,140 +49,221 @@ create_step_counter = 0
|
|
|
48
49
|
|
|
49
50
|
DB_PATH = os.path.expanduser("~/.praison/database.sqlite")
|
|
50
51
|
|
|
51
|
-
def
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
52
|
+
async def create_tables(engine):
|
|
53
|
+
"""Create all necessary tables if they don't exist."""
|
|
54
|
+
try:
|
|
55
|
+
async with engine.begin() as conn:
|
|
56
|
+
# Check if we're using PostgreSQL
|
|
57
|
+
dialect = engine.dialect.name
|
|
58
|
+
if dialect == 'postgresql':
|
|
59
|
+
# Create tables with PostgreSQL-specific types
|
|
60
|
+
await conn.execute(text("""
|
|
61
|
+
CREATE TABLE IF NOT EXISTS users (
|
|
62
|
+
id UUID PRIMARY KEY,
|
|
63
|
+
identifier TEXT NOT NULL UNIQUE,
|
|
64
|
+
metadata JSONB NOT NULL,
|
|
65
|
+
created_at TEXT
|
|
66
|
+
)
|
|
67
|
+
"""))
|
|
68
|
+
|
|
69
|
+
await conn.execute(text("""
|
|
70
|
+
CREATE TABLE IF NOT EXISTS threads (
|
|
71
|
+
id UUID PRIMARY KEY,
|
|
72
|
+
created_at TEXT,
|
|
73
|
+
name TEXT,
|
|
74
|
+
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
|
|
75
|
+
user_identifier TEXT,
|
|
76
|
+
tags TEXT[],
|
|
77
|
+
metadata JSONB NOT NULL DEFAULT '{}'
|
|
78
|
+
)
|
|
79
|
+
"""))
|
|
80
|
+
|
|
81
|
+
await conn.execute(text("""
|
|
82
|
+
CREATE TABLE IF NOT EXISTS steps (
|
|
83
|
+
id UUID PRIMARY KEY,
|
|
84
|
+
name TEXT NOT NULL,
|
|
85
|
+
type TEXT NOT NULL,
|
|
86
|
+
thread_id UUID NOT NULL REFERENCES threads(id) ON DELETE CASCADE,
|
|
87
|
+
parent_id UUID,
|
|
88
|
+
disable_feedback BOOLEAN NOT NULL DEFAULT false,
|
|
89
|
+
streaming BOOLEAN NOT NULL DEFAULT false,
|
|
90
|
+
wait_for_answer BOOLEAN DEFAULT false,
|
|
91
|
+
is_error BOOLEAN NOT NULL DEFAULT false,
|
|
92
|
+
metadata JSONB DEFAULT '{}',
|
|
93
|
+
tags TEXT[],
|
|
94
|
+
input TEXT,
|
|
95
|
+
output TEXT,
|
|
96
|
+
created_at TEXT,
|
|
97
|
+
start_time TEXT,
|
|
98
|
+
end_time TEXT,
|
|
99
|
+
generation JSONB,
|
|
100
|
+
show_input TEXT,
|
|
101
|
+
language TEXT,
|
|
102
|
+
indent INTEGER
|
|
103
|
+
)
|
|
104
|
+
"""))
|
|
105
|
+
|
|
106
|
+
await conn.execute(text("""
|
|
107
|
+
CREATE TABLE IF NOT EXISTS elements (
|
|
108
|
+
id UUID PRIMARY KEY,
|
|
109
|
+
thread_id UUID REFERENCES threads(id) ON DELETE CASCADE,
|
|
110
|
+
type TEXT,
|
|
111
|
+
url TEXT,
|
|
112
|
+
chainlit_key TEXT,
|
|
113
|
+
name TEXT NOT NULL,
|
|
114
|
+
display TEXT,
|
|
115
|
+
object_key TEXT,
|
|
116
|
+
size TEXT,
|
|
117
|
+
page INTEGER,
|
|
118
|
+
language TEXT,
|
|
119
|
+
for_id UUID,
|
|
120
|
+
mime TEXT
|
|
121
|
+
)
|
|
122
|
+
"""))
|
|
123
|
+
|
|
124
|
+
await conn.execute(text("""
|
|
125
|
+
CREATE TABLE IF NOT EXISTS feedbacks (
|
|
126
|
+
id UUID PRIMARY KEY,
|
|
127
|
+
for_id UUID NOT NULL,
|
|
128
|
+
value INTEGER NOT NULL,
|
|
129
|
+
thread_id UUID,
|
|
130
|
+
comment TEXT
|
|
131
|
+
)
|
|
132
|
+
"""))
|
|
133
|
+
|
|
134
|
+
await conn.execute(text("""
|
|
135
|
+
CREATE TABLE IF NOT EXISTS settings (
|
|
136
|
+
id SERIAL PRIMARY KEY,
|
|
137
|
+
key TEXT UNIQUE,
|
|
138
|
+
value TEXT
|
|
139
|
+
)
|
|
140
|
+
"""))
|
|
141
|
+
|
|
142
|
+
# Create indexes
|
|
143
|
+
await conn.execute(text(
|
|
144
|
+
"CREATE INDEX IF NOT EXISTS idx_steps_thread_id ON steps(thread_id)"
|
|
145
|
+
))
|
|
146
|
+
await conn.execute(text(
|
|
147
|
+
"CREATE INDEX IF NOT EXISTS idx_threads_created_at ON threads(created_at DESC)"
|
|
148
|
+
))
|
|
149
|
+
else:
|
|
150
|
+
# SQLite tables (existing schema)
|
|
151
|
+
await conn.execute(text("""
|
|
152
|
+
CREATE TABLE IF NOT EXISTS users (
|
|
153
|
+
id TEXT PRIMARY KEY,
|
|
154
|
+
identifier TEXT NOT NULL UNIQUE,
|
|
155
|
+
metadata TEXT NOT NULL,
|
|
156
|
+
created_at TEXT
|
|
157
|
+
)
|
|
158
|
+
"""))
|
|
159
|
+
|
|
160
|
+
await conn.execute(text("""
|
|
161
|
+
CREATE TABLE IF NOT EXISTS threads (
|
|
162
|
+
id TEXT PRIMARY KEY,
|
|
163
|
+
created_at TEXT,
|
|
164
|
+
name TEXT,
|
|
165
|
+
user_id TEXT REFERENCES users(id) ON DELETE CASCADE,
|
|
166
|
+
user_identifier TEXT,
|
|
167
|
+
tags TEXT,
|
|
168
|
+
metadata TEXT NOT NULL DEFAULT '{}'
|
|
169
|
+
)
|
|
170
|
+
"""))
|
|
171
|
+
|
|
172
|
+
await conn.execute(text("""
|
|
173
|
+
CREATE TABLE IF NOT EXISTS steps (
|
|
174
|
+
id TEXT PRIMARY KEY,
|
|
175
|
+
name TEXT NOT NULL,
|
|
176
|
+
type TEXT NOT NULL,
|
|
177
|
+
thread_id TEXT NOT NULL REFERENCES threads(id) ON DELETE CASCADE,
|
|
178
|
+
parent_id TEXT,
|
|
179
|
+
disable_feedback INTEGER NOT NULL DEFAULT 0,
|
|
180
|
+
streaming INTEGER NOT NULL DEFAULT 0,
|
|
181
|
+
wait_for_answer INTEGER DEFAULT 0,
|
|
182
|
+
is_error INTEGER NOT NULL DEFAULT 0,
|
|
183
|
+
metadata TEXT DEFAULT '{}',
|
|
184
|
+
tags TEXT,
|
|
185
|
+
input TEXT,
|
|
186
|
+
output TEXT,
|
|
187
|
+
created_at TEXT,
|
|
188
|
+
start_time TEXT,
|
|
189
|
+
end_time TEXT,
|
|
190
|
+
generation TEXT,
|
|
191
|
+
show_input TEXT,
|
|
192
|
+
language TEXT,
|
|
193
|
+
indent INTEGER
|
|
194
|
+
)
|
|
195
|
+
"""))
|
|
196
|
+
|
|
197
|
+
await conn.execute(text("""
|
|
198
|
+
CREATE TABLE IF NOT EXISTS elements (
|
|
199
|
+
id TEXT PRIMARY KEY,
|
|
200
|
+
thread_id TEXT REFERENCES threads(id) ON DELETE CASCADE,
|
|
201
|
+
type TEXT,
|
|
202
|
+
url TEXT,
|
|
203
|
+
chainlit_key TEXT,
|
|
204
|
+
name TEXT NOT NULL,
|
|
205
|
+
display TEXT,
|
|
206
|
+
object_key TEXT,
|
|
207
|
+
size TEXT,
|
|
208
|
+
page INTEGER,
|
|
209
|
+
language TEXT,
|
|
210
|
+
for_id TEXT,
|
|
211
|
+
mime TEXT
|
|
212
|
+
)
|
|
213
|
+
"""))
|
|
214
|
+
|
|
215
|
+
await conn.execute(text("""
|
|
216
|
+
CREATE TABLE IF NOT EXISTS feedbacks (
|
|
217
|
+
id TEXT PRIMARY KEY,
|
|
218
|
+
for_id TEXT NOT NULL,
|
|
219
|
+
value INTEGER NOT NULL,
|
|
220
|
+
thread_id TEXT,
|
|
221
|
+
comment TEXT
|
|
222
|
+
)
|
|
223
|
+
"""))
|
|
224
|
+
|
|
225
|
+
await conn.execute(text("""
|
|
226
|
+
CREATE TABLE IF NOT EXISTS settings (
|
|
227
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
228
|
+
key TEXT UNIQUE,
|
|
229
|
+
value TEXT
|
|
230
|
+
)
|
|
231
|
+
"""))
|
|
232
|
+
|
|
233
|
+
# Create indexes
|
|
234
|
+
await conn.execute(text(
|
|
235
|
+
"CREATE INDEX IF NOT EXISTS idx_steps_thread_id ON steps(thread_id)"
|
|
236
|
+
))
|
|
237
|
+
await conn.execute(text(
|
|
238
|
+
"CREATE INDEX IF NOT EXISTS idx_threads_created_at ON threads(created_at DESC)"
|
|
239
|
+
))
|
|
240
|
+
|
|
241
|
+
logger.info(f"Successfully created tables for {dialect} database")
|
|
242
|
+
except Exception as e:
|
|
243
|
+
logger.error(f"Error creating tables: {str(e)}")
|
|
244
|
+
from sqlalchemy.exc import DatabaseError as SQLAlchemyDatabaseError
|
|
245
|
+
raise SQLAlchemyDatabaseError(statement=str(e), params=None, orig=e)
|
|
172
246
|
|
|
173
247
|
# Initialize the database
|
|
174
|
-
initialize_db()
|
|
175
|
-
|
|
176
|
-
deleted_thread_ids = [] # type: List[str]
|
|
248
|
+
async def initialize_db():
|
|
249
|
+
await create_tables(cl_data._data_layer.engine)
|
|
177
250
|
|
|
178
251
|
# Get database connection string from environment variable or use SQLite as default
|
|
179
252
|
DB_URL = os.getenv("DATABASE_URL", f"sqlite+aiosqlite:///{DB_PATH}")
|
|
253
|
+
if DB_URL.startswith('postgresql'):
|
|
254
|
+
# Convert postgresql:// to postgresql+psycopg:// if needed
|
|
255
|
+
DB_URL = DB_URL.replace('postgresql://', 'postgresql+psycopg://')
|
|
256
|
+
|
|
257
|
+
# Initialize SQLAlchemy data layer
|
|
180
258
|
cl_data._data_layer = SQLAlchemyDataLayer(
|
|
181
259
|
conninfo=DB_URL,
|
|
182
260
|
ssl_require=bool(os.getenv("DATABASE_SSL", False))
|
|
183
261
|
)
|
|
184
262
|
|
|
263
|
+
# Create tables if using PostgreSQL
|
|
264
|
+
if DB_URL.startswith('postgresql'):
|
|
265
|
+
asyncio.run(initialize_db())
|
|
266
|
+
|
|
185
267
|
# Set Tavily API key
|
|
186
268
|
tavily_api_key = os.getenv("TAVILY_API_KEY")
|
|
187
269
|
tavily_client = TavilyClient(api_key=tavily_api_key) if tavily_api_key else None
|
|
@@ -241,10 +323,53 @@ tools = [{
|
|
|
241
323
|
}
|
|
242
324
|
}] if tavily_api_key else []
|
|
243
325
|
|
|
326
|
+
async def save_setting(key: str, value: str):
|
|
327
|
+
"""Saves a setting to the database.
|
|
328
|
+
|
|
329
|
+
Args:
|
|
330
|
+
key: The setting key.
|
|
331
|
+
value: The setting value.
|
|
332
|
+
"""
|
|
333
|
+
try:
|
|
334
|
+
async with cl_data._data_layer.engine.begin() as conn:
|
|
335
|
+
await conn.execute(
|
|
336
|
+
text("""
|
|
337
|
+
INSERT INTO settings (key, value)
|
|
338
|
+
VALUES (:key, :value)
|
|
339
|
+
ON CONFLICT (key) DO UPDATE SET value = :value
|
|
340
|
+
"""),
|
|
341
|
+
{"key": key, "value": value}
|
|
342
|
+
)
|
|
343
|
+
logger.debug(f"Saved setting {key}={value}")
|
|
344
|
+
except Exception as e:
|
|
345
|
+
logger.error(f"Error saving setting {key}: {str(e)}")
|
|
346
|
+
raise DatabaseError(f"Failed to save setting: {str(e)}")
|
|
347
|
+
|
|
348
|
+
async def load_setting(key: str) -> str:
|
|
349
|
+
"""Loads a setting from the database.
|
|
350
|
+
|
|
351
|
+
Args:
|
|
352
|
+
key: The setting key.
|
|
353
|
+
|
|
354
|
+
Returns:
|
|
355
|
+
The setting value, or None if the key is not found.
|
|
356
|
+
"""
|
|
357
|
+
try:
|
|
358
|
+
async with cl_data._data_layer.engine.connect() as conn:
|
|
359
|
+
result = await conn.execute(
|
|
360
|
+
text("SELECT value FROM settings WHERE key = :key"),
|
|
361
|
+
{"key": key}
|
|
362
|
+
)
|
|
363
|
+
row = result.fetchone()
|
|
364
|
+
return row[0] if row else None
|
|
365
|
+
except Exception as e:
|
|
366
|
+
logger.error(f"Error loading setting {key}: {str(e)}")
|
|
367
|
+
return None
|
|
368
|
+
|
|
244
369
|
@cl.on_chat_start
|
|
245
370
|
async def start():
|
|
246
|
-
initialize_db()
|
|
247
|
-
model_name = load_setting("model_name")
|
|
371
|
+
await initialize_db()
|
|
372
|
+
model_name = await load_setting("model_name")
|
|
248
373
|
|
|
249
374
|
if model_name:
|
|
250
375
|
cl.user_session.set("model_name", model_name)
|
|
@@ -274,7 +399,7 @@ async def setup_agent(settings):
|
|
|
274
399
|
cl.user_session.set("model_name", model_name)
|
|
275
400
|
|
|
276
401
|
# Save in settings table
|
|
277
|
-
save_setting("model_name", model_name)
|
|
402
|
+
await save_setting("model_name", model_name)
|
|
278
403
|
|
|
279
404
|
# Save in thread metadata
|
|
280
405
|
thread_id = cl.user_session.get("thread_id")
|
|
@@ -292,7 +417,7 @@ async def setup_agent(settings):
|
|
|
292
417
|
|
|
293
418
|
@cl.on_message
|
|
294
419
|
async def main(message: cl.Message):
|
|
295
|
-
model_name = load_setting("model_name") or os.getenv("MODEL_NAME") or "gpt-4o-mini"
|
|
420
|
+
model_name = await load_setting("model_name") or os.getenv("MODEL_NAME") or "gpt-4o-mini"
|
|
296
421
|
message_history = cl.user_session.get("message_history", [])
|
|
297
422
|
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
298
423
|
|
|
@@ -474,7 +599,7 @@ async def send_count():
|
|
|
474
599
|
@cl.on_chat_resume
|
|
475
600
|
async def on_chat_resume(thread: ThreadDict):
|
|
476
601
|
logger.info(f"Resuming chat: {thread['id']}")
|
|
477
|
-
model_name = load_setting("model_name") or os.getenv("MODEL_NAME") or "gpt-4o-mini"
|
|
602
|
+
model_name = await load_setting("model_name") or os.getenv("MODEL_NAME") or "gpt-4o-mini"
|
|
478
603
|
logger.debug(f"Model name: {model_name}")
|
|
479
604
|
settings = cl.ChatSettings(
|
|
480
605
|
[
|
praisonai/ui/code.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import chainlit as cl
|
|
2
2
|
from chainlit.input_widget import TextInput
|
|
3
|
-
from chainlit.types import ThreadDict
|
|
4
|
-
from litellm import acompletion, completion
|
|
3
|
+
from chainlit.types import ThreadDict, StepDict
|
|
5
4
|
import os
|
|
6
5
|
import sqlite3
|
|
7
6
|
from datetime import datetime
|
|
@@ -9,8 +8,6 @@ from typing import Dict, List, Optional
|
|
|
9
8
|
from dotenv import load_dotenv
|
|
10
9
|
load_dotenv()
|
|
11
10
|
import chainlit.data as cl_data
|
|
12
|
-
from chainlit.step import StepDict
|
|
13
|
-
from literalai.helper import utc_now
|
|
14
11
|
import logging
|
|
15
12
|
import json
|
|
16
13
|
from sql_alchemy import SQLAlchemyDataLayer
|
|
@@ -43,7 +40,7 @@ if not CHAINLIT_AUTH_SECRET:
|
|
|
43
40
|
os.environ["CHAINLIT_AUTH_SECRET"] = "p8BPhQChpg@J>jBz$wGxqLX2V>yTVgP*7Ky9H$aV:axW~ANNX-7_T:o@lnyCBu^U"
|
|
44
41
|
CHAINLIT_AUTH_SECRET = os.getenv("CHAINLIT_AUTH_SECRET")
|
|
45
42
|
|
|
46
|
-
now =
|
|
43
|
+
now = datetime.now()
|
|
47
44
|
|
|
48
45
|
create_step_counter = 0
|
|
49
46
|
|
praisonai/ui/sql_alchemy.py
CHANGED
|
@@ -12,6 +12,7 @@ from chainlit.data.base import BaseDataLayer, BaseStorageClient
|
|
|
12
12
|
from chainlit.data.utils import queue_until_user_message
|
|
13
13
|
from chainlit.element import ElementDict
|
|
14
14
|
from chainlit.logger import logger
|
|
15
|
+
from chainlit.message import Message
|
|
15
16
|
from chainlit.step import StepDict
|
|
16
17
|
from chainlit.types import (
|
|
17
18
|
Feedback,
|
|
@@ -204,9 +205,10 @@ class SQLAlchemyDataLayer(BaseDataLayer):
|
|
|
204
205
|
async def get_thread(self, thread_id: str) -> Optional[ThreadDict]:
|
|
205
206
|
if self.show_logger:
|
|
206
207
|
logger.info(f"SQLAlchemy: get_thread, thread_id={thread_id}")
|
|
207
|
-
user_threads: Optional[List[ThreadDict]] =
|
|
208
|
-
thread_id=thread_id
|
|
208
|
+
user_threads: Optional[List[ThreadDict]] = (
|
|
209
|
+
await self.get_all_user_threads(thread_id=thread_id) or []
|
|
209
210
|
)
|
|
211
|
+
|
|
210
212
|
if user_threads:
|
|
211
213
|
return user_threads[0]
|
|
212
214
|
else:
|
|
@@ -335,7 +337,7 @@ class SQLAlchemyDataLayer(BaseDataLayer):
|
|
|
335
337
|
|
|
336
338
|
###### Steps ######
|
|
337
339
|
@queue_until_user_message()
|
|
338
|
-
async def create_step(self, step_dict:
|
|
340
|
+
async def create_step(self, step_dict: dict):
|
|
339
341
|
if self.show_logger:
|
|
340
342
|
logger.info(f"SQLAlchemy: create_step, step_id={step_dict.get('id')}")
|
|
341
343
|
|
|
@@ -365,7 +367,7 @@ class SQLAlchemyDataLayer(BaseDataLayer):
|
|
|
365
367
|
await self.execute_sql(query=query, parameters=parameters)
|
|
366
368
|
|
|
367
369
|
@queue_until_user_message()
|
|
368
|
-
async def update_step(self, step_dict:
|
|
370
|
+
async def update_step(self, step_dict: dict):
|
|
369
371
|
if self.show_logger:
|
|
370
372
|
logger.info(f"SQLAlchemy: update_step, step_id={step_dict.get('id')}")
|
|
371
373
|
await self.create_step(step_dict)
|
|
@@ -646,37 +648,37 @@ class SQLAlchemyDataLayer(BaseDataLayer):
|
|
|
646
648
|
value=step_feedback["feedback_value"],
|
|
647
649
|
comment=step_feedback.get("feedback_comment"),
|
|
648
650
|
)
|
|
649
|
-
step_dict =
|
|
650
|
-
id
|
|
651
|
-
name
|
|
652
|
-
type
|
|
653
|
-
threadId
|
|
654
|
-
parentId
|
|
655
|
-
streaming
|
|
656
|
-
waitForAnswer
|
|
657
|
-
isError
|
|
658
|
-
metadata
|
|
651
|
+
step_dict = {
|
|
652
|
+
"id": step_feedback["step_id"],
|
|
653
|
+
"name": step_feedback["step_name"],
|
|
654
|
+
"type": step_feedback["step_type"],
|
|
655
|
+
"threadId": thread_id,
|
|
656
|
+
"parentId": step_feedback.get("step_parentid"),
|
|
657
|
+
"streaming": step_feedback.get("step_streaming", False),
|
|
658
|
+
"waitForAnswer": step_feedback.get("step_waitforanswer"),
|
|
659
|
+
"isError": step_feedback.get("step_iserror"),
|
|
660
|
+
"metadata": (
|
|
659
661
|
step_feedback["step_metadata"]
|
|
660
662
|
if step_feedback.get("step_metadata") is not None
|
|
661
663
|
else {}
|
|
662
664
|
),
|
|
663
|
-
tags
|
|
664
|
-
input
|
|
665
|
+
"tags": step_feedback.get("step_tags"),
|
|
666
|
+
"input": (
|
|
665
667
|
step_feedback.get("step_input", "")
|
|
666
668
|
if step_feedback.get("step_showinput")
|
|
667
669
|
not in [None, "false"]
|
|
668
670
|
else ""
|
|
669
671
|
),
|
|
670
|
-
output
|
|
671
|
-
createdAt
|
|
672
|
-
start
|
|
673
|
-
end
|
|
674
|
-
generation
|
|
675
|
-
showInput
|
|
676
|
-
language
|
|
677
|
-
indent
|
|
678
|
-
feedback
|
|
679
|
-
|
|
672
|
+
"output": step_feedback.get("step_output", ""),
|
|
673
|
+
"createdAt": step_feedback.get("step_createdat"),
|
|
674
|
+
"start": step_feedback.get("step_start"),
|
|
675
|
+
"end": step_feedback.get("step_end"),
|
|
676
|
+
"generation": step_feedback.get("step_generation"),
|
|
677
|
+
"showInput": step_feedback.get("step_showinput"),
|
|
678
|
+
"language": step_feedback.get("step_language"),
|
|
679
|
+
"indent": step_feedback.get("step_indent"),
|
|
680
|
+
"feedback": feedback,
|
|
681
|
+
}
|
|
680
682
|
# Append the step to the steps list of the corresponding ThreadDict
|
|
681
683
|
thread_dicts[thread_id]["steps"].append(step_dict)
|
|
682
684
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PraisonAI
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.4
|
|
4
4
|
Summary: PraisonAI application combines AutoGen and CrewAI or similar frameworks into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customization, and efficient human-agent collaboration.
|
|
5
5
|
Author: Mervin Praison
|
|
6
6
|
Requires-Python: >=3.10,<3.13
|
|
@@ -5,7 +5,7 @@ praisonai/api/call.py,sha256=iHdAlgIH_oTsEbjaGGu1Jjo6DTfMR-SfFdtSxnOLCeY,11032
|
|
|
5
5
|
praisonai/auto.py,sha256=NDQiTV8ex_NE5C6AoY26-gMyLZNYrfthgQ6G0Dn1uhU,8304
|
|
6
6
|
praisonai/chainlit_ui.py,sha256=bNR7s509lp0I9JlJNvwCZRUZosC64qdvlFCt8NmFamQ,12216
|
|
7
7
|
praisonai/cli.py,sha256=Rg6vikTv4LHR1R6BIEzcaBWFvkdRZr0nOkMi6RCPKh8,21224
|
|
8
|
-
praisonai/deploy.py,sha256=
|
|
8
|
+
praisonai/deploy.py,sha256=pxDKqvLhkqdAiUaf9Kgse3YhBfbqeEJzVOQV3XJjfZg,6027
|
|
9
9
|
praisonai/inbuilt_tools/__init__.py,sha256=fai4ZJIKz7-iOnGZv5jJX0wmT77PKa4x2jqyaJddKFA,569
|
|
10
10
|
praisonai/inbuilt_tools/autogen_tools.py,sha256=kJdEv61BTYvdHOaURNEpBcWq8Rs-oC03loNFTIjT-ak,4687
|
|
11
11
|
praisonai/inc/__init__.py,sha256=sPDlYBBwdk0VlWzaaM_lG0_LD07lS2HRGvPdxXJFiYg,62
|
|
@@ -32,8 +32,8 @@ praisonai/setup/setup_conda_env.sh,sha256=te7s0KHsTi7XM-vkNvE0dKC1HeU2tXxqE-sPUS
|
|
|
32
32
|
praisonai/setup.py,sha256=0jHgKnIPCtBZiGYaYyTz3PzrJI6nBy55VXk2UctXlDo,373
|
|
33
33
|
praisonai/test.py,sha256=OL-wesjA5JTohr8rtr6kWoaS4ImkJg2l0GXJ-dUUfRU,4090
|
|
34
34
|
praisonai/train.py,sha256=DvORlrwKOD-2v4r_z84eV3LsfzpNs-WnPKb5cQB3_t4,11071
|
|
35
|
-
praisonai/ui/chat.py,sha256=
|
|
36
|
-
praisonai/ui/code.py,sha256=
|
|
35
|
+
praisonai/ui/chat.py,sha256=xLiYr79CiThzudaSvwYeHxIp3qnIHN02z-lJJxCBKP4,24527
|
|
36
|
+
praisonai/ui/code.py,sha256=YP100uHF6BpMyzVh_lgv32GUFLkMu88LXyoSIzv06Wg,18799
|
|
37
37
|
praisonai/ui/context.py,sha256=oWO2I_WBZb7kZnuXItf18EJX0ZQv-1nAd8rxhwhuuDU,11871
|
|
38
38
|
praisonai/ui/public/fantasy.svg,sha256=4Gs3kIOux-pjGtw6ogI_rv5_viVJxnE5gRwGilsSg0o,1553
|
|
39
39
|
praisonai/ui/public/game.svg,sha256=y2QMaA01m8XzuDjTOBWzupOC3-TpnUl9ah89mIhviUw,2406
|
|
@@ -45,10 +45,10 @@ praisonai/ui/realtime.py,sha256=qpgcGA8CIUfYuSXtQM0zSlxktFtUZXsryn0Tru-R5wU,1530
|
|
|
45
45
|
praisonai/ui/realtimeclient/__init__.py,sha256=zA2xa7rBUSw77wFkndJMQNNPqdH6ywQ3uf4WSYHjNfs,27513
|
|
46
46
|
praisonai/ui/realtimeclient/realtimedocs.txt,sha256=hmgd8Uwy2SkjSndyyF_-ZOaNxiyHwGaQLGc67DvV-sI,26395
|
|
47
47
|
praisonai/ui/realtimeclient/tools.py,sha256=IJOYwVOBW5Ocn5_iV9pFkmSKR3WU3YpX3kwF0I3jikQ,7855
|
|
48
|
-
praisonai/ui/sql_alchemy.py,sha256=
|
|
48
|
+
praisonai/ui/sql_alchemy.py,sha256=gFqeq70R7FyZyYnE_J0SzdhviVqzFJgplNG-2a0JH8I,29970
|
|
49
49
|
praisonai/version.py,sha256=ugyuFliEqtAwQmH4sTlc16YXKYbFWDmfyk87fErB8-8,21
|
|
50
|
-
praisonai-1.0.
|
|
51
|
-
praisonai-1.0.
|
|
52
|
-
praisonai-1.0.
|
|
53
|
-
praisonai-1.0.
|
|
54
|
-
praisonai-1.0.
|
|
50
|
+
praisonai-1.0.4.dist-info/LICENSE,sha256=kqvFysVlnFxYOu0HxCe2HlmZmJtdmNGOxWRRkT9TsWc,1035
|
|
51
|
+
praisonai-1.0.4.dist-info/METADATA,sha256=5o0ngmKMBz1vBcT31ArQPVZdJwNLO_oDJM8vMaxcGTk,17085
|
|
52
|
+
praisonai-1.0.4.dist-info/WHEEL,sha256=Ie8mbC-etDUh6aDhzdvvvp_A-4mQQX7whlOFBnSJhcE,110
|
|
53
|
+
praisonai-1.0.4.dist-info/entry_points.txt,sha256=I_xc6a6MNTTfLxYmAxe0rgey0G-_hbY07oFW-ZDnkw4,135
|
|
54
|
+
praisonai-1.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|