Skip to content

Refactor context transfer to knowledge transfer terminology (the code this time) #585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions assistants/project-assistant/assistant/chat.py
Original file line number Diff line number Diff line change
@@ -31,12 +31,17 @@
from assistant.command_processor import command_registry
from assistant.respond import respond_to_conversation
from assistant.team_welcome import generate_team_welcome_message
from assistant.utils import CONTEXT_TRANSFER_TEMPLATE_ID, DEFAULT_TEMPLATE_ID, load_text_include
from assistant.utils import (
DEFAULT_TEMPLATE_ID,
KNOWLEDGE_TRANSFER_TEMPLATE_ID,
is_knowledge_transfer_assistant,
load_text_include,
)

from .config import assistant_config
from .conversation_project_link import ConversationProjectManager
from .logging import logger
from .project_common import ConfigurationTemplate, detect_assistant_role, get_template
from .project_common import detect_assistant_role
from .project_data import LogEntryType
from .project_files import ProjectFileManager
from .project_manager import ProjectManager
@@ -71,7 +76,7 @@ async def content_evaluator_factory(
},
additional_templates=[
AssistantTemplate(
id=CONTEXT_TRANSFER_TEMPLATE_ID,
id=KNOWLEDGE_TRANSFER_TEMPLATE_ID,
name="Knowledge Transfer Assistant",
description="An assistant for capturing and sharing complex information for others to explore.",
),
@@ -92,20 +97,20 @@ async def content_evaluator_factory(
),
dashboard_card.TemplateConfig(
enabled=True,
template_id=CONTEXT_TRANSFER_TEMPLATE_ID,
template_id=KNOWLEDGE_TRANSFER_TEMPLATE_ID,
icon=dashboard_card.image_to_url(
pathlib.Path(__file__).parent / "assets" / "icon_context_transfer.svg", "image/svg+xml"
),
background_color="rgb(198,177,222)",
card_content=dashboard_card.CardContent(
content_type="text/markdown",
content=load_text_include("context_transfer_card_content.md"),
content=load_text_include("knowledge_transfer_card_content.md"),
),
),
),
**navigator.metadata_for_assistant_navigator({
"default": load_text_include("project_assistant_info.md"),
"knowledge_transfer": load_text_include("context_transfer_assistant_info.md"),
"knowledge_transfer": load_text_include("knowledge_transfer_assistant_info.md"),
}),
},
)
@@ -134,8 +139,6 @@ async def on_conversation_created(context: ConversationContext) -> None:
conversation_metadata = conversation.metadata or {}

config = await assistant_config.get(context.assistant)
template = get_template(context)
is_context_transfer_assistant = template == ConfigurationTemplate.CONTEXT_TRANSFER_ASSISTANT

##
## Figure out what type of conversation this is.
@@ -226,7 +229,7 @@ async def on_conversation_created(context: ConversationContext) -> None:
context=context,
title=f"New {config.Project_or_Context}",
description="_This knowledge brief is displayed in the side panel of all of your team members' conversations, too. Before you share links to your team, ask your assistant to update the brief with whatever details you'd like here. What will help your teammates get off to a good start as they explore the knowledge you are sharing?_"
if is_context_transfer_assistant
if is_knowledge_transfer_assistant(context)
else "_This project brief is displayed in the side panel of all of your team members' conversations, too. Before you share links to your team, ask your assistant to update the brief with whatever details you'd like here. What will help your teammates get off to a good start as they begin working on your project?_",
)

6 changes: 3 additions & 3 deletions assistants/project-assistant/assistant/config.py
Original file line number Diff line number Diff line change
@@ -4,22 +4,22 @@

from .configs import (
AssistantConfigModel,
ContextTransferConfigModel,
CoordinatorConfig,
KnowledgeTransferConfigModel,
RequestConfig,
TeamConfig,
)

assistant_config = BaseModelAssistantConfig(
AssistantConfigModel,
additional_templates={
"knowledge_transfer": ContextTransferConfigModel,
"knowledge_transfer": KnowledgeTransferConfigModel,
},
)

__all__ = [
"AssistantConfigModel",
"ContextTransferConfigModel",
"KnowledgeTransferConfigModel",
"CoordinatorConfig",
"RequestConfig",
"TeamConfig",
4 changes: 2 additions & 2 deletions assistants/project-assistant/assistant/configs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from .context_transfer import ContextTransferConfigModel
from .default import AssistantConfigModel, CoordinatorConfig, RequestConfig, TeamConfig
from .knowledge_transfer import KnowledgeTransferConfigModel

__all__ = [
"AssistantConfigModel",
"ContextTransferConfigModel",
"KnowledgeTransferConfigModel",
"CoordinatorConfig",
"RequestConfig",
"TeamConfig",
7 changes: 4 additions & 3 deletions assistants/project-assistant/assistant/configs/default.py
Original file line number Diff line number Diff line change
@@ -58,9 +58,10 @@ class PromptConfig(BaseModel):
title="Prompt Templates",
json_schema_extra={
"required": [
"instruction_prompt",
"coordinator_prompt",
"team_prompt",
"coordinator_role",
"coordinator_instructions",
"team_role",
"team_instructions",
"whiteboard_prompt",
"project_information_request_detection",
],
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
from .default import AssistantConfigModel, CoordinatorConfig, PromptConfig, TeamConfig


class ContextTransferPromptConfig(PromptConfig):
class KnowledgeTransferPromptConfig(PromptConfig):
"""Prompt configuration specific to knowledge transfer template."""

whiteboard_prompt: Annotated[
@@ -16,15 +16,15 @@ class ContextTransferPromptConfig(PromptConfig):
title="Knowledge Transfer Whiteboard Prompt",
description="The prompt used to generate whiteboard content in knowledge transfer mode.",
),
] = load_text_include("context_transfer_whiteboard_prompt.txt")
] = load_text_include("knowledge_transfer_whiteboard_prompt.txt")

project_information_request_detection: Annotated[
str,
Field(
title="Knowledge Transfer Information Request Detection Prompt",
description="The prompt used to detect information requests in knowledge transfer mode.",
),
] = load_text_include("context_transfer_information_request_detection.txt")
] = load_text_include("knowledge_transfer_information_request_detection.txt")

welcome_message_generation: Annotated[
str,
@@ -33,10 +33,10 @@ class ContextTransferPromptConfig(PromptConfig):
description="The prompt used to generate a welcome message for new team conversations.",
),
UISchema(widget="textarea"),
] = load_text_include("context_transfer_welcome_message_generation.txt")
] = load_text_include("knowledge_transfer_welcome_message_generation.txt")


class ContextTransferCoordinatorConfig(CoordinatorConfig):
class KnowledgeTransferCoordinatorConfig(CoordinatorConfig):
"""Coordinator configuration specific to knowledge transfer template."""

