==================
Anaconda Assistant
==================

Anaconda Assistant is your digital pair programmer for data science in `Anaconda Notebooks <http://nb.anaconda.cloud>`_! Made for novice and intermediate JupyterLabs notebook practitioners—yet handy for users of all levels—this AI assistant can help you:

* Write and debug code
* Analyze data
* Visualize results

The number of prompts you can make to the Assistant per day differs based on your tier:

.. csv-table::
    :file: ../../csv/notebook-assistant-capabilities.csv
    :widths: 40, 13, 13, 19, 15
    :header-rows: 1

.. note::
    \* Pro is a legacy tier no longer available for purchase.

Follow this quickstart guide to learn how to make the most of your Anaconda Assistant.

Starting with a notebook
========================

Anaconda recommends using the Assistant after you’ve loaded a DataFrame in your notebook.
 
.. note::
    Throughout the Assistant, *DataFrames* refer to Pandas DataFrames only, though certain dataframe types compatible with Pandas DataFrames could work as well.

This can be done in a few different ways:

- If you’re starting with an empty notebook, the Assistant provides you with the option to generate a DataFrame with random data, which you can then use to generate graphs and more.
- Use Anaconda data catalogs as a starting point: 

    #. Open a new Launcher by clicking the blue plus **+** in the top-left corner.
    #. In the Launcher, under Anaconda Data Catalogs, click Explore Catalogs.
    #. Click |runcells| **Run All Cells** to restart and run all the cells available in your notebook. This will render the DataFrame(s) in the notebook.

- If you already have specific data you’d like to work with and a proficiency in Jupyter Notebooks, import the data and generate a DataFrame as you normally would.

Accessing the Anaconda Assistant
================================

There are a few methods you can use to access the Anaconda Assistant:

.. tab-set::
  
  .. tab-item:: Anaconda Toolbox

    Click **Chat-based Python Help** in Anaconda Toolbox.
   
    .. thumbnail:: ../../img/assistant_in_toolbox.png
      :align: center
      :width: 50%
  
  .. tab-item:: Toolbar Icons

    Click |assistant| **Anaconda Assistant** on the right of your active notebook or the command toolbar at the top of your active notebook.

    .. thumbnail:: ../../img/assistant_in_toolbars.png
      :align: center

  .. tab-item:: Cell Assistant

    Click |assistant| **Anaconda Assistant** in the cell toolbar or **right-click** within an active cell to display Assistant quick prompts. 
    
    Use quick prompts for the entire cell or selected lines of code within the cell.

    .. thumbnail:: ../../img/assistant_in_cell.png
      :align: center
  
  .. tab-item:: Keyboard Shortcut
    
    Use the keyboard shortcut Ctrl+Shift+A (Windows)/Cmd+Shift+A (Mac).


Using the Anaconda Assistant
============================

Let’s take a look at the different parts of the Assistant and what we can do with this tool.

.. thumbnail:: ../../img/assistant_anatomy.png
   :align: center
   :width: 50%

#. **Start a new chat**
    At any time, you can start a new Assistant session, or “chat,” by clicking |newchat| **New chat**.
#. **History of previous chats**
    View and return to previous chats by clicking |clock-rotate-left| **Chats history**.
#. **Settings**
    Adjust where code is run in the notebook, enable or disable data collection and usage, and upgrade your account by clicking |gear| **Settings**.
#. **Assistant tasks**
    The Assistant allows you to perform a variety of functions, which are covered in the following section.
#. **Text box**
    Ask your own questions and make unique requests using the text box at the bottom of the Assistant.
#. **Chat limit used**
    Currently, each new chat allows a set amount of requests per 24 hour period. You may encounter a warning message when you reach the daily limit.
#. **Attach to chat**
    Add data for the Assistant to analyze and manipulate (in development).

Get started
===========

Explore code for various math equations and python projects independent of your notebook. Whether you’re starting from scratch or looking to take your project in a new direction, the code examples in this section can serve as much needed inspiration.

Build upon results by asking for deeper analysis or changes to the code using plain English. Make sure you provide specific instructions to the assistant! The more specific you are, the better your results will be.

Working with DataFrames
=======================

For notebooks containing DataFrames, the Assistant provides various methods for viewing and interacting with your data in a new way.

.. note::
  **Load a DataFrame** is the only option that will appear in this section if your notebook lacks a Pandas DataFrame. Running code to generate a DataFrame will trigger the availability of the other options.

Load a DataFrame
----------------

If you’re starting with an empty notebook, this option will open a menu of DataFrames for you to load in your notebook, which you can then use to generate a wide variety of graphs. You can also ask questions about the generated code and request changes using plain English. Remember to be specific! 

Generate a graph for the DataFrame
----------------------------------

This option generates a graph based on the DataFrame(s) in your notebook. If your notebook contains more than one DataFrame, you’re prompted to select which DataFrame you want to generate a graph for.

