Skip to content
Merged
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
17 changes: 13 additions & 4 deletions src/praisonai/praisonai/api/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,32 +357,41 @@ def setup_public_url(port):
print(f"Praison AI Voice URL: {public_url}")
return public_url

def run_server(port: int, use_public: bool = False):
def run_server(port: int, host: str = "127.0.0.1", use_public: bool = False):
"""Run the FastAPI server using uvicorn."""
if not OPENAI_API_KEY:
raise ValueError('Missing the OpenAI API key. Please set it in the .env file or configure it through the GUI.')

if use_public:
setup_public_url(port)
host = "0.0.0.0" # ngrok needs all-interfaces
else:
print(f"Starting Praison AI Call Server on http://localhost:{port}")
uvicorn.run(app, host="0.0.0.0", port=port, log_level="warning")
print(f"Starting Praison AI Call Server on http://{host}:{port}")

# Log warning if binding to all interfaces without public flag
if host == "0.0.0.0" and not use_public:
print("WARNING: Server is binding to all network interfaces (0.0.0.0). "
"This exposes the service to your local network.")

uvicorn.run(app, host=host, port=port, log_level="warning")

def main(args=None):
"""Run the Praison AI Call Server."""
parser = argparse.ArgumentParser(description="Run the Praison AI Call Server.")
parser.add_argument('--public', action='store_true', help="Use ngrok to expose the server publicly")
parser.add_argument('--port', type=int, default=PORT, help="Port to run the server on")
parser.add_argument('--host', type=str, default="127.0.0.1", help="Host to bind the server to")

if args is None:
args = parser.parse_args()
else:
args = parser.parse_args(args)

port = args.port
host = args.host
use_public = args.public or PUBLIC

run_server(port=port, use_public=use_public)
run_server(port=port, host=host, use_public=use_public)

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions src/praisonai/praisonai/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def _yaml_safe_load(stream):



# OpenAI client creation removed - create per-call instead of global cache

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Line 56 comment conflicts with the actual client lifecycle.

At Line 56, the comment says clients are created “per-call,” but this file still caches self._openai_client and self._async_openai_client per generator instance (lazy-init, then reuse). Please reword the comment to reflect instance-scoped caching (no module-level singleton), so the architecture intent is unambiguous.

Suggested wording
-# OpenAI client creation removed - create per-call instead of global cache
+# Removed module-level OpenAI client cache; clients are lazily created and owned per generator instance.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/praisonai/praisonai/auto.py` at line 56, The comment at line 56
incorrectly describes the OpenAI client lifecycle as "per-call" when the actual
implementation caches clients at the instance level using self._openai_client
and self._async_openai_client attributes. Update the comment to accurately
reflect instance-scoped caching behavior, specifying that clients are created
once on first use (lazy-initialization) and then reused for all subsequent calls
within that same generator instance, rather than being created fresh on every
call or cached globally across instances.



# --- CrewAI lazy loading ---
Expand Down
2 changes: 1 addition & 1 deletion src/praisonai/praisonai/bots/_http_approval.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
agent = Agent(
name="assistant",
tools=[execute_command],
approval=HTTPApproval(host="0.0.0.0", port=8899),
approval=HTTPApproval(host="127.0.0.1", port=8899),
)
"""

Expand Down
3 changes: 2 additions & 1 deletion src/praisonai/praisonai/scheduler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
- DeploymentScheduler: Schedule deployment operations
"""

from .base import ScheduleParser, ExecutorInterface, PraisonAgentExecutor
from .base import ExecutorInterface, PraisonAgentExecutor
from .shared import ScheduleParser

__all__ = [
'ScheduleParser',
Expand Down
1 change: 0 additions & 1 deletion src/praisonai/praisonai/scheduler/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

logger = logging.getLogger(__name__)


class ExecutorInterface(ABC):
"""Abstract interface for executors."""

Expand Down
Loading