From e5b42b97dd994bafdfc5697c7aaabb56455b5ea1 Mon Sep 17 00:00:00 2001 From: Jonas Lindberg Date: Sat, 2 Mar 2024 07:33:54 +0100 Subject: [PATCH] Rename maeve to crew (#65) * rename maeve to crew --- aitino/__init__.py | 16 ++++++++-------- aitino/{maeve.py => crew.py} | 4 ++-- aitino/interfaces/db.py | 10 +++++----- aitino/models/session.py | 2 +- aitino/parser.py | 2 +- aitino/test_stream.py | 4 ++-- 6 files changed, 19 insertions(+), 19 deletions(-) rename aitino/{maeve.py => crew.py} (99%) diff --git a/aitino/__init__.py b/aitino/__init__.py index f79ac4a6..84778b47 100644 --- a/aitino/__init__.py +++ b/aitino/__init__.py @@ -14,7 +14,7 @@ from .improver import PromptType, improve_prompt from .interfaces import db -from .maeve import Composition, Maeve +from .crew import Composition, Crew from .models import StreamReply, Session, Message logger = logging.getLogger("root") @@ -66,8 +66,8 @@ def improve( return improve_prompt(word_limit, prompt, prompt_type, temperature) -@app.get("/maeve") -async def run_maeve( +@app.get("/crew") +async def run_crew( id: UUID, profile_id: UUID, session_id: UUID | None = None, reply: str | None = None ) -> StreamingResponse: if reply and not session_id: @@ -87,7 +87,7 @@ async def run_maeve( message = reply if not message or not composition: - raise HTTPException(status_code=400, detail=f"Maeve with id {id} not found") + raise HTTPException(status_code=400, detail=f"Crew with id {id} not found") session = db.get_session(session_id) if session_id else None cached_messages = db.get_messages(session_id) if session_id else None @@ -106,7 +106,7 @@ async def run_maeve( if session is None: session = Session( - maeve_id=id, + crew_id=id, profile_id=profile_id, ) db.post_session(session) @@ -173,11 +173,11 @@ async def on_reply( db.post_message(message) await q.put(message) - maeve = Maeve(composition, on_reply) + crew = Crew(composition, on_reply) - # "maeve.run(message)" is run in a seperate thread + # "crew.run(message)" is run in a seperate thread asyncio.run_coroutine_threadsafe( - maeve.run(message, messages=cached_messages, q=q, job_done=job_done), + crew.run(message, messages=cached_messages, q=q, job_done=job_done), asyncio.get_event_loop(), ) diff --git a/aitino/maeve.py b/aitino/crew.py similarity index 99% rename from aitino/maeve.py rename to aitino/crew.py index f9e19555..0990b20f 100644 --- a/aitino/maeve.py +++ b/aitino/crew.py @@ -25,7 +25,7 @@ class Composition(BaseModel): agents: list[Agent] -class Maeve: +class Crew: def __init__( self, composition: Composition, @@ -149,7 +149,7 @@ async def run( ) manager.register_reply([autogen.Agent, None], self._on_reply) - logger.info("Starting Maeve") + logger.info("Starting Crew") with Cache.disk() as cache: await self.user_proxy.a_initiate_chat( manager, message=message, cache=cast(Cache, cache), silent=True diff --git a/aitino/interfaces/db.py b/aitino/interfaces/db.py index 54454b0f..10b2e382 100644 --- a/aitino/interfaces/db.py +++ b/aitino/interfaces/db.py @@ -7,7 +7,7 @@ from pydantic import ValidationError from supabase import Client, create_client -from ..maeve import Composition +from ..crew import Composition from ..models import Message, Session from ..parser import parse_input @@ -24,12 +24,12 @@ logger = logging.getLogger("root") -def get_complied(maeve_id: UUID) -> tuple[str, Composition] | tuple[None, None]: +def get_complied(crew_id: UUID) -> tuple[str, Composition] | tuple[None, None]: """ - Get the complied message and composition for a given Maeve ID. + Get the complied message and composition for a given Crew ID. """ - logger.debug(f"Getting complied message and composition for {maeve_id}") - response = supabase.table("maeves").select("*").eq("id", maeve_id).execute() + logger.debug(f"Getting complied message and composition for {crew_id}") + response = supabase.table("crews").select("*").eq("id", crew_id).execute() if len(response.data) == 0: return None, None diff --git a/aitino/models/session.py b/aitino/models/session.py index 89694ff1..6b81ad1e 100644 --- a/aitino/models/session.py +++ b/aitino/models/session.py @@ -6,6 +6,6 @@ class Session(BaseModel): id: UUID = Field(default_factory=lambda: uuid4()) - maeve_id: UUID + crew_id: UUID profile_id: UUID created_at: datetime = Field(default_factory=lambda: datetime.now(tz=UTC)) diff --git a/aitino/parser.py b/aitino/parser.py index 5c388d8d..76efcd5f 100644 --- a/aitino/parser.py +++ b/aitino/parser.py @@ -1,4 +1,4 @@ -from .maeve import Agent, Composition +from .crew import Agent, Composition def parse_composition(nodes: dict) -> Composition: diff --git a/aitino/test_stream.py b/aitino/test_stream.py index 69d3b33a..933324a4 100644 --- a/aitino/test_stream.py +++ b/aitino/test_stream.py @@ -6,7 +6,7 @@ import aiohttp -async def call_maeve(url: str) -> AsyncGenerator[str, None]: +async def call_crew(url: str) -> AsyncGenerator[str, None]: async with aiohttp.ClientSession() as session: async with session.get(url) as response: while True: @@ -24,7 +24,7 @@ async def main() -> None: url = sys.argv[1] i = 0 - async for event in call_maeve(url): + async for event in call_crew(url): i += 1 print(json.dumps(json.loads(event.strip()), indent=2))