Skip to content

Commit 57aa905

Browse files
payneioPaul Payne
andauthored
papayne/skills 6 (#266)
Skill Assistant: - Add startup routine/action w/ start method.- - Add clear method. - Add drive_root and metadrive_root to assistant registry. - Fixes state_meachine_routine_runner methods (await). - Enables tests in form_filler_skill. FormFillerSkill/GuidedConversationSkill: - Make Agenda a Pydantic model (separate mutations/functions into a functional approach). - Remove BaseModelLLM in deference to built-in validation. - Adds drives. - Separates init/step initialization. - Creates definitions module (adds acrostic_poem). - Properly manages artifacts, agenda and other state in run stack frames. - Adds separate logging module to avoid cyclical dependencies. --------- Co-authored-by: Paul Payne <[email protected]>
1 parent c2d72ee commit 57aa905

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2302
-930
lines changed

assistants/skill-assistant/assistant/assistant_registry.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import logging
3+
from os import PathLike
34
from pathlib import Path
45
from typing import Optional
56

@@ -53,6 +54,8 @@ async def register_assistant(
5354
event_mapper: SkillEventMapperProtocol,
5455
chat_driver_config: ChatDriverConfig,
5556
skills: dict[str, Skill] | None = None,
57+
drive_root: PathLike | None = None,
58+
metadata_drive_root: PathLike | None = None,
5659
) -> Assistant:
5760
"""
5861
Define the skill assistant that you want to have backing this assistant
@@ -67,8 +70,8 @@ async def register_assistant(
6770
assistant = Assistant(
6871
name="Assistant",
6972
assistant_id=assistant_id,
70-
drive_root=Path(".data") / assistant_id / "assistant",
71-
metadata_drive_root=Path(".data") / assistant_id / ".assistant",
73+
drive_root=drive_root or Path(".data") / assistant_id / "assistant",
74+
metadata_drive_root=metadata_drive_root or Path(".data") / assistant_id / ".assistant",
7275
chat_driver_config=chat_driver_config,
7376
skills=skills,
7477
)

assistants/skill-assistant/assistant/skill_assistant.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from typing import Any, Optional
1313

1414
import openai_client
15+
from assistant_drive import Drive, DriveConfig
1516
from content_safety.evaluators import CombinedContentSafetyEvaluator
1617
from form_filler_skill import FormFillerSkill
1718
from form_filler_skill.guided_conversation import GuidedConversationSkill
@@ -174,7 +175,11 @@ async def respond_to_conversation(
174175
await conversation_context.update_participant_me(UpdateParticipant(status="thinking..."))
175176

176177
# Get an assistant from the skill library.
177-
assistant = assistant_registry.get_assistant(conversation_context.id)
178+
assistant_id = conversation_context.id
179+
assistant = assistant_registry.get_assistant(assistant_id)
180+
drive_root = Path(".data") / assistant_id / "assistant"
181+
metadata_drive_root = Path(".data") / assistant_id / ".assistant"
182+
drive = Drive(DriveConfig(root=drive_root))
178183

179184
# Create and register an assistant if necessary.
180185
if not assistant:
@@ -191,19 +196,25 @@ async def respond_to_conversation(
191196
chat_driver_config,
192197
{
193198
"posix": PosixSkill(
199+
name="posix",
194200
sandbox_dir=Path(".data") / conversation_context.id,
195201
chat_driver_config=chat_driver_config,
196202
mount_dir="/mnt/data",
197203
),
198204
"form_filler": FormFillerSkill(
205+
name="form_filler",
199206
chat_driver_config=chat_driver_config,
200207
language_model=language_model,
201208
),
202209
"guided_conversation": GuidedConversationSkill(
203-
chat_driver_config=chat_driver_config,
210+
name="guided_conversation",
204211
language_model=language_model,
212+
drive=drive.subdrive("guided_conversation"),
213+
chat_driver_config=chat_driver_config,
205214
),
206215
},
216+
drive_root=drive_root,
217+
metadata_drive_root=metadata_drive_root,
207218
)
208219

209220
except Exception as e:

assistants/skill-assistant/uv.lock

Lines changed: 132 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libraries/python/assistant-drive/assistant_drive/drive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class IfDriveFileExistsBehavior(StrEnum):
2626

2727
class DriveConfig(BaseModel):
2828
root: str | PathLike
29-
default_if_exists_behavior: IfDriveFileExistsBehavior = IfDriveFileExistsBehavior.AUTO_RENAME
29+
default_if_exists_behavior: IfDriveFileExistsBehavior = IfDriveFileExistsBehavior.OVERWRITE
3030

3131

3232
class FileMetadata:

libraries/python/assistant-drive/assistant_drive/tests/test_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def test_open_non_existent_file(drive):
9191

9292
def test_auto_rename(drive, if_exists=IfDriveFileExistsBehavior.AUTO_RENAME):
9393
drive.write(file_content, "test.txt", "summaries")
94-
metadata = drive.write(file_content, "test.txt", "summaries")
94+
metadata = drive.write(file_content, "test.txt", "summaries", if_exists=IfDriveFileExistsBehavior.AUTO_RENAME)
9595
assert metadata.filename == "test(1).txt"
9696
assert sorted(list(drive.list(dir="summaries"))) == sorted(["test.txt", "test(1).txt"])
9797

libraries/python/context/pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@ events = { path = "../events", editable = true }
2323
[build-system]
2424
requires = ["hatchling"]
2525
build-backend = "hatchling.build"
26+
27+
[tool.pytest.ini_options]
28+
addopts = "-vv"
29+
log_cli = true
30+
log_cli_level = "WARNING"
31+
log_cli_format = "%(asctime)s | %(levelname)-7s | %(name)s | %(message)s"
32+
testpaths = ["tests"]
33+
asyncio_mode = "auto"
34+
asyncio_default_fixture_loop_scope = "function"

0 commit comments

Comments
 (0)