Prompt Managemnt

Manage prompts centrally, fetch versions, and use variables for dynamic prompts

Prompt-Managemnt helps you manage prompts efficiently, retrieve specific versions, and compile prompts with dynamic variables.

Key Features

  • Prompt Management: Easily create, edit, and track multiple prompt versions.
  • Versioning: Supports major, minor, and patch updates for clear version control.
  • Dynamic Variables: Use {{variableName}} placeholders that are replaced dynamically at runtime.
  • Statistics: Access download statistics and version history directly from the UI.

Getting started

List of Prompts via the UI

Prompt
  1. Get a quick overview of all prompts created.
  2. Navigate to the Prompt in tmam.
  3. Explore the available prompts listed.

Create or Edit a Prompt

Prompt edit
  1. Create new prompts or update existing ones.
  2. Click + New to start a new prompt.
  3. In the prompt editor, enter the prompt name, add meta properties, and use placeholders (e.g., {{variableName}}) to represent dynamic values that will be substituted at runtime.
  4. Assign a draft, major, minor, or patch version when creating or updating prompts for better version control.

View Prompt Details

Once the prompt is creaetd, You can see information about the prompt along with details on all past versions.

Access prompmts via our SDK

First, create an API Key

To authenticate your requests, you need an API key. Here’s how you can create one:

  1. Go to the tmam.
  2. Navigate to the API Keys page.
  3. Click on Create API Key.
  4. Enter a name for your API key.
  5. Save the API key displayed. Ensure you store it securely as it will be used for authentication in the SDK.

Then, get prompt using the SDK

Here’s how you can fetch and compile a prompt in Python:

import tmam

response = tmam.get_prompt(
  url="http://api.tmam.ai/api/sdk/v1", 
  api_key="TMAM_API_KEY",  
  name="prompt_name",          
  should_compile=True,                
  variables={
    "name": "Ali",            
  },
)

print(response)

Here’s how you can fetch and compile a prompt in Typescript/Javascript:

import tmam 

const response = await tmam.getPrompts({
  name: "prompt_name",     // Fetch the prompt by name
  shouldCompile: true,      // Compile the prompt with provided variables
  variables: {
    name: "Ali",            // Pass variables for prompt compilation
  }
});

console.log(response);           // Print or process the fetched and compiled prompt

Expected outcome

{
  err: null,
  res: {
      promptId: 'a2e47d3e-6c13-4d7e-8b6e-2f7b91e3d9f4',
      name: 'prompt_name',
      version: '1.2.3',
      tags: [ 'user', 'greeting' ],
      metaProperties: { model: 'gpt4' },
      prompt: 'Hello {{name}}, how are you today?',
      compiledPrompt: 'Hello Ali, how are you today?'
  }
}

SDK Parameters

Below are the parameters for use with the SDK:

ParameterDescriptionRequired/Optional
urlSets the tmam URL. Defaults to the tmam_URL environment variable.Required
api_keySets the tmam API Key. Can also be provided via the tmam_API_KEY environment variable.Required
nameSets the name to fetch a unique prompt. Use this or prompt_id.Required*
prompt_idSets the ID to fetch a unique prompt. Use this or name.Optional*
versionSet to True to get the prompt with variable substitution.Optional
shouldCompileBoolean value that compiles the prompt using the provided variables.Optional
variablesSets the variables for prompt compilation.Optional
meta_propertiesSets the meta-properties for storing in the prompt’s access history metadata.Optional

* Either name or prompt_id must be provided.