Skip to main content

OpenAI client plugin for space-evals

Project description

space-evals-client-openai

OpenAI client plugin for space-evals. Lets you use OpenAI models (GPT-4o, GPT-4, etc.) as the target, customer, or judge in your space-evals test suite.

Installation

pip install space-evals-client-openai

This installs the core space-evals package and the openai SDK as dependencies.

Setup

Set your API key:

export OPENAI_API_KEY=sk-...

Or use a custom env var name in your config (see below).

Usage

Via config file

Add provider: openai to any client role in your space-evals.yaml:

clients:
  target:
    provider: openai
    model: gpt-4o

  customer:
    provider: openai
    model: gpt-4o-mini

  judge:
    provider: openai
    model: gpt-4o

Then run your tests:

space-evals run ./tests/

Via programmatic API

import asyncio
from space_evals.engine import run_tests
from space_evals.clients.base import get_client

target = get_client("openai", model="gpt-4o")

result = asyncio.run(run_tests(
    path="./tests/",
    target_client=target,
))

Configuration

Field Type Default Description
provider string -- Must be "openai"
model string -- Model ID (e.g. gpt-4o, gpt-4o-mini, gpt-4-turbo)
api_key_env string OPENAI_API_KEY Env var containing your API key
params object {} Extra parameters passed to the OpenAI API (e.g. temperature, max_tokens)

Example with extra params

clients:
  target:
    provider: openai
    model: gpt-4o
    api_key_env: MY_OPENAI_KEY
    params:
      temperature: 0
      max_tokens: 2048

What this plugin does

  • Translates space-evals's Message format to OpenAI's chat completions API
  • Extracts tool calls from responses into space-evals's ToolCall format
  • Handles system prompts (used by the customer and judge roles)
  • Lazy-loads the OpenAI SDK on first use

Requirements

  • Python >= 3.11
  • space-evals >= 0.1.0
  • openai >= 1.0
  • OPENAI_API_KEY environment variable (or custom via api_key_env)

License

MIT

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

space_evals_client_openai-0.1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

space_evals_client_openai-0.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file space_evals_client_openai-0.1.0.tar.gz.

File metadata

File hashes

Hashes for space_evals_client_openai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d146e1fb4cdab58387ec1e2a51caff0bb65dac5280d45e18d70c4748964edf72
MD5 f4ea0bce13856928b0e4a5b5fb832d7a
BLAKE2b-256 44ae31593370b9bf842cde0c22afcf38d44f620d1e6e4ac45c9f50adec8a924b

See more details on using hashes here.

Provenance

The following attestation bundles were made for space_evals_client_openai-0.1.0.tar.gz:

Publisher: publish.yaml on Raghav-Sahai/Evals

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

File details

Details for the file space_evals_client_openai-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for space_evals_client_openai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 00a89d32032a56355653a9aacbf1777a0bcca7567175a590a3601a96dcd69c8b
MD5 ee7cd23b6dbfe3a5861dc2721c9ae794
BLAKE2b-256 fe8f1d5d518f69dcac6671a30c73c9fbc754a900c9b31cb5ecf6fffc1d10891f

See more details on using hashes here.

Provenance

The following attestation bundles were made for space_evals_client_openai-0.1.0-py3-none-any.whl:

Publisher: publish.yaml on Raghav-Sahai/Evals

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

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