Skip to main content

anaconda-assistant

The Anaconda Assistant Python client

Installation

conda install -c anaconda-cloud anaconda-assistant-sdk

How to authenticate

To use the Python client or CLI you can use anaconda login CLI, Anaconda Navigator, or

from anaconda_auth import login
login()

to launch a browser to login and save your API token to disk. For cases where you cannot utilize a browser to login you can grab your API and set the ANACONDA_AUTH_API_KEY=<api-key> env var.

The Python clients and integrations provide api_key as a keyword argument.

Terms of use and data collection

In order to use the Anaconda Assistant SDK and derived integrations the user must first agree to

On Data Collection: If you opt-in you will enjoy personalized recommendations and contribute to smarter features.

We prioritize your privacy:

  • Your data is never sold
  • Always secured
  • This setting only affects the data Anaconda stores
  • It does not affect the data that is sent to Open AI

To agree to the terms of service and configure data collection edit the ~/.anaconda/config.toml file

[plugin.assistant]
accepted_terms = true
data_collection = true

You may set data_collection = false if you chose to opt-out.

If you set accepted_terms = false the Anaconda Assistant SDK and derived integrations will not function.

If either or both of these values are unset in the ~/.anaconda/config.toml file, an exception will be raised.

Chat session

The ChatSession provides a multi-turn chat interface that saves input and output messages. The response can be streamed or provided in one chunk.

from anaconda_assistant import ChatSession

chat = ChatSession()

text = chat.completions("what are the the first 5 fibonacci numbers?", stream=False)
print(text)

text = chat.completions("make that the first 10 numbers", stream=True)
for chunk in text:
    print(chunk, end="")

Chat client

The ChatClient provides a low-level completions function that accepts a list of messages in the same format as OpenAI. The completions() method returns a ChatResponse object that allows streaming of the response similar to requests Response with .iter_content(), .iter_lines(), and .message, which returns the whole message as a string. Once the who message has been access or consumed through an iterable it is retained in the .message object. Additionally, the response object stores .tokens_used and .tokens_limit integers.

from anaconda_assistant import ChatClient

client = ChatClient()

messages = [
    {"role": "user", "content": "What is pi?"}
]

response = client.completions(messages=messages)

for chunk in response.iter_content():
    print(chunk, end="")

You can only consume the message with .iter_content() once, but the result is captured to the .message attribute while streaming.

Daily quotas

Each Anaconda subscription plan enforces a limit on the number of requests (calls to .completions()). The limits are documented on the Plans and Pricing page. Once the limit is reached the .completions() function will throw a DailyQuotaExceeded exception.

Users can upgrade their plans by visiting https://anaconda.cloud/profile/subscriptions.

Integrations

A number of 3rd party integrations are provided. In each case you will need to have optional packages installed.

LLM CLI

The LLM CLI can be use to send and receive messages with the Anaconda Assistant.

Required packages: llm

To direct your messages to Anaconda Assistant use the model name anaconda-assistant

> llm -m anaconda-assistant 'what is pi?'

LlamaIndex

To use the LlamaIndex integration you will need to install at least llama-index-core

Required packages: llama-index-core

The AnacondaAssistant class supports streaming and non-streaming completions and chat methods. A system prompt can be provided to AnacondaAssistant with the system_prompt keyword argument

from anaconda_assistant.integrations.llama_index import AnacondaAssistant

llm = AnacondaAssistant()

# Completions example
for c in llm.stream_complete('who are you?'):
    print(c.delta, end='')

# Chat example
from llama_index.core.llms import ChatMessage
response = model.chat(messages=[ChatMessage(content="Who are you?")])

# custom system prompt
prompted = AnacondaAssistant(system_prompt='you are a kitty, you will response with meow!')
print(prompted.complete('what is pi?'))

LangChain

A LangChain integration is provided that supports message streaming and non-streaming responses.

Required packages: langchain-core >=0.3 and langchain >=0.3

from anaconda_assistant.integrations.langchain import AnacondaAssistant
from langchain.prompts import ChatPromptTemplate

model = AnacondaAssistant()
prompt = ChatPromptTemplate.from_template("tell me a joke about {topic}")
chain = prompt | model

message = chain.invoke({'topic': 'python'})
print(message.content)

ELL

You can use Anaconda Assistant as a model in the ell prompt engineering framework.

Required packages: ell-ai[sqlite] or ell-ai[postgres]

import ell
import anaconda_assistant.integrations.ell

ell.init(verbose=True)

@ell.simple(model="anaconda-assistant")
def who():
    return "Who are you?"

who()

PandasAI

To use Anaconda Assistant with PandasAI configure the SmartDataFrame using the AnacondaAssistant plugin

Required packages: pandasai

from anaconda_assistant.integrations.pandasai import AnacondaAssistant
from pandasai import SmartDataframe

ai = AnacondaAssistant()
sdf = SmartDataframe(df, config={'llm': ai})
sdf.chat('what is the average of this column where some condition is true?')

Panel

You can integrate the Anaconda Assistant in your Panel application using the chat features including the name and avatar for the signed in user.

Required packages: panel

import panel as pn

from anaconda_auth import BaseClient
from anaconda_assistant.integrations.panel import AnacondaAssistantCallbackHandler

callback = AnacondaAssistantCallbackHandler()
auth_client = BaseClient()

chat = pn.chat.ChatInterface(
    callback=callback,
    user=auth_client.name,
    avatar=auth_client.avatar,
    placeholder_threshold=0.05
)

Setup for development

Ensure you have conda installed. Then run:

make setup

Run the unit tests

make test

Run the unit tests across isolated environments with tox

make tox

Metadata

Release files for anaconda-assistant-sdk 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anaconda-assistant-sdk 0.5.2
File Size Uploaded
anaconda_assistant_sdk-0.5.2.tar.gz 31.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for anaconda-assistant-sdk 0.5.2
File Interpreter ABI Platform
anaconda_assistant_sdk-0.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 63.4 kB

Release files / anaconda_assistant_sdk-0.5.2.tar.gz

Download URL anaconda_assistant_sdk-0.5.2.tar.gz
Size 31.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e9375aa828faf46ae4025a6312f85f5744ca621592da53ca9dcb98a47413ea64
BLAKE2b-256 checksum
How to use checksums
062256fdbced8ce3868a3b2a3a1bc3face7b0386fd9c638128c23ff21c6878e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release files / anaconda_assistant_sdk-0.5.2-py3-none-any.whl

Download URL anaconda_assistant_sdk-0.5.2-py3-none-any.whl
Size 31.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a2d359a6c423fe85df16de477c410d4221b666135238caf9c978f93de265b0c
BLAKE2b-256 checksum
How to use checksums
96a2bf928b4baf86286819d23d4b824d8ece9439533298859a5861ea80cc524a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release history Release notifications | RSS feed

This release

0.5.2 This release

2 release files

0.4.0

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.4

2 release files

0.3.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page