welcome_message: Annotated[
@@ -61,7 +61,7 @@ class ContextTransferCoordinatorConfig(CoordinatorConfig):
What knowledge would you like to transfer today?"""


class ContextTransferTeamConfig(TeamConfig):
class KnowledgeTransferTeamConfig(TeamConfig):
"""Team configuration specific to knowlege transfer template."""

default_welcome_message: Annotated[
@@ -73,7 +73,7 @@ class ContextTransferTeamConfig(TeamConfig):
] = "# Welcome to your Knowledge Transfer space!\n\nYou now have access to the shared knowledge that has been prepared for you. This is your personal conversation for exploring your knowledge space."


class ContextTransferConfigModel(AssistantConfigModel):
class KnowledgeTransferConfigModel(AssistantConfigModel):
project_or_context: Annotated[str, UISchema(widget="hidden")] = "knowledge"
Project_or_Context: Annotated[str, UISchema(widget="hidden")] = "Knowledge"

@@ -83,7 +83,7 @@ class ContextTransferConfigModel(AssistantConfigModel):
title="Prompt Configuration",
description="Configuration for prompt templates used throughout the assistant.",
),
] = ContextTransferPromptConfig()
] = KnowledgeTransferPromptConfig()

proactive_guidance: Annotated[
bool,
@@ -107,12 +107,12 @@ class ContextTransferConfigModel(AssistantConfigModel):
title="Knowledge Transfer Coordinator Configuration",
description="Configuration for coordinators in knowledge transfer mode.",
),
] = ContextTransferCoordinatorConfig()
] = KnowledgeTransferCoordinatorConfig()

team_config: Annotated[
TeamConfig,
Field(
title="Knowledge Transfer Team Configuration",
description="Configuration for team members in knowledge transfer mode.",
),
] = ContextTransferTeamConfig()
] = KnowledgeTransferTeamConfig()
6 changes: 3 additions & 3 deletions assistants/project-assistant/assistant/project_common.py
Original file line number Diff line number Diff line change
@@ -12,10 +12,10 @@

from .conversation_project_link import ConversationProjectManager
from .logging import logger
from .utils import DEFAULT_TEMPLATE_ID
from .project_data import LogEntryType
from .project_storage import ProjectStorage
from .project_storage_models import ConversationRole
from .utils import DEFAULT_TEMPLATE_ID


class ConfigurationTemplate(Enum):
@@ -25,15 +25,15 @@ class ConfigurationTemplate(Enum):
"""

PROJECT_ASSISTANT = "project_assistant"
CONTEXT_TRANSFER_ASSISTANT = "knowledge_transfer_assistant"
KNOWLEDGE_TRANSFER_ASSISTANT = "knowledge_transfer_assistant"


def get_template(context: ConversationContext) -> ConfigurationTemplate:
template_id = context.assistant._template_id or DEFAULT_TEMPLATE_ID
return (
ConfigurationTemplate.PROJECT_ASSISTANT
if template_id == DEFAULT_TEMPLATE_ID
else ConfigurationTemplate.CONTEXT_TRANSFER_ASSISTANT
else ConfigurationTemplate.KNOWLEDGE_TRANSFER_ASSISTANT
)


2 changes: 1 addition & 1 deletion assistants/project-assistant/assistant/respond.py
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
from .string_utils import Context, ContextStrategy, Instructions, Prompt, TokenBudget, render

SILENCE_TOKEN = "{{SILENCE}}"
CONTEXT_TRANSFER_ASSISTANT = ConfigurationTemplate.CONTEXT_TRANSFER_ASSISTANT
KNOWLEDGE_TRANSFER_ASSISTANT = ConfigurationTemplate.KNOWLEDGE_TRANSFER_ASSISTANT
PROJECT_ASSISTANT = ConfigurationTemplate.PROJECT_ASSISTANT


35 changes: 18 additions & 17 deletions assistants/project-assistant/assistant/state_inspector.py
Original file line number Diff line number Diff line change
@@ -13,8 +13,10 @@
ConversationContext,
)

from assistant.utils import is_knowledge_transfer_assistant

from .conversation_project_link import ConversationProjectManager
from .project_common import ConfigurationTemplate, detect_assistant_role, get_template
from .project_common import detect_assistant_role
from .project_data import RequestStatus
from .project_manager import ProjectManager
from .project_storage import ProjectStorage
@@ -54,12 +56,11 @@ async def get(self, context: ConversationContext) -> AssistantConversationInspec
# State variables that will determine the content to display.
conversation_role = await detect_assistant_role(context)

template = get_template(context)
is_context_transfer = template == ConfigurationTemplate.CONTEXT_TRANSFER_ASSISTANT
is_knowledge_transfer = is_knowledge_transfer_assistant(context)

if is_context_transfer:
self.display_name = "Knowledge Context"
self.description = "Context transfer information."
if is_knowledge_transfer:
self.display_name = "Knowledge Overview"
self.description = "Information about the knowledge space."

# Determine the conversation's role and project
project_id = await ConversationProjectManager.get_associated_project_id(context)
@@ -74,11 +75,11 @@ async def get(self, context: ConversationContext) -> AssistantConversationInspec

if conversation_role == ConversationRole.COORDINATOR:
markdown = await self._format_coordinator_markdown(
project_id, conversation_role, brief, project_info, context, is_context_transfer
project_id, conversation_role, brief, project_info, context, is_knowledge_transfer
)
else:
markdown = await self._format_team_markdown(
project_id, conversation_role, brief, project_info, context, is_context_transfer
project_id, conversation_role, brief, project_info, context, is_knowledge_transfer
)

return AssistantConversationInspectorStateDataModel(data={"content": markdown})
@@ -90,7 +91,7 @@ async def _format_coordinator_markdown(
brief: Any,
project_info: Any,
context: ConversationContext,
is_context_transfer: bool,
is_knowledge_transfer: bool,
) -> str:
"""Format project information as markdown for Coordinator role"""