Click **Get Code** to have the Assistant provide you with a list of various types of graphs (bar, heatmap, etc.) it can generate based on the data in the DataFrame. You’re also presented with the code for generating the graph described in the first option listed, which you can then run in the notebook by clicking **Run in Notebook**, or you can copy the code to paste it yourself by clicking **Copy**.

If you want code for a different graph, or to see a new set of possibilities, use the text box to choose which graph you would like generated. Type something like the following:

- Generate the second idea
- Make a chart of #3, please
- Give me new options!

Describe the data in the DataFrame
----------------------------------

Analyze and visualize data more efficiently by having the Assistant generate a summary of—and potential use cases for—your DataFrame. This can be a great source of inspiration when you’re struggling to clearly explain the value your data provides.

Ask follow-up questions to dive deeper into the results. For example, if you find an interesting trend in your data, you can ask the Assistant to further refine the analysis or provide recommendations.

Suggestions for cleaning data
-----------------------------

The Assistant can provide various means for "cleaning up" your DataFrame by standardizing inconsistent information, removing duplicates, checking for missing values, and more. If your notebook contains more than one DataFrame, you’re prompted to select which DataFrame you want to clean.

For a brand new set of suggestions, click **Refresh Suggestions** at the top of the Assistant.

More suggestions…
-----------------

The Assistant can provide you with ideas for building upon your DataFrame, such as creating new visualizations, filtering based on specific conditions, removing unnecessary information, or even merging the DataFrame with an entirely new DataFrame.

For a brand new set of suggestions, click **Refresh Suggestions** at the top of the Assistant.

Enhancing the Assistant experience
==================================

This section provides tips on improving your working experience with the Assistant.

.. Referencing dataframes and other notebooks
.. ------------------------------------------
.. 
.. To enable context-based solutions when discussing your notebooks and dataframes, type **@** in the text box and select an artifact from the dropdown that appears. 
.. 
.. .. thumbnail:: ../../img/assistant_artifact.png
..    :align: center
..
    
Course correcting the conversation
----------------------------------

Sometimes, generative AI systems can encounter challenges when processing long conversations, leading to a decline in the quality of responses. If you find that the conversation is becoming less helpful to you, don't worry! Instead of restarting the entire conversation and losing the responses that *were* helpful to you, you can selectively remove messages by clicking |trash| **Delete this and all messages below** in the prompt. By pruning the conversation, you can seamlessly resume interaction with the Assistant from a point where responses were still valuable and relevant.

.. thumbnail:: ../../img/assistant_delete_messages.png
   :align: center

Setting code location
---------------------

To change where code generated by the Assistant gets added to your notebook, click |gear| **Settings**. Then, under **Run code in Notebook**, select from the dropdown a location where code should be added and run in the notebook.

.. thumbnail:: ../../img/assistant_run_code_location.png
   :align: center

Stopping a response from the Assistant
--------------------------------------

If you want to interrupt the Assistant mid-response (perhaps the Assistant misunderstood your prompt and is providing unnecessary information), press Enter (Windows)/Return (Mac) on your keyboard. Alternatively, you can click |stop| **Stop** in the text box.

.. thumbnail:: ../../img/assistant_stop_streaming.png
   :align: center

Frequently asked questions
==========================

Why am I not seeing all options under Working with DataFrames?
--------------------------------------------------------------

Some options for working with DataFrames are hidden until you run cells in your notebook that generate a DataFrame. Click |runcells| **Run All Cells** to restart and run all the cells available in your notebook. If one or more DataFrames are successfully generated in your notebook, all options should appear in the Assistant.

What programming languages are supported?
-----------------------------------------

Anaconda Assistant primarily supports Python, but we are planning to expand support to other languages in the future.

What personal data is collected when I use the Assistant?
---------------------------------------------------------

When you first use Anaconda Assistant, you are prompted to opt in to Anaconda’s data collection and usage of chat messages. Whether or not you opt in, `OpenAI’s terms of use <https://openai.com/policies/terms-of-use>`_ on data collection and usage still apply.

If you opt in, Anaconda collects all chat information, user IDs, and event logs.

If you opt out, Anaconda only collects event logs and your user ID—any prompts you have entered in the chat remain undisclosed.

How do I provide feedback?
--------------------------

Use the buttons embedded within the Assistant to provide positive or negative feedback:

.. thumbnail:: ../../img/assistant_feedback.png
   :align: center

.. |runcells| raw:: html

   <svg class="inline" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
   <path d="M2 4L8 8L2 12V4Z"/>
   <path d="M14 8L8 4V8V12L14 8Z"/>
   </svg>     

