Skip to main content

AnswerRocket Skill API Client

This is a client library for interacting with an AnswerRocket instance.

Installation

pip install answerrocket-client

Use

from answer_rocket import AnswerRocketClient
arc = AnswerRocketClient(url='https://your-answerrocket-instance.com', token='<your_api_token>')

# test that the config is valid
arc.can_connect()

# Get a resource file.  When running in an AnswerRocket instance, this call will fetch a customized version of the resource if one has been created.
import json
some_resource = json.loads(arc.config.get_artifact('path/to/my/file.json'))

# to run SQL, get the database ID from an AnswerRocket environment
table_name = "my_table"
sql = "SELECT sum(my_measure) from "+table_name
database_id = "my_database_id"

execute_sql_query_result = arc.data.execute_sql_query(database_id, sql, 100)

if execute_sql_query_result.success:
    print(execute_sql_query_result.df)    
else:
    print(execute_sql_query_result.error)
    print(execute_sql_query_result.code)

# language model calls use the configured settings from the connected Max instance (except for the secret key)
success, model_reply = arc.chat.completion(messages = "hakuna")

if success:
    # the reply is the full value of the LLM's return object
    reply = model_reply["choices"][0]["message"]["content"]
    print(f"** {reply} **")
else:
    # error reply is a description of the exception
    print("Error: "+model_reply)

# chat conversations and streaming replies are supported
messages = [
    { "role":"system",
      "content":"You are an efficient assistant helping a business user answer questions about data."},
    { "role":"user",
      "content":"Can you tell me the average of 150,12,200,54,24 and 32?  are any of these outliers?  Explain why."}
]

def display_streaming_result(str):
    print(str,end="", flush=True)

success, reply = arc.chat.completion(messages = messages, stream_callback=display_streaming_result)

Notes:

  • both the token and instance URL can be provided via the AR_TOKEN and AR_URL env vars instead, respectively. This is recommended to avoid accidentally committing a dev api token in your skill code. API token is available through the AnswerRocket UI for authenticated users.
  • when running outside of an AnswerRocket installation such as during development, make sure the openai key is set before importing answer_rocket, like os.environ['OPENAI_API_KEY'] = openai_completion_key. Get this key from OpenAI.

Working on the SDK

Setup

This repository contains a .envrc file for use with direnv. With that installed you should have a separate python interpreter that direnv's hook will activate for you when you cd into this repository.

Once you have direnv set up and activating inside the repo, just make to install dev dependencies and get started.

Finding things in the codebase

The main point of contact with users of this sdk is AnswerRocketClient in answer_rocket/client.py. That is, it is what users will import and initialize. Different categories of utilities can be grouped into modules in whatever way is most convenient, but they should be exposed via the client rather than through a separate import so that utilities for authentication, etc., can be reused.

The client hits an sdk-specific GraphQL API on its target AnswerRocket server. There is a graphql/schema.py with generated python types for what queries are available. When needed it can be regenerated with the generate-gql-schema makefile target. See the Makefile for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

answerrocket_client-0.2.108.tar.gz (68.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

answerrocket_client-0.2.108-py3-none-any.whl (69.5 kB view details)

Uploaded Python 3

File details

Details for the file answerrocket_client-0.2.108.tar.gz.

File metadata

  • Download URL: answerrocket_client-0.2.108.tar.gz
  • Upload date:
  • Size: 68.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for answerrocket_client-0.2.108.tar.gz
Algorithm Hash digest
SHA256 1d90be49ccf89d672ecf836967e44327ef8b4144fd1b8303fcae961e24fd12a1
MD5 b9ecc8a08794accbe8083030f911ac1d
BLAKE2b-256 952c05183d09ce521022fd06dc911d3b9f2e9a751db4296591cfece41bb626aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for answerrocket_client-0.2.108.tar.gz:

Publisher: publish-to-pypi.yml on answerrocket/answerrocket-python-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file answerrocket_client-0.2.108-py3-none-any.whl.

File metadata

File hashes

Hashes for answerrocket_client-0.2.108-py3-none-any.whl
Algorithm Hash digest
SHA256 4b45d474e8770d8d09b4fbaef7e87ce1e31245d63eea44508d5f4db5084f112a
MD5 e6445417458c095a8d97c17023970855
BLAKE2b-256 293a3f20d3abd17d6de698949e8dfa716e2f6ede68595a989f1853f956ccb5b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for answerrocket_client-0.2.108-py3-none-any.whl:

Publisher: publish-to-pypi.yml on answerrocket/answerrocket-python-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.108 This release

2 files

0.2.107

2 files

0.2.106

2 files

0.2.105

2 files

0.2.104

2 files

0.2.103

2 files

0.2.102

2 files

0.2.101

2 files

0.2.100

2 files

0.2.99

2 files

0.2.98

2 files

0.2.97

2 files

0.2.96

2 files

0.2.95

2 files

0.2.94

2 files

0.2.93

2 files

0.2.92

2 files

0.2.91

2 files

0.2.90

2 files

0.2.89

2 files

0.2.88

2 files

0.2.87

2 files

0.2.86

2 files

0.2.85

2 files

0.2.84

2 files

0.2.83

2 files

0.2.82

2 files

0.2.81

2 files

0.2.80

2 files

0.2.79

2 files

0.2.78

2 files

0.2.77

2 files

0.2.76

2 files

0.2.75

2 files

0.2.74

2 files

0.2.73

2 files

0.2.72

2 files

0.2.71

2 files

0.2.70

2 files

0.2.69

2 files

0.2.68

2 files

0.2.67

2 files

0.2.66

2 files

0.2.65

2 files

0.2.64

2 files

0.2.63

2 files

0.2.62

2 files

0.2.61

2 files

0.2.60

2 files

0.2.59

2 files

0.2.58

2 files

0.2.57

2 files

0.2.56

2 files

0.2.55

2 files

0.2.54

2 files

0.2.53

2 files

0.2.52

2 files

0.2.51

2 files

0.2.50

2 files

0.2.49

2 files

0.2.48

2 files

0.2.47

2 files

0.2.46

2 files

0.2.45

2 files

0.2.44

2 files

0.2.43

2 files

0.2.42

2 files

0.2.41

2 files

0.2.40

2 files

0.2.39

2 files

0.2.38

2 files

0.2.37

2 files

0.2.36

2 files

0.2.35

2 files

0.2.34

2 files

0.2.33

2 files

0.2.32

2 files

0.2.31

2 files

0.2.30

2 files

0.2.29

2 files

0.2.27

2 files

0.2.26

2 files

0.2.25

2 files

0.2.24

2 files

0.2.23

2 files

0.2.22

2 files

0.2.21

2 files

0.2.20

2 files

0.2.19

2 files

0.2.18

2 files

0.2.17

2 files

0.2.16

2 files

0.2.15

2 files

0.2.14

2 files

0.2.13

2 files

0.2.12

2 files

0.2.11

2 files

0.2.10

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.42.0

2 files

0.1.41.0

2 files

0.1.40.0

2 files

0.1.39.0

2 files

0.1.38.0

2 files

0.1.37.0

2 files

0.1.36.0

2 files

0.1.35.0

2 files

0.1.34.0

2 files

0.1.33.0

2 files

0.1.32.0

2 files

0.1.31.0

2 files

0.1.30.0

2 files

0.1.29.0

2 files

0.1.28.0

2 files

0.1.27.0

2 files

0.1.26.0

2 files

0.1.25.2

2 files

0.1.25.1

2 files

0.1.25

2 files

0.1.24

2 files

0.1.23

2 files

0.1.22

2 files

0.1.21

2 files

0.1.20

2 files

0.1.19

2 files

0.1.18

2 files

0.1.17.6

2 files

0.1.17.5

2 files

0.1.17.4

2 files

0.1.17.3

2 files

0.1.17.2

2 files

0.1.17.1

2 files

0.1.17

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 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