kpbotla's picture
Upload 5 files
b2746c2 verified
raw
history blame contribute delete
491 Bytes
from smolagents import tool
@tool
def cite(input: str) -> str:
"""
Takes input as 'answer ||| url' and formats a markdown citation.
Args:
input (str): Combined answer and URL separated by '|||'.
Returns:
str: Formatted citation string with markdown link.
"""
try:
answer, url = input.split("|||")
return f"{answer.strip()}\n\nSource: [{url.strip()}]({url.strip()})"
except:
return "Could not format citation correctly."