PraisonAI 0.1.0__cp312-cp312-manylinux_2_35_x86_64.whl → 0.1.2__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/realtime.py +47 -1
- praisonai/ui/realtimeclient/__init__.py +3 -0
- praisonai/ui/realtimeclient/realtimedocs.txt +1484 -0
- praisonai/ui/realtimeclient/tools.py +63 -20
- {praisonai-0.1.0.dist-info → praisonai-0.1.2.dist-info}/METADATA +12 -11
- {praisonai-0.1.0.dist-info → praisonai-0.1.2.dist-info}/RECORD +10 -9
- {praisonai-0.1.0.dist-info → praisonai-0.1.2.dist-info}/LICENSE +0 -0
- {praisonai-0.1.0.dist-info → praisonai-0.1.2.dist-info}/WHEEL +0 -0
- {praisonai-0.1.0.dist-info → praisonai-0.1.2.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==0.1.
|
|
59
|
+
file.write("RUN pip install flask praisonai==0.1.2 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/realtime.py
CHANGED
|
@@ -144,6 +144,50 @@ cl_data._data_layer = SQLAlchemyDataLayer(conninfo=f"sqlite+aiosqlite:///{DB_PAT
|
|
|
144
144
|
|
|
145
145
|
client = AsyncOpenAI()
|
|
146
146
|
|
|
147
|
+
# Add these new imports and code
|
|
148
|
+
import importlib.util
|
|
149
|
+
import logging
|
|
150
|
+
from importlib import import_module
|
|
151
|
+
from pathlib import Path
|
|
152
|
+
|
|
153
|
+
# Set up logging
|
|
154
|
+
logging.basicConfig(level=logging.INFO)
|
|
155
|
+
logger = logging.getLogger(__name__)
|
|
156
|
+
|
|
157
|
+
# Try to import tools from the root directory
|
|
158
|
+
root_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
159
|
+
tools_path = os.path.join(root_dir, 'tools.py')
|
|
160
|
+
logger.info(f"Tools path: {tools_path}")
|
|
161
|
+
|
|
162
|
+
def import_tools_from_file(file_path):
|
|
163
|
+
spec = importlib.util.spec_from_file_location("custom_tools", file_path)
|
|
164
|
+
custom_tools_module = importlib.util.module_from_spec(spec)
|
|
165
|
+
spec.loader.exec_module(custom_tools_module)
|
|
166
|
+
logger.debug(f"Imported tools from {file_path}")
|
|
167
|
+
logger.debug(f"Tools: {custom_tools_module}")
|
|
168
|
+
return custom_tools_module
|
|
169
|
+
|
|
170
|
+
try:
|
|
171
|
+
if os.path.exists(tools_path):
|
|
172
|
+
# tools.py exists in the root directory, import from file
|
|
173
|
+
custom_tools_module = import_tools_from_file(tools_path)
|
|
174
|
+
logger.info("Successfully imported custom tools from root tools.py")
|
|
175
|
+
else:
|
|
176
|
+
logger.info("No custom tools.py file found in the root directory")
|
|
177
|
+
custom_tools_module = None
|
|
178
|
+
|
|
179
|
+
if custom_tools_module:
|
|
180
|
+
# Update the tools list with custom tools
|
|
181
|
+
if hasattr(custom_tools_module, 'tools') and isinstance(custom_tools_module.tools, list):
|
|
182
|
+
tools.extend(custom_tools_module.tools)
|
|
183
|
+
else:
|
|
184
|
+
for name, obj in custom_tools_module.__dict__.items():
|
|
185
|
+
if callable(obj) and not name.startswith("__"):
|
|
186
|
+
tools.append(({"type": "function", "function": obj}, obj))
|
|
187
|
+
|
|
188
|
+
except Exception as e:
|
|
189
|
+
logger.warning(f"Error importing custom tools: {str(e)}. Continuing without custom tools.")
|
|
190
|
+
|
|
147
191
|
@cl.on_chat_start
|
|
148
192
|
async def start():
|
|
149
193
|
initialize_db()
|
|
@@ -365,4 +409,6 @@ async def on_chat_resume(thread: ThreadDict):
|
|
|
365
409
|
cl.user_session.set("message_history", message_history)
|
|
366
410
|
|
|
367
411
|
# Reconnect to OpenAI realtime
|
|
368
|
-
await setup_openai_realtime()
|
|
412
|
+
await setup_openai_realtime()
|
|
413
|
+
|
|
414
|
+
|
|
@@ -431,6 +431,8 @@ class RealtimeClient(RealtimeEventHandler):
|
|
|
431
431
|
self.dispatch("realtime.event", realtime_event)
|
|
432
432
|
|
|
433
433
|
def _on_session_created(self, event):
|
|
434
|
+
print(f"Session created: {event}")
|
|
435
|
+
logger.debug(f"Session created: {event}")
|
|
434
436
|
self.session_created = True
|
|
435
437
|
|
|
436
438
|
def _process_event(self, event, *args):
|
|
@@ -550,6 +552,7 @@ class RealtimeClient(RealtimeEventHandler):
|
|
|
550
552
|
for key in self.tools
|
|
551
553
|
]
|
|
552
554
|
session = {**self.session_config, "tools": use_tools}
|
|
555
|
+
logger.debug(f"Updating session: {session}")
|
|
553
556
|
if self.realtime.is_connected():
|
|
554
557
|
await self.realtime.send("session.update", {"session": session})
|
|
555
558
|
return True
|