complete ai kerne frame code
This commit is contained in:
@@ -0,0 +1 @@
|
||||
TODO
|
||||
@@ -0,0 +1,58 @@
|
||||
from typing import Optional
|
||||
import logging
|
||||
import llm_kernel,llm_work_task
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
class agent_msg:
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
class agent_prompt:
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
def as_str()->str:
|
||||
pass
|
||||
|
||||
class agent_chat_session:
|
||||
def __init__(self) -> None:
|
||||
self.llm_model_name = None
|
||||
self.llm_instance = None
|
||||
self.max_token_size = 0
|
||||
self.chat_msg_list = None
|
||||
self.enable_function = True
|
||||
|
||||
pass
|
||||
|
||||
def chat(self,message:str) -> None:
|
||||
pass
|
||||
# Key functions, let the AI Agent try to run.
|
||||
def completion(self)->llm_work_task:
|
||||
if self.llm_instance is None:
|
||||
self.llm_instance = llm_kernel.craete(self.llm_model_name)
|
||||
if self.llm_instance is None:
|
||||
logger.fatal(f"cann't get llm_kerenel : {self.llm_model_name}")
|
||||
return
|
||||
|
||||
llm_work_task = self.llm_instance.completion(self._get_prompt(),self.max_token_size)
|
||||
return llm_work_task
|
||||
|
||||
def _get_prompt(str) -> str:
|
||||
pass
|
||||
|
||||
class ai_agent:
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
def get_chat_session(self,chat_user_name:str,session_id:Optional[str]) -> agent_chat_session:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
#chat_session = agent.get_default_chat_session("master");
|
||||
#chat_session.chat("给我讲一个英文笑话!");
|
||||
#chat_session.completion();
|
||||
#print(chat_session.last_msg());
|
||||
@@ -0,0 +1,20 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any
|
||||
from .agent import agent,agent_msg
|
||||
|
||||
class ai_role:
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
class agent_group:
|
||||
def __init__(self) -> None:
|
||||
self.roles = None
|
||||
pass
|
||||
|
||||
def add_role(self,role_name:str,agent_id:str) -> None:
|
||||
pass
|
||||
|
||||
def send_msg(self,role_name:str,msg:agent_msg) -> None:
|
||||
pass
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
from .workflow import ai_workflow
|
||||
from agent import agent_msg
|
||||
class aios_shell:
|
||||
def send_msg(self,msg:agent_msg,target:ai_workflow) -> None:
|
||||
pass
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
from compute_node import compute_node
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
# How to dispatch different computing tasks (some tasks may contain a large amount of state for correct execution)
|
||||
# to suitable computing nodes, achieving a balance of speed, cost, and power consumption,
|
||||
# is the CORE GOAL of the entire computing task schedule system (aios_kernel).
|
||||
class compute_task(ABC):
|
||||
@abstractmethod
|
||||
def display(self) -> str:
|
||||
pass
|
||||
|
||||
|
||||
class compute_kernel:
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
def run(self,task:compute_task) -> None:
|
||||
# check there is compute node can support this task
|
||||
# add task to working_queue
|
||||
pass
|
||||
|
||||
def start(self):
|
||||
pass
|
||||
|
||||
def add_compute_node(self,node:compute_node):
|
||||
pass
|
||||
|
||||
def disable_compute_node(self,):
|
||||
pass
|
||||
@@ -0,0 +1,13 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class compute_node(ABC):
|
||||
@abstractmethod
|
||||
def display(self) -> str:
|
||||
pass
|
||||
|
||||
class local_compute_node(compute_node):
|
||||
def display(self) -> str:
|
||||
return super().display()
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
class environment_event(ABC):
|
||||
@abstractmethod
|
||||
def display(self) -> str:
|
||||
pass
|
||||
|
||||
|
||||
class environment:
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
def event_to_msg(self,) -> environment_event:
|
||||
pass
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
class llm_work_task:
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
|
||||
class llm_kernel:
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
def completion(self,prompt:str,max_token:int) -> llm_work_task:
|
||||
# craete a llm_work_task ,push on queue's end
|
||||
# then task_schedule would run this task.(might schedule some work_task to another host)
|
||||
pass
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
from compute_node import compute_node
|
||||
|
||||
class open_ai_compute_node(compute_node):
|
||||
def display(self) -> str:
|
||||
return super().display()
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import environment
|
||||
import agent_prompt,agent_msg
|
||||
|
||||
class ai_workflow:
|
||||
def __init__(self) -> None:
|
||||
self.rule_prompt : agent_prompt = None
|
||||
self.workflow_config = None
|
||||
self.context = None
|
||||
|
||||
def load_from_disk(self,config_path:str,context_dir_path) -> int:
|
||||
pass
|
||||
|
||||
def send_msg(self,msg:agent_msg,target_group:str = None) -> None:
|
||||
if target_group is None:
|
||||
target_group = self.get_default_group()
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
|
||||
pass
|
||||
|
||||
def _pop_msg(self) -> Tuple[agent_msg,str]:
|
||||
pass
|
||||
|
||||
def get_default_group(self) -> agent_group:
|
||||
pass
|
||||
|
||||
def get_group(self,group_name:str) -> agent_group:
|
||||
pass
|
||||
|
||||
def get_workflow_rule_prompt(self) -> agent_prompt:
|
||||
return self.rule_prompt
|
||||
|
||||
def get_inner_environment(self) -> environment:
|
||||
pass
|
||||
|
||||
def connect_to_environment(self,env:environment) -> None:
|
||||
pass
|
||||
Reference in New Issue
Block a user