Skip to content

Commit

Permalink
Rename maeve to crew (#65)
Browse files Browse the repository at this point in the history
* rename maeve to crew
  • Loading branch information
eksno authored Mar 2, 2024
1 parent ea65c6f commit e5b42b9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions aitino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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(),
)

Expand Down
4 changes: 2 additions & 2 deletions aitino/maeve.py → aitino/crew.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Composition(BaseModel):
agents: list[Agent]


class Maeve:
class Crew:
def __init__(
self,
composition: Composition,
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions aitino/interfaces/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion aitino/models/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
2 changes: 1 addition & 1 deletion aitino/parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .maeve import Agent, Composition
from .crew import Agent, Composition


def parse_composition(nodes: dict) -> Composition:
Expand Down
4 changes: 2 additions & 2 deletions aitino/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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))

Expand Down

0 comments on commit e5b42b9

Please sign in to comment.