@@ -101,7 +102,7 @@ async def _format_coordinator_markdown(

lines.append("**Role:** Coordinator")

if not is_context_transfer:
if not is_knowledge_transfer:
stage_label = "Planning Stage"
if project_info and project_info.state:
if project_info.state.value == "planning":
@@ -121,7 +122,7 @@ async def _format_coordinator_markdown(

lines.append("")

lines.append(f"## {'Knowledge' if is_context_transfer else 'Project'} Brief")
lines.append(f"## {'Knowledge' if is_knowledge_transfer else 'Project'} Brief")

title = brief.title if brief else "Untitled"
lines.append(f"### {title}")
@@ -132,13 +133,13 @@ async def _format_coordinator_markdown(
lines.append("")

# In context transfer mode, show additional context in a dedicated section
if is_context_transfer and brief.additional_context:
if is_knowledge_transfer and brief.additional_context:
lines.append("## Additional Knowledge Context")
lines.append(brief.additional_context)
lines.append("")

# Add goals section if available and progress tracking is enabled
if not is_context_transfer and project and project.goals:
if not is_knowledge_transfer and project and project.goals:
lines.append("## Goals")
for goal in project.goals:
criteria_complete = sum(1 for c in goal.success_criteria if c.completed)
@@ -210,7 +211,7 @@ async def _format_team_markdown(
brief: Any,
project_info: Any,
context: ConversationContext,
is_context_transfer: bool,
is_knowledge_transfer: bool,
) -> str:
"""Format project information as markdown for Team role"""

@@ -222,7 +223,7 @@ async def _format_team_markdown(
lines.append("**Role:** Team")

# Determine stage based on project status
if not is_context_transfer:
if not is_knowledge_transfer:
stage_label = "Working Stage"
if project_info and project_info.state:
if project_info.state.value == "planning":
@@ -255,13 +256,13 @@ async def _format_team_markdown(
lines.append("")

# In context transfer mode, show additional context in a dedicated section
if is_context_transfer and brief.additional_context:
if is_knowledge_transfer and brief.additional_context:
lines.append("## Additional Knowledge Context")
lines.append(brief.additional_context)
lines.append("")

# Add goals section with checkable criteria if progress tracking is enabled
if not is_context_transfer and project and project.goals:
if not is_knowledge_transfer and project and project.goals:
lines.append("## Objectives")
for goal in project.goals:
criteria_complete = sum(1 for c in goal.success_criteria if c.completed)
8 changes: 4 additions & 4 deletions assistants/project-assistant/assistant/tools.py
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@
from .project_notifications import ProjectNotifier
from .project_storage import ProjectStorage, ProjectStorageManager
from .project_storage_models import ConversationRole
from .utils import DEFAULT_TEMPLATE_ID, is_context_transfer_assistant
from .utils import DEFAULT_TEMPLATE_ID, is_knowledge_transfer_assistant


async def invoke_command_handler(
@@ -95,13 +95,13 @@ def __init__(self, context: ConversationContext, role: ConversationRole):
self.context = context
self.role = role
self.tool_functions = ToolFunctions()
self.is_context_transfer = is_context_transfer_assistant(context)
self.is_knowledge_transfer = is_knowledge_transfer_assistant(context)

template_id = context.assistant._template_id or DEFAULT_TEMPLATE_ID
self.config_template = (
ConfigurationTemplate.PROJECT_ASSISTANT
if template_id == DEFAULT_TEMPLATE_ID
else ConfigurationTemplate.CONTEXT_TRANSFER_ASSISTANT
else ConfigurationTemplate.KNOWLEDGE_TRANSFER_ASSISTANT
)

# Register common tools for both roles in both configs
@@ -1171,7 +1171,7 @@ async def suggest_next_action(self) -> Dict[str, Any]:

if not ready_for_working and self.role is ConversationRole.COORDINATOR:
# Check if it's ready to mark as ready for working
if self.config_template == ConfigurationTemplate.CONTEXT_TRANSFER_ASSISTANT:
if self.config_template == ConfigurationTemplate.KNOWLEDGE_TRANSFER_ASSISTANT:
has_goals = True
has_criteria = True
else:
Loading