Skip to content

Commit

Permalink
Merge pull request #302 from ohdearquant/merge_direct
Browse files Browse the repository at this point in the history
Merge direct
  • Loading branch information
ohdearquant authored Mar 22, 2024
2 parents f062b64 + 3cd80b9 commit 1cb7a60
Show file tree
Hide file tree
Showing 77 changed files with 4,599 additions and 3,305 deletions.
7 changes: 2 additions & 5 deletions lionagi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
from .version import __version__
from dotenv import load_dotenv


from .libs import *
from .core import *
from .integrations import *

from .core import direct, Branch, Session, Structure, Tool, BaseAgent
from .integrations.provider.services import Services

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Expand Down
12 changes: 7 additions & 5 deletions lionagi/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from .tool import func_to_tool
from .session import Branch, Session

from .flow import direct
from . import *

__all__ = ["Session", "Branch", "func_to_tool", "direct"]
from .branch import Branch, ExecutableBranch
from .session import Session
from .schema import Tool, Structure, ActionNode, Relationship
from .agent import BaseAgent
from .messages import Instruction, System, Response
from .tool import func_to_tool
3 changes: 3 additions & 0 deletions lionagi/core/agent/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .base_agent import BaseAgent

__all__ = ["BaseAgent"]
22 changes: 10 additions & 12 deletions lionagi/core/agent/base_agent.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
from collections import deque

from lionagi.core.mail.schema import StartMail
from lionagi.core.schema.base_node import BaseRelatableNode
from lionagi.core.mail.mail_manager import MailManager

import lionagi.libs.ln_func_call as func_call
from lionagi.libs.ln_async import AsyncUtil
from lionagi.libs import func_call, AsyncUtil


class BaseAgent(BaseRelatableNode):
def __init__(
self,
structure,
executable_class,
output_parser=None,
executable_class_kwargs={},
) -> None:
def __init__(self, structure, executable_obj, output_parser=None) -> None:

super().__init__()
self.structure = structure
self.executable = executable_class(**executable_class_kwargs)
self.executable = executable_obj
self.start = StartMail()
self.mailManager = MailManager([self.structure, self.executable, self.start])
self.output_parser = output_parser
self.start_context = None

async def mail_manager_control(self, refresh_time=1):
while not self.structure.execute_stop or not self.executable.execute_stop:
await AsyncUtil.sleep(refresh_time)
self.mailManager.execute_stop = True

async def execute(self, context=None):
self.start_context = context
self.start.trigger(
context=context,
structure_id=self.structure.id_,
Expand All @@ -44,5 +38,9 @@ async def execute(self, context=None):
],
)

self.structure.execute_stop = False
self.executable.execute_stop = False
self.mailManager.execute_stop = False

if self.output_parser:
return self.output_parser(self)
4 changes: 4 additions & 0 deletions lionagi/core/branch/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .branch import Branch
from .executable_branch import ExecutableBranch

__all__ = ["Branch", "ExecutableBranch"]
Loading

0 comments on commit 1cb7a60

Please sign in to comment.