Commit 7725a877 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

enh: get_last_user_message_item

parent fefa8a81
......@@ -8,9 +8,17 @@ import uuid
import time
def get_last_user_message(messages: List[dict]) -> str:
def get_last_user_message_item(messages: List[dict]) -> str:
for message in reversed(messages):
if message["role"] == "user":
return message
return None
def get_last_user_message(messages: List[dict]) -> str:
message = get_last_user_message_item(messages)
if message is not None:
if isinstance(message["content"], list):
for item in message["content"]:
if item["type"] == "text":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment