Skip to main content

Cloud Security Alliance AI Foundation Model API Clients

Project description

Cloud Security Alliance AI Foundation Model API Clients

This Python library (csa_ai_foundation_model_api_clients) provides API access to text completions for:

  • Anthropic Claude 3
  • Google Gemini 1.5
  • OpenAI ChatGPT 4

and has plans to add:

  • OpenAI ChatGPT 4 batch mode

You can set the following options:

  • system prompt (aka developer prompt, persona)
  • user prompt (aka instructions)
  • user data (as part of the user prompt)
  • temperature
  • max_tokens

and has plans to add:

  • top_p
  • top_k
  • model specific paramaters

Please note this code does not have tests, or good error handling, but it works. Also with respect to handling rate limiting that is on the todo, but currently if you use this tool put a sleep statement to slow it down.

Examples:

#!/usr/bin/env python3

import os

from foundation_model_api_clients import FoundationModelAPIClient

def main():
    model_name = 'claude'
    api_key = os.getenv('ANTHROPIC_CLAUDE_API_KEY')

    client = FoundationModelAPIClient(model_name, api_key)

    system_prompt = "You are a helpful assistant."
    user_prompt = "What is the capital of France?"
    user_data = None
    output_file = 'response.json'

    response = client.generate_response(
        system_prompt,
        user_prompt,
        user_data,
        temperature=0.7,
        max_tokens=100,
        output_file=output_file
    )

if __name__ == '__main__':
    main()

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

csa_ai_foundation_model_api_clients-0.0.4.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file csa_ai_foundation_model_api_clients-0.0.4.tar.gz.

File metadata

File hashes

Hashes for csa_ai_foundation_model_api_clients-0.0.4.tar.gz
Algorithm Hash digest
SHA256 a1f66ce02da3b1a0000fe3d9fa054fe506cbfe4cf19e42f5845431ff9ad6eefe
MD5 460fc07bf69b502a25af0b1004784c11
BLAKE2b-256 d256e2d5c893af98fdc9a26d41316a79d47cb72aee019c66765c84fe023ea039

See more details on using hashes here.

File details

Details for the file csa_ai_foundation_model_api_clients-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for csa_ai_foundation_model_api_clients-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8fc96e9b6d4fdb5b258c35353533aea4adb50d3c9968632a36e53548fb6e8970
MD5 47e3397fc26c547abf9fc87ac843ba06
BLAKE2b-256 f6a5aa4b994e9be7d6077e0f94ae330ded950d35efb05c0c9a977336c2615a64

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