"git@developer.sourcefind.cn:chenzk/alphafold2_jax.git" did not exist on "8173117130e6df8749ab7349722ec465666df548"
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 ...@@ -8,9 +8,17 @@ import uuid
import time 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): for message in reversed(messages):
if message["role"] == "user": 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): if isinstance(message["content"], list):
for item in message["content"]: for item in message["content"]:
if item["type"] == "text": 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