Skip to main content

No project description provided

Project description

Scorecard AI Python Library

fern shield

Installation

Add this dependency to your project's build file:

pip install fern-scorecard
# or
poetry add fern-scorecard

Usage

We also export an HTTP client so that you can hit our APIs directly.

import scorecard

from scorecard.client import Scorecard

client = Scorecard(
  api_key="YOUR_API_KEY" # Defaults to SCORECARD_API_KEY
)

testset = client.testset.create(
  testset_id=1234, 
  user_query="Your prompt...", 
  model_params: {
    "param": "value"
  }
)

print(testset)

Async Client

Use our async cien to make non-blocking requests to the API.

import scorecard
import asyncio

from scorecard.client import AsyncScorecard

client = AsyncScorecard(
  api_key="YOUR_API_KEY" # Defaults to SCORECARD_API_KEY
)

async def main() -> None:
  testset = await client.testset.create(
    testset_id=1234, 
    user_query="Your prompt...", 
    model_params: {
      "param": "value"
    }
  )

  print(testset)

asyncio.run(main())

Timeouts

By default, the client is configured to have a timeout of 60 seconds. You can customize this value at client instantiation.

from scorecard.client import Scorecard

scorecard_client = Scorecard(
  api_key="YOUR_API_KEY",
  timeout=15,
)

Handling Exceptions

All exceptions thrown by the SDK will sublcass scorecard.ApiError.

from scorecard.core import ApiError
from scorecard import UnprocessableEntityError

try:
  client.testset.get("testset-id")
except UnprocessableEntityError as e: 
  # handle unprocessable entity error
except APIError as e:  
  # handle any api related error

Error codes are as followed:

Status Code Error Type
422 UnprocessableEntityError

Beta status

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning the package version to a specific version in your pyproject.toml file. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributing

While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

Project details


Download files

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

Source Distribution

scorecard_ai-0.1.4.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

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

scorecard_ai-0.1.4-py3-none-any.whl (34.8 kB view details)

Uploaded Python 3

File details

Details for the file scorecard_ai-0.1.4.tar.gz.

File metadata

  • Download URL: scorecard_ai-0.1.4.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.7.17 Linux/5.15.0-1053-azure

File hashes

Hashes for scorecard_ai-0.1.4.tar.gz
Algorithm Hash digest
SHA256 177f31f57450634f326a3ef6273f5b79463a92028780491ec9e6d16e46918bac
MD5 0dfe96766d5c625a52ccc674b7c59836
BLAKE2b-256 1133e1d1e94953114eabbbef56b9d85cfc2882abc375a18a63070a4d01d66d7e

See more details on using hashes here.

File details

Details for the file scorecard_ai-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: scorecard_ai-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 34.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.7.17 Linux/5.15.0-1053-azure

File hashes

Hashes for scorecard_ai-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 062d5b8df0ac15f09d5101925f8af518e6c375e27dfad16b56abd2dc4c31e573
MD5 786e03ee6cf9e9d6eac7ce23597395c2
BLAKE2b-256 4f3c59ca4ea03cc324c232d6b880712348ae714b54df708e33bd02e58eaccd0d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page