fix URL issue with agents

This commit is contained in:
Xi Yan 2024-09-23 16:44:25 -07:00
parent 9eb5ec3e4b
commit 70fb70a71c

View file

@ -7,6 +7,7 @@
import asyncio
import copy
import os
import re
import secrets
import shutil
import string
@ -378,6 +379,11 @@ class ChatAgent(ShieldRunnerMixin):
elif attachments and AgentTool.code_interpreter.value in enabled_tools:
urls = [a.content for a in attachments if isinstance(a.content, URL)]
# TODO: we need to migrate URL away from str type
pattern = re.compile("^(https?://|file://|data:)")
urls += [
URL(uri=a.content) for a in attachments if pattern.match(a.content)
]
msg = await attachment_message(self.tempdir, urls)
input_messages.append(msg)