Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ZetaNova3 committed Feb 1, 2024
0 parents commit d256e19
Show file tree
Hide file tree
Showing 43 changed files with 281 additions and 0 deletions.
Empty file added .github/workflows/ci.yml
Empty file.
Binary file added __pycache__/test_watcher.cpython-310.pyc
Binary file not shown.
Empty file added app/__init__.py
Empty file.
Binary file added app/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Empty file added app/api/__init__.py
Empty file.
Binary file added app/api/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions app/api/endpoints/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Initialize the endpoints module
Binary file not shown.
Empty file added app/docs/__init__.py
Empty file.
Binary file added app/docs/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Empty file added app/models/__init__.py
Empty file.
Binary file added app/models/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Empty file added app/simulated_file_change.py
Empty file.
Empty file added app/tests/__init__.py
Empty file.
Binary file added app/tests/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added app/tests/__pycache__/test_api.cpython-310.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions app/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from fastapi.testclient import TestClient
from app.main import app

client = TestClient(app)

def test_tool_endpoint_success():
# Assuming the tool endpoint expects a GET request
response = client.get("/tool")
assert response.status_code == 200
# Add more assertions based on the expected JSON structure

def test_tool_endpoint_failure():
# Assuming there's a way to simulate a failure, like an invalid parameter
response = client.get("/tool?invalid_param=1")
assert response.status_code == 400
# Add more assertions based on the expected error response
Empty file added app/utils/__init__.py
Empty file.
Binary file added app/utils/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Empty file added chatbot/__init__.py
Empty file.
Binary file added chatbot/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Empty file added chatbot/chatbot_handler.py
Empty file.
Empty file added factories/__init__.py
Empty file.
Binary file added factories/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file not shown.
45 changes: 45 additions & 0 deletions factories/agent_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

class AgentFactory:
"""
Agent Factory for instantiating various types of agents with specific capabilities and behaviors.
This factory is responsible for creating and managing different agents that can interact within the system,
leveraging the capabilities of Googles Generative AI Models Gemini pro and gemini vision pro for multimodal capabilities.
"""

def __init__(self):
"""
Initializes the Agent Factory with necessary configurations or states.
"""
self.agents = {}

def register_agent(self, agent_name, agent_class):
"""
Registers a new agent class under a given agent name.
:param agent_name: The name of the agent to register.
:param agent_class: The class of the agent to register.
"""
if agent_name in self.agents:
raise ValueError(f"Agent {agent_name} is already registered.")
self.agents[agent_name] = agent_class

def create_agent(self, agent_name, *args, **kwargs):
"""
Creates an instance of an agent based on its name, with optional arguments.
:param agent_name: The name of the agent to instantiate.
:return: An instance of the requested agent.
"""
if agent_name not in self.agents:
raise ValueError(f"Agent {agent_name} is not registered.")
agent_class = self.agents[agent_name]
agent_instance = agent_class(*args, **kwargs)
return agent_instance

def list_agents(self):
"""
Lists all registered agents.
:return: A list of registered agent names.
"""
return list(self.agents.keys())
Empty file added factories/api_factory.py
Empty file.
45 changes: 45 additions & 0 deletions factories/automated_test_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

class AutomatedTestFactory:
"""
Automated Test Factory for generating tools and structures for automated testing of various components within the system.
This factory is responsible for creating and managing different testing tools that can be utilized across the application
to ensure the reliability and robustness of the system.
"""

def __init__(self):
"""
Initializes the Automated Test Factory with necessary configurations or states.
"""
self.test_tools = {}

def register_test_tool(self, tool_name, tool_class):
"""
Registers a new test tool class under a given tool name.
:param tool_name: The name of the test tool to register.
:param tool_class: The class of the test tool to register.
"""
if tool_name in self.test_tools:
raise ValueError(f"Test tool {tool_name} is already registered.")
self.test_tools[tool_name] = tool_class

def create_test_tool(self, tool_name, *args, **kwargs):
"""
Creates an instance of a test tool based on its name, with optional arguments.
:param tool_name: The name of the test tool to instantiate.
:return: An instance of the requested test tool.
"""
if tool_name not in self.test_tools:
raise ValueError(f"Test tool {tool_name} is not registered.")
tool_class = self.test_tools[tool_name]
tool_instance = tool_class(*args, **kwargs)
return tool_instance

def list_registered_tools(self):
"""
Lists all registered test tools.
:return: A list of registered test tool names.
"""
return list(self.test_tools.keys())
Empty file.
Empty file added factories/embedding_factory.py
Empty file.
Empty file.
43 changes: 43 additions & 0 deletions factories/function_as_tool_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

class FunctionAsToolFactory:
"""
Function as Tool Factory for dynamically generating tools based on functions.
This factory allows for dynamic function registration and instantiation as tools within the system.
"""

def __init__(self):
"""
Initializes the Function as Tool Factory with necessary configurations or states.
"""
self.function_tools = {}

def register_function_tool(self, function_name, function):
"""
Registers a new function as a tool under a given function name.
:param function_name: The name of the function to register as a tool.
:param function: The function to register as a tool.
"""
if function_name in self.function_tools:
raise ValueError(f"Function tool {function_name} is already registered.")
self.function_tools[function_name] = function

def create_function_tool(self, function_name, *args, **kwargs):
"""
Creates an instance of a function tool based on its name, with optional arguments.
:param function_name: The name of the function tool to instantiate.
:return: The result of the function tool execution.
"""
if function_name not in self.function_tools:
raise ValueError(f"Function tool {function_name} is not registered.")
function = self.function_tools[function_name]
result = function(*args, **kwargs)
return result

# Example usage
# Assuming there's a function `greet` defined somewhere that takes a name argument
# function_as_tool_factory = FunctionAsToolFactory()
# function_as_tool_factory.register_function_tool("greet", greet)
# greeting = function_as_tool_factory.create_function_tool("greet", name="John")
# print(greeting)
Empty file added factories/memory_factory.py
Empty file.
51 changes: 51 additions & 0 deletions factories/plugin_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

class PluginFactory:
"""
Plugin Factory for handling the creation and management of plugins for extensibility.
This factory is responsible for instantiating and managing different plugins
that can be utilized across the application for extending its capabilities.
"""

def __init__(self):
"""
Initializes the Plugin Factory with necessary configurations or states.
"""
self.plugins = {}

def register_plugin(self, plugin_name, plugin_class):
"""
Registers a new plugin class under a given plugin name.
:param plugin_name: The name of the plugin to register.
:param plugin_class: The class of the plugin to register.
"""
if plugin_name in self.plugins:
raise ValueError(f"Plugin {plugin_name} is already registered.")
self.plugins[plugin_name] = plugin_class

def create_plugin(self, plugin_name, *args, **kwargs):
"""
Creates an instance of a plugin based on its name, with optional arguments.
:param plugin_name: The name of the plugin to instantiate.
:return: An instance of the requested plugin.
"""
if plugin_name not in self.plugins:
raise ValueError(f"Plugin {plugin_name} is not registered.")
plugin_class = self.plugins[plugin_name]
plugin_instance = plugin_class(*args, **kwargs)
return plugin_instance

def get_all_plugins(self):
"""
Returns a list of all registered plugins.
:return: A list of registered plugin names.
"""
return list(self.plugins.keys())

# Example usage
# Assuming there's a class `LoggerPlugin` defined somewhere that takes no arguments for initialization
# plugin_factory = PluginFactory()
# plugin_factory.register_plugin("logger", LoggerPlugin)
# logger_plugin = plugin_factory.create_plugin("logger")
Empty file added factories/prompt_factory.py
Empty file.
46 changes: 46 additions & 0 deletions factories/proxy_agent_control_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

"""Proxy Agent Control Factory Module.
This module is responsible for creating and managing components for controlling proxy agents,
enabling communication and coordination among different parts of the system.
"""

class ProxyAgentControlFactory:
def __init__(self):
"""Initialize the Proxy Agent Control Factory."""
self.proxy_agents = {}

def register_proxy_agent(self, agent_name, agent_class):
"""Register a new proxy agent class under a given agent name.
Args:
agent_name (str): The name of the proxy agent to register.
agent_class (class): The class of the proxy agent to register.
"""
if agent_name in self.proxy_agents:
raise ValueError(f"Proxy Agent {agent_name} is already registered.")
self.proxy_agents[agent_name] = agent_class

def create_proxy_agent(self, agent_name, *args, **kwargs):
"""Create an instance of a proxy agent based on its name, with optional arguments.
Args:
agent_name (str): The name of the proxy agent to instantiate.
Returns:
An instance of the requested proxy agent, if found. Raises an error otherwise.
"""
if agent_name not in self.proxy_agents:
raise ValueError(f"Proxy Agent {agent_name} is not registered.")
return self.proxy_agents[agent_name](*args, **kwargs)

def get_proxy_agent(self, agent_name):
"""Retrieve a proxy agent by its name.
Args:
agent_name (str): The name of the proxy agent to retrieve.
Returns:
The class of the requested proxy agent, if found. None otherwise.
"""
return self.proxy_agents.get(agent_name, None)
Empty file added factories/tool_factory.py
Empty file.
Empty file added llm_orchestrator/__init__.py
Empty file.
Binary file not shown.
Empty file.
Empty file added main.py
Empty file.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
watchdog
33 changes: 33 additions & 0 deletions test_watcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Update the test_watcher.py script with the integration for the testing factory
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import time

class TestingFactory:
@staticmethod
def handle_file_change(file_path):
# Simulated implementation for demonstration
print(f"Simulated testing factory handling file change for: {file_path}")

class ChangeHandler(FileSystemEventHandler):
def on_modified(self, event):
if event.is_directory:
return
print(f'File changed: {event.src_path}')
# Call the simulated testing factory's handle_file_change method
TestingFactory.handle_file_change(event.src_path)

def start_watching(path='app/'):
event_handler = ChangeHandler()
observer = Observer()
observer.schedule(event_handler, path, recursive=True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()

if __name__ == "__main__":
start_watching()

0 comments on commit d256e19

Please sign in to comment.