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
9 changes: 4 additions & 5 deletions chatkit/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
Annotated,
Any,
AsyncGenerator,
Awaitable,
Generic,
Sequence,
TypeVar,
Expand Down Expand Up @@ -634,9 +633,9 @@ class ThreadItemConverter:
Other item types are converted automatically.
"""

def attachment_to_message_content(
async def attachment_to_message_content(
self, attachment: Attachment
) -> Awaitable[ResponseInputContentParam]:
) -> ResponseInputContentParam:
"""
Convert an attachment in a user message into a message content part to send to the model.
Required when attachments are enabled.
Expand All @@ -645,7 +644,7 @@ def attachment_to_message_content(
"An Attachment was included in a UserMessageItem but Converter.attachment_to_message_content was not implemented"
)

def tag_to_message_content(
async def tag_to_message_content(
self, tag: UserMessageTagContent
) -> ResponseInputContentParam:
"""
Expand Down Expand Up @@ -801,7 +800,7 @@ async def user_message_to_input(

tag_content: ResponseInputMessageContentListParam = [
# should return summarized text items
self.tag_to_message_content(tag)
await self.tag_to_message_content(tag)
for tag in uniq_tags
]

Expand Down
4 changes: 2 additions & 2 deletions docs/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class MyThreadConverter(ThreadItemConverter):

# ..handle other attachment types

def hidden_context_to_input(self, item: HiddenContextItem) -> Message:
async def hidden_context_to_input(self, item: HiddenContextItem) -> Message:
return Message(
type="message",
role="system",
Expand All @@ -335,7 +335,7 @@ class MyThreadConverter(ThreadItemConverter):
],
)

def tag_to_message_content(self, tag: UserMessageTagContent):
async def tag_to_message_content(self, tag: UserMessageTagContent):
tag_context = await retrieve_context_for_tag(tag.id)
return ResponseInputTextParam(
type="input_text",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ async def test_input_item_converter_to_input_items_mixed():

async def test_input_item_converter_user_input_with_tags():
class MyThreadItemConverter(ThreadItemConverter):
def tag_to_message_content(self, tag):
async def tag_to_message_content(self, tag):
return ResponseInputTextParam(
type="input_text", text=tag.text + " " + tag.data["key"]
)
Expand Down