Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tools: fix citations #108

Merged
merged 1 commit into from May 7, 2024
Merged

Tools: fix citations #108

merged 1 commit into from May 7, 2024

Conversation

lusmoura
Copy link
Contributor

@lusmoura lusmoura commented May 7, 2024

This PR fixes two issues:

  1. The Python interpreter tool generates all results as one single dict, but we should, instead, return one object per result. For example, if multiple files are generated, we should return one object per file. There are also some other fixes for this tool, such as the sucess typo.
  2. The function tools might have different parameters, such as code, expression, and result. Since we're enforcing the documents to contain text, the parameters are not always part of the response and as a consequence, they're not always cited. This PR adds fields and tool_name to the documents so that FE can use this information to display the correct citation.

New search-results event:

  • Python interpreter
{
    "event": "search-results",
    "data": {
        "is_finished": false,
        "search_results": [],
        "documents": [
            {
                "text": "2\n",
                "document_id": "Python_Interpreter:0:0",
                "title": "",
                "url": "",
                "fields": {
                    "code_runtime": "293",
                    "std_err": "",
                    "std_out": "2\n",
                    "success": "True",
                    "text": "2\n"
                },
                "tool_name": "Python_Interpreter"
            }
        ]
    }
}
  • Python interpreter with image
{
    "event": "search-results",
    "data": {
        "is_finished": false,
        "search_results": [],
        "documents": [
            {
                "text": "",
                "document_id": "Python_Interpreter:0:0",
                "title": "",
                "url": "",
                "fields": {
                    "code_runtime": "654",
                    "std_err": "",
                    "std_out": "",
                    "success": "True",
                },
                "tool_name": "Python_Interpreter"
            },
            {
                "text": "Created output file graph.png",
                "document_id": "Python_Interpreter:1:0",
                "title": "",
                "url": "",
                "fields": {
                    "output_file": "{\"filename\": \"graph.png\", \"b64_data\": \"iMAGE\"}",
                },
                "tool_name": "Python_Interpreter"
            }
        ]
    }
}
  • Wikipedia
{
    "event": "search-results",
    "data": {
        "is_finished": false,
        "search_results": [],
        "documents": [
            {
                "text": "Billie Eilish Pirate Baird O'Connell ( EYE-lish; born December 18, 2001) is an American singer and songwriter. She first gained public attention in 2015 with her debut single \"Ocean Eyes\", written and produced by her brother Finneas O'Connell, with whom she collaborates on music and live shows. In 2017, she released her debut extended play (EP), Don't Smile at Me. Commercially successful, it reached the top 15 of record charts in numerous countries, including the US, UK, Canada, and Australia.\nEilish's first studio album, When We All Fall Asleep, Where Do We Go? (2019), debuted atop the US Billboard 200 and UK Albums Chart. It was one of the year's best-selling albums, buoyed by the success of its fifth single, \"Bad Guy\", Eilish's first number-one on the US Billboard Hot 100. This made her the first artist born in the 21st century to release a chart-topping single. The next year, Eilish performed the theme song \"No Time to Die\" for the James Bond film of the same name, which topped the UK Singles Chart and won the Academy Award for Best Original Song in 2022. Her subsequent singles \"Everything I Wanted\", \"My Future\", \"Therefore I Am\", and \"Your Power\" peaked in the top 10 in the US and UK. Her second studio album, Happier Than Ever (2021), topped the charts in 25 countries. She wrote and performed \"What Was I Made For?\" for the fantasy film Barbie (2023), which became her second number-one single in the UK and earned her a second Academy Award.\nEilish has received multiple accolades, including nine Grammy Awards, two American Music Awards, two Guinness World Records, three MTV Video Music Awards, three Brit Awards, two Golden Globe Awards, and two Academy Awards. She is the youngest artist in Grammy history to win all four general field categories\u2014Record of the Year, Album of the Year,  Song of the Year, as well as Best New Artist\u2014in the same year. Eilish is also the first person born in the 21st century to win an Academy Award and the youngest ever two-time winner. She was featured on Time magazine's inaugural Time 100 Next list in 2019 and the Time 100 in 2021. According to the Recording Industry Association of America (RIAA) and Billboard, Eilish is the 26th-highest-certified digital singles artist and one of the most successful artists of the 2010s. She was honored as one of the BBC 100 Women in December 2022.\nEilish has a history of political activism, focusing on climate change awareness, women's reproductive rights, and gender equality.",
                "document_id": "doc_0",
                "title": "Billie Eilish",
                "url": "https://en.wikipedia.org/wiki/Billie_Eilish",
                "fields": {
                    "title": "Billie Eilish",
                    "url": "https://en.wikipedia.org/wiki/Billie_Eilish"
                },
                "tool_name": ""
            },
       }
}

Follow UP: FE changes

@lusmoura lusmoura requested a review from a team as a code owner May 7, 2024 11:29
Copy link
Contributor

@BeatrixCohere BeatrixCohere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lusmoura lusmoura merged commit 517207c into main May 7, 2024
2 checks passed
@lusmoura lusmoura deleted the luisa/fix_python_interpreter branch May 7, 2024 13:39
lakshyaag pushed a commit to lakshyaag/cohere-toolkit that referenced this pull request May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants