Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/gradient_labs/_conversation_assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AssignmentParams:
def assign_conversation(
*, client: HttpClient, conversation_id: str, params: AssignmentParams
) -> None:
"""run assigns a conversation to a participant."""
"""assigns a conversation to a participant."""
body = {"assignee_type": params.participant_type.value}
if params.assignee_id:
body["assignee_id"] = params.assignee_id
Expand Down
44 changes: 44 additions & 0 deletions src/gradient_labs/_conversation_resume.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from typing import Optional
from datetime import datetime

from dataclasses import dataclass
from dataclasses_json import dataclass_json

from ._http_client import HttpClient
from .conversation import ParticipantType


@dataclass_json
@dataclass(frozen=True)
class ResumeParams:
# assignee_type identifies the type of participant that this conversation is
# being assigned to. Set this to ParticipantTypeAIAgent to assign the conversation
# to the Gradient Labs AI agent.
assignee_type: ParticipantType

# assignee_id optionally identifies the specific user that the conversation
# is being assigned to.
assignee_id: Optional[str] = None

# Timestamp optionally defines the time when the conversation was assigned.
# If not given, this will default to the current time.
timestamp: Optional[datetime] = None

# reason optionally allows you to describe why this assignment is happening.
reason: Optional[str] = None


def resume_conversation(
*, client: HttpClient, conversation_id: str, params: ResumeParams
) -> None:
"""resume_conversation re-opens a conversation that was previously finished."""
body = {"assignee_type": params.participant_type.value}
if params.assignee_id:
body["assignee_id"] = params.assignee_id
if params.timestamp:
body["timestamp"] = HttpClient.localize(params.timestamp)

_ = client.put(
path=f"conversations/{conversation_id}/resume",
body=params.to_dict(),
)
9 changes: 9 additions & 0 deletions src/gradient_labs/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ._conversation_event import add_conversation_event, EventParams
from ._conversation_finish import finish_conversation, FinishParams
from ._conversation_rate import rate_conversation, RatingParams
from ._conversation_resume import resume_conversation, ResumeParams
from ._conversation_read import read_conversation, ReadParams
from ._conversation_start import start_conversation, StartConversationParams

Expand Down Expand Up @@ -158,6 +159,14 @@ def rate_conversation(self, *, conversation_id: str, params: RatingParams) -> No
params=params,
)

def resume_conversation(self, *, conversation_id: str, params: ResumeParams) -> None:
"""resume_conversation re-opens a conversation that was previously finished."""
resume_conversation(
client=self.http_client,
conversation_id=conversation_id,
params=params,
)

def read_conversation(
self, *, conversation_id: str, params: ReadParams
) -> Conversation:
Expand Down