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
7 changes: 4 additions & 3 deletions nodes/src/nodes/autopipe/IGlobal.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# =============================================================================

from rocketlib import IGlobalBase, debug, OPEN_MODE
from typing import Dict, Any
from typing import Dict, Any, Optional
from ai.common.config import Config


Expand All @@ -46,7 +46,9 @@ def pushRemote(filter: Dict[str, Any]):
debug(' Remote', filter['provider'])

# Create a filter for the given provider
def getFilter(id: str, provider: str, config: Dict = {}):
def getFilter(id: str, provider: str, config: Optional[Dict] = None):
if config is None:
config = {}
filter = {}
filter['id'] = id
filter['provider'] = provider
Expand Down Expand Up @@ -168,7 +170,6 @@ def isSet(key: str):
providerStore, configStore = Config.getMultiProviderConfig('store', autopipeConfig)
pushLocal(getFilter('vector_1', providerStore, configStore))


pass

# Now, add all the filters we figured out
Expand Down
8 changes: 4 additions & 4 deletions packages/ai/src/ai/account/keystore.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Tuple, Any, List
from typing import Dict, Optional, Tuple, Any, List
from rocketlib import ILoader


Expand All @@ -16,7 +16,7 @@ class KeyStore:
- Enforcing access control based on API keys
"""

def __init__(self, config: Dict[str, Any] = {}, **kwargs) -> None:
def __init__(self, config: Optional[Dict[str, Any]] = None, **kwargs) -> None:
"""
Initialize the keystore with configuration and optional parameters.

Expand All @@ -31,8 +31,8 @@ def __init__(self, config: Dict[str, Any] = {}, **kwargs) -> None:
# str:3 = endpoint
self.token_map: Dict[str, Tuple[str, str, str, str]] = {}

# Initialize the base class with the provided configuration
super().__init__(config, **kwargs)
# Store the configuration
self.config = config if config is not None else {}

async def assign_node(self, apikey: str, pipeline: str) -> Tuple[str, str]:
"""
Expand Down
4 changes: 3 additions & 1 deletion packages/ai/src/ai/common/dap/dap_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, module: str, **kwargs) -> None:
# Initialize base DAP functionality
super().__init__(module, **kwargs)

async def on_receive(self, message: Dict[str, Any] = {}) -> None:
async def on_receive(self, message: Optional[Dict[str, Any]] = None) -> None:
"""
Dispatch a received DAP message to the appropriate handler method.

Expand All @@ -58,6 +58,8 @@ async def on_receive(self, message: Dict[str, Any] = {}) -> None:
Args:
message (Dict[str, Any]): The parsed DAP message containing type, command, seq, and arguments
"""
if message is None:
message = {}
# Extract message type to determine handling approach
message_type = message.get('type', '')

Expand Down
4 changes: 3 additions & 1 deletion packages/ai/src/ai/modules/remote/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Optional

from ai.web import WebServer
from ai.common.schema import Autopipe

Expand All @@ -6,7 +8,7 @@
from .remote_pipe import remote_pipe


def initModule(server: WebServer, config: Autopipe = {}):
def initModule(server: WebServer, _config: Optional[Autopipe] = None):
"""
Initialize the module by registering API routes for search and configuration.

Expand Down
14 changes: 6 additions & 8 deletions packages/ai/src/ai/modules/remote/remote.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List
from typing import Any, Dict, List, Optional
Comment thread
stepmikhaylov marked this conversation as resolved.
Resolved


class Pipe:
Expand All @@ -8,17 +8,15 @@ class Pipe:
Define our class to keep track of a processing pipe.
"""

def __init__(self, apikey: str = '', loader: Any = None, input: List[str] = [], output: List[str] = [], usage: Dict[str, int] = {}):
def __init__(self, apikey: str = '', loader: Any = None, input_keys: Optional[List[str]] = None, output: Optional[List[str]] = None, usage: Optional[Dict[str, int]] = None):
"""
Сreate an instance of the pipe context.
Create an instance of the pipe context.
"""
if usage is None: # to avoid mutable default argument issues
usage = {}
self.apikey = apikey
self.loader = loader
self.input = input
self.output = output
self.usage = usage
self.input = input_keys if input_keys is not None else []
self.output = output if output is not None else []
self.usage = usage if usage is not None else {}


# Define our global mapping of opened endpoints and API keys
Expand Down
8 changes: 4 additions & 4 deletions packages/ai/src/ai/web/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class WebServer:
Manage and run a FastAPI web server with exception handling, SSL support, and event loop management.
"""

def __init__(self, config: Dict[str, Any] = {}, **kwargs):
def __init__(self, config: Optional[Dict[str, Any]] = None, **kwargs):
"""
Initialize the WebServer instance with the FastAPI app and configuration.

Expand Down Expand Up @@ -156,7 +156,7 @@ def __init__(self, config: Dict[str, Any] = {}, **kwargs):
)

# Store the server configuration
self.config = config
self.config = config if config is not None else {}

# Register a global exception handler for catching unexpected errors
self.app.exception_handler(Exception)(self._general_exception_handler)
Expand Down Expand Up @@ -709,7 +709,7 @@ def add_socket(
self._private_paths.append(path)
self._compiled_private_paths = None

def use(self, moduleName: str, config: Dict[str, Any] = {}):
def use(self, moduleName: str, config: Optional[Dict[str, Any]] = None):
"""
Dynamically loads a service module and enables its API endpoints.

Expand Down Expand Up @@ -745,7 +745,7 @@ def use(self, moduleName: str, config: Dict[str, Any] = {}):
moduleHandle = importlib.import_module(f'ai.modules.{moduleName}')

# Init the module and register the module's endpoints with the server
moduleHandle.initModule(self, config)
moduleHandle.initModule(self, config if config is not None else {})

# Add it to the module handle
self.app.state.modules[moduleName] = moduleHandle
Expand Down
Loading