Skip to main content

SDK for Ottic API

Project description

OTTIC SDK

Learn how to use the Ottic SDK to manage and use published prompts in your applications.

Setup

Follow these steps to install and configure the Ottic SDK:

Step 1: Install Ottic

Install the Ottic Node.js SDK.

pip install ottic

Step 2: Obtain Your Ottic API Key

Visit the Integrations page to copy your Ottic API key.

Note: This key is required to authenticate and use Ottic in your application.

Step 3: Integrate a Published Prompt

Use the snippet below to set up the Ottic SDK and begin working with a published prompt in your application:

from ottic import OtticAI

ottic = OtticAI(api_key=OTTIC_API_KEY)

Using a Published Prompt in Production

Ottic allows you to generate responses from LLM with your prompt in your application. Below are three use cases demonstrating how to generate responses with published prompts or render prompt text.

1. Generate a Response Using a Prompt

This snippet demonstrates how to use a published prompt with variable placeholders to generate a response from the model:

from ottic import OtticAI

ottic = OtticAI(api_key=OTTIC_API_KEY)

response = await ottic.chat.complete.create({
  promptId: 'YOUR_PROMPT_ID', # Replace with your published prompt ID
  variables: {
    variable: "dataset variable",
    variable1: "dataset variable1",
    variable2: "dataset variable2",
  },
  messages: [
    {
      role: 'user',
      content: "I want to buy a new insurance. I need help!",
    },
  ],
  metadata: {
    "userId": "METADATA_USER_ID",
    "userEmail": "USER@EMAIL.COM",
  },
  chainId: "CHAIN_ID",
  tags: ["TAG1", "TAG2"],
})
  • promptId (string, required): The ID of the published prompt you want to use.
  • variables (object): Variables you want to use in your prompt. Without variables, the prompt will be used as is.
  • messages (array): A list of messages comprising the conversation so far. If messages are not provided, the prompt will be used as is.
  • metadata (object): Contains additional information about the request.
  • chainId (string): Identifier for the chain of requests and responses.
  • tags (array): Array of strings that contain tags for the request.

Note: metadata, chainId, and tags are optional parameters to monitor your requests and responses.

Note: response will contain the output generated by the LLM based on the configuration of your Ottic prompt.

This snippet demonstrates how to request a response using the selected prompt settings. You can update the LLM configuration directly in Ottic and generate responses without modifying your code.

2. Retrieve a Rendered Prompt with Variable Replacements

To fetch a prompt with placeholders replaced by specified variable values, use the following code:

from ottic import OtticAI

ottic = OtticAI(api_key=OTTIC_API_KEY)
livePrompt = await ottic.prompts.render({
  promptId: 'YOUR_PROMPT_ID',
  variables: {
    variable: "dataset variable",
    variable1: "dataset variable1",
    variable2: "dataset variable2",
  },
})
  • promptId (string, required): The ID of the published prompt you want to use.
  • variables (object): Variables you want to use in your prompt. Without variables, the prompt will be used as is.

If any variables are missing, they will remain as placeholders in the returned prompt.

3. Retrieve a Prompt with Placeholders Intact

To retrieve a prompt without any variable replacements, use this snippet:

from ottic import OtticAI

ottic = OtticAI(api_key=OTTIC_API_KEY)
livePrompt = await ottic.prompts.render({ promptId: 'YOUR_PROMPT_ID' })

This will return the original prompt without modifications.

More information about Ottic API can be found https://docs.ottic.ai.

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

ottic-0.1.1.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

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

ottic-0.1.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file ottic-0.1.1.tar.gz.

File metadata

  • Download URL: ottic-0.1.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for ottic-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7ab306638f573379ca547d833428e0ccd29859d43a5869a5704f0fbaf74c4821
MD5 b52da454323e7ce58c7578f2fdf1b67d
BLAKE2b-256 e108784c9db1fa58fbca7bed44fca16243823ad920e45c4067418cc9fff25eb4

See more details on using hashes here.

File details

Details for the file ottic-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ottic-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for ottic-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 57886473e83f7851e4e433844531b90b2c5c2b80eaf4bb2bd88f45080e8d8c12
MD5 07ac019ff42b51e43385f2da8e3373cc
BLAKE2b-256 8f19de6a49d658fa4bd86b22cc63f381ed41c0ddae156193cd4f22b746b0e1c1

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