Elffuss BraidHub

kikocis/llama-stack public

fix URL issue with agents
Changesetcd503abf30902a8f33228270f66a232bf41f91c185da85f1fcee60ae7773a42c
AuthorXi Yan <xiyan@meta.com> · 2024-09-23 16:44 -07:00
CommitterXi Yan <xiyan@meta.com> · 2024-09-23 16:44 -07:00
Parents329cf2dbbb63

Browse the files at this changeset

1 file changed

modified llama_stack/providers/impls/meta_reference/agents/agent_instance.py +6 −0
@@ -7,6 +7,7 @@
77 import asyncio
88 import copy
99 import os
10+import re
1011 import secrets
1112 import shutil
1213 import string
@@ -378,6 +379,11 @@
378379
379380 elif attachments and AgentTool.code_interpreter.value in enabled_tools:
380381 urls = [a.content for a in attachments if isinstance(a.content, URL)]
382+ # TODO: we need to migrate URL away from str type
383+ pattern = re.compile("^(https?://|file://|data:)")
384+ urls += [
385+ URL(uri=a.content) for a in attachments if pattern.match(a.content)
386+ ]
381387 msg = await attachment_message(self.tempdir, urls)
382388 input_messages.append(msg)
383389