.. |assistant| raw:: html

    <svg class="inline" width="16" height="16" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
    <path
    d="M10.125 3.25C10.0312 3.1875 10 3.09375 10 3C10 2.90625 10.0312 2.84375 10.125 2.78125L12 2L12.75 0.15625C12.8125 0.0625 12.9062 0 13 0C13.0938 0 13.1562 0.0625 13.2188 0.15625L14 2L15.8438 2.78125C15.9375 2.84375 16 2.90625 16 3C16 3.09375 15.9375 3.1875 15.8438 3.25L14 4L13.2188 5.875C13.1562 5.96875 13.0938 6 13 6C12.9062 6 12.8125 5.96875 12.75 5.875L12 4L10.125 3.25ZM15.8438 12.7812C15.9375 12.8438 16 12.9062 16 13C16 13.0938 15.9375 13.1875 15.8438 13.25L14 14L13.2188 15.875C13.1562 15.9688 13.0938 16 13 16C12.9062 16 12.8125 15.9688 12.75 15.875L12 14L10.125 13.25C10.0312 13.1875 10 13.0938 10 13C10 12.9062 10.0312 12.8438 10.125 12.7812L12 12L12.75 10.1562C12.8125 10.0625 12.9062 10 13 10C13.0938 10 13.1562 10.0625 13.2188 10.1562L14 12L15.8438 12.7812ZM12 8C12 8.1875 11.875 8.375 11.7188 8.4375L8.1875 10.2188L6.4375 13.75C6.34375 13.9062 6.15625 14 6 14C5.78125 14 5.625 13.9062 5.53125 13.75L3.78125 10.2188L0.25 8.4375C0.09375 8.375 0 8.1875 0 8C0 7.8125 0.09375 7.625 0.25 7.5625L3.78125 5.78125L5.53125 2.28125C5.71875 1.9375 6.25 1.9375 6.4375 2.28125L8.1875 5.78125L11.7188 7.5625C11.875 7.625 12 7.8125 12 8Z"
    fill="#31a824"
    />
    </svg>

.. |newchat| raw:: html

    <svg class="inline" width="16" height="16" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23 20">
      <path d="M12 0.125C18.0586 0.125 22.957 4.16406 22.957 9.0625C22.957 14.0039 18.0586 18 12 18C10.3242 18 8.77734 17.6992 7.35938 17.1836C6.28516 18.043 4.17969 19.375 1.34375 19.375C1.17188 19.375 1.04297 19.332 1 19.2031C0.957031 19.0742 0.957031 18.9023 1.08594 18.8164C1.08594 18.7734 2.89062 16.8828 3.40625 14.6914C1.90234 13.1445 1 11.2109 1 9.0625C1 4.16406 5.89844 0.125 12 0.125ZM15.4375 10.0938C15.9961 10.0938 16.4688 9.66406 16.4688 9.0625C16.4688 8.50391 15.9961 8.03125 15.3945 8.03125H12.9883V5.625C12.9883 5.06641 12.5586 4.59375 12 4.59375C11.3984 4.59375 10.9688 5.06641 10.9258 5.625V8.07422H8.51953C7.96094 8.07422 7.53125 8.50391 7.53125 9.0625C7.53125 9.66406 7.96094 10.0938 8.51953 10.0938H10.9688V12.543C10.9688 13.1016 11.3984 13.5312 12 13.5312C12.5586 13.5312 12.9883 13.1016 13.0312 12.5V10.0938H15.4375Z" fill="currentColor"></path>

    </svg>

.. |clock-rotate-left| raw:: html

    <svg class="inline" xmlns="http://www.w3.org/2000/svg" width="21" height="19" viewBox="0 0 21 19">
      <path d="M19.1797 7.625C20.3516 13.6406 15.7812 18.875 10 18.875C8.4375 18.875 6.99219 18.5234 5.70312 17.8594C4.96094 17.4688 4.80469 16.4531 5.39062 15.8672C5.78125 15.4766 6.36719 15.3984 6.875 15.6328C7.8125 16.1406 8.86719 16.375 10 16.375C14.2578 16.375 17.6562 12.4688 16.6797 8.01562C16.1328 5.28125 13.6328 2.625 10 2.625C9.49219 2.625 7.1875 2.58594 5.11719 4.65625L6.60156 6.14062C7.14844 6.6875 6.75781 7.625 5.97656 7.625H1.21094C0.898438 7.625 0.625 7.35156 0.625 7V2.27344C0.625 1.49219 1.5625 1.10156 2.10938 1.64844L3.35938 2.89844C4.88281 1.375 7.07031 0.125 10 0.125C16.8359 0.125 18.9062 6.21875 19.1797 7.625ZM10 4.5C10.5078 4.5 10.9375 4.92969 10.9375 5.4375V9.65625L13.0078 11.2578C13.4375 11.5703 13.5156 12.1562 13.2031 12.5859C13.0078 12.8203 12.7344 12.9375 12.4609 12.9375C12.2656 12.9375 12.0703 12.8984 11.9141 12.7812L9.41406 10.9062C9.17969 10.7109 9.0625 10.4375 9.0625 10.125V5.4375C9.0625 4.92969 9.45312 4.5 10 4.5Z" fill="currentColor"></path>
      
    </svg>

.. |gear| raw:: html

        <svg class="inline" width="16" height="16" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
      <path
        d="M481.9 166.6c3.2 8.7 .5 18.4-6.4 24.6l-30.9 28.1c-7.7 7.1-11.4 17.5-10.9 27.9c.1 2.9 .2 5.8 .2 8.8s-.1 5.9-.2 8.8c-.5 10.5 3.1 20.9 10.9 27.9l30.9 28.1c6.9 6.2 9.6 15.9 6.4 24.6c-4.4 11.9-9.7 23.3-15.8 34.3l-4.7 8.1c-6.6 11-14 21.4-22.1 31.2c-5.9 7.2-15.7 9.6-24.5 6.8l-39.7-12.6c-10-3.2-20.8-1.1-29.7 4.6c-4.9 3.1-9.9 6.1-15.1 8.7c-9.3 4.8-16.5 13.2-18.8 23.4l-8.9 40.7c-2 9.1-9 16.3-18.2 17.8c-13.8 2.3-28 3.5-42.5 3.5s-28.7-1.2-42.5-3.5c-9.2-1.5-16.2-8.7-18.2-17.8l-8.9-40.7c-2.2-10.2-9.5-18.6-18.8-23.4c-5.2-2.7-10.2-5.6-15.1-8.7c-8.8-5.7-19.7-7.8-29.7-4.6L69.1 425.9c-8.8 2.8-18.6 .3-24.5-6.8c-8.1-9.8-15.5-20.2-22.1-31.2l-4.7-8.1c-6.1-11-11.4-22.4-15.8-34.3c-3.2-8.7-.5-18.4 6.4-24.6l30.9-28.1c7.7-7.1 11.4-17.5 10.9-27.9c-.1-2.9-.2-5.8-.2-8.8s.1-5.9 .2-8.8c.5-10.5-3.1-20.9-10.9-27.9L8.4 191.2c-6.9-6.2-9.6-15.9-6.4-24.6c4.4-11.9 9.7-23.3 15.8-34.3l4.7-8.1c6.6-11 14-21.4 22.1-31.2c5.9-7.2 15.7-9.6 24.5-6.8l39.7 12.6c10 3.2 20.8 1.1 29.7-4.6c4.9-3.1 9.9-6.1 15.1-8.7c9.3-4.8 16.5-13.2 18.8-23.4l8.9-40.7c2-9.1 9-16.3 18.2-17.8C213.3 1.2 227.5 0 242 0s28.7 1.2 42.5 3.5c9.2 1.5 16.2 8.7 18.2 17.8l8.9 40.7c2.2 10.2 9.4 18.6 18.8 23.4c5.2 2.7 10.2 5.6 15.1 8.7c8.8 5.7 19.7 7.7 29.7 4.6l39.7-12.6c8.8-2.8 18.6-.3 24.5 6.8c8.1 9.8 15.5 20.2 22.1 31.2l4.7 8.1c6.1 11 11.4 22.4 15.8 34.3zM242 336a80 80 0 1 0 0-160 80 80 0 1 0 0 160z"
      />
    </svg>

.. |trash| raw:: html

      <svg class="inline" width="16" height="16" xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 448 512">
      <path
        d="M135.2 17.7L128 32H32C14.3 32 0 46.3 0 64S14.3 96 32 96H416c17.7 0 32-14.3 32-32s-14.3-32-32-32H320l-7.2-14.3C307.4 6.8 296.3 0 284.2 0H163.8c-12.1 0-23.2 6.8-28.6 17.7zM416 128H32L53.2 467c1.6 25.3 22.6 45 47.9 45H346.9c25.3 0 46.3-19.7 47.9-45L416 128z"
      />
      </svg>

.. |stop| raw:: html

      <svg class="inline" width="16" height="16" viewBox="0 0 22 23" xmlns="http://www.w3.org/2000/svg">
      <path 
        d="M11 0.75C17.0586 0.75 22 5.69141 22 11.75C22 17.8516 17.0586 22.75 11 22.75C4.89844 22.75 0 17.8516 0 11.75C0 5.69141 4.89844 0.75 11 0.75ZM15.125 14.8438V8.65625C15.125 8.09766 14.6523 7.625 14.0938 7.625H7.90625C7.30469 7.625 6.875 8.09766 6.875 8.65625V14.8438C6.875 15.4453 7.30469 15.875 7.90625 15.875H14.0938C14.6523 15.875 15.125 15.4453 15.125 14.8438Z"
      />
    </svg>
