|  | 
|  | 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | 
|  | 2 | + | 
|  | 3 | +import { APIResource } from '../../resource'; | 
|  | 4 | +import { isRequestOptions } from '../../core'; | 
|  | 5 | +import * as Core from '../../core'; | 
|  | 6 | +import * as VersionsAPI from './versions'; | 
|  | 7 | +import { Versions } from './versions'; | 
|  | 8 | + | 
|  | 9 | +export class Prompts extends APIResource { | 
|  | 10 | +  versions: VersionsAPI.Versions = new VersionsAPI.Versions(this._client); | 
|  | 11 | + | 
|  | 12 | +  /** | 
|  | 13 | +   * Create prompt. Create a new prompt. | 
|  | 14 | +   */ | 
|  | 15 | +  create(body: PromptCreateParams, options?: Core.RequestOptions): Core.APIPromise<Prompt> { | 
|  | 16 | +    return this._client.post('/v1/prompts', { body, ...options }); | 
|  | 17 | +  } | 
|  | 18 | + | 
|  | 19 | +  /** | 
|  | 20 | +   * Get prompt. Get a prompt by its identifier and optional version. | 
|  | 21 | +   */ | 
|  | 22 | +  retrieve( | 
|  | 23 | +    promptId: string, | 
|  | 24 | +    query?: PromptRetrieveParams, | 
|  | 25 | +    options?: Core.RequestOptions, | 
|  | 26 | +  ): Core.APIPromise<Prompt>; | 
|  | 27 | +  retrieve(promptId: string, options?: Core.RequestOptions): Core.APIPromise<Prompt>; | 
|  | 28 | +  retrieve( | 
|  | 29 | +    promptId: string, | 
|  | 30 | +    query: PromptRetrieveParams | Core.RequestOptions = {}, | 
|  | 31 | +    options?: Core.RequestOptions, | 
|  | 32 | +  ): Core.APIPromise<Prompt> { | 
|  | 33 | +    if (isRequestOptions(query)) { | 
|  | 34 | +      return this.retrieve(promptId, {}, query); | 
|  | 35 | +    } | 
|  | 36 | +    return this._client.get(`/v1/prompts/${promptId}`, { query, ...options }); | 
|  | 37 | +  } | 
|  | 38 | + | 
|  | 39 | +  /** | 
|  | 40 | +   * Update prompt. Update an existing prompt (increments version). | 
|  | 41 | +   */ | 
|  | 42 | +  update(promptId: string, body: PromptUpdateParams, options?: Core.RequestOptions): Core.APIPromise<Prompt> { | 
|  | 43 | +    return this._client.post(`/v1/prompts/${promptId}`, { body, ...options }); | 
|  | 44 | +  } | 
|  | 45 | + | 
|  | 46 | +  /** | 
|  | 47 | +   * List all prompts. | 
|  | 48 | +   */ | 
|  | 49 | +  list(options?: Core.RequestOptions): Core.APIPromise<PromptListResponse> { | 
|  | 50 | +    return ( | 
|  | 51 | +      this._client.get('/v1/prompts', options) as Core.APIPromise<{ data: PromptListResponse }> | 
|  | 52 | +    )._thenUnwrap((obj) => obj.data); | 
|  | 53 | +  } | 
|  | 54 | + | 
|  | 55 | +  /** | 
|  | 56 | +   * Delete prompt. Delete a prompt. | 
|  | 57 | +   */ | 
|  | 58 | +  delete(promptId: string, options?: Core.RequestOptions): Core.APIPromise<void> { | 
|  | 59 | +    return this._client.delete(`/v1/prompts/${promptId}`, { | 
|  | 60 | +      ...options, | 
|  | 61 | +      headers: { Accept: '*/*', ...options?.headers }, | 
|  | 62 | +    }); | 
|  | 63 | +  } | 
|  | 64 | + | 
|  | 65 | +  /** | 
|  | 66 | +   * Set prompt version. Set which version of a prompt should be the default in | 
|  | 67 | +   * get_prompt (latest). | 
|  | 68 | +   */ | 
|  | 69 | +  setDefaultVersion( | 
|  | 70 | +    promptId: string, | 
|  | 71 | +    body: PromptSetDefaultVersionParams, | 
|  | 72 | +    options?: Core.RequestOptions, | 
|  | 73 | +  ): Core.APIPromise<Prompt> { | 
|  | 74 | +    return this._client.post(`/v1/prompts/${promptId}/set-default-version`, { body, ...options }); | 
|  | 75 | +  } | 
|  | 76 | +} | 
|  | 77 | + | 
|  | 78 | +/** | 
|  | 79 | + * Response model to list prompts. | 
|  | 80 | + */ | 
|  | 81 | +export interface ListPromptsResponse { | 
|  | 82 | +  data: PromptListResponse; | 
|  | 83 | +} | 
|  | 84 | + | 
|  | 85 | +/** | 
|  | 86 | + * A prompt resource representing a stored OpenAI Compatible prompt template in | 
|  | 87 | + * Llama Stack. | 
|  | 88 | + */ | 
|  | 89 | +export interface Prompt { | 
|  | 90 | +  /** | 
|  | 91 | +   * Boolean indicating whether this version is the default version for this prompt | 
|  | 92 | +   */ | 
|  | 93 | +  is_default: boolean; | 
|  | 94 | + | 
|  | 95 | +  /** | 
|  | 96 | +   * Unique identifier formatted as 'pmpt\_<48-digit-hash>' | 
|  | 97 | +   */ | 
|  | 98 | +  prompt_id: string; | 
|  | 99 | + | 
|  | 100 | +  /** | 
|  | 101 | +   * List of prompt variable names that can be used in the prompt template | 
|  | 102 | +   */ | 
|  | 103 | +  variables: Array<string>; | 
|  | 104 | + | 
|  | 105 | +  /** | 
|  | 106 | +   * Version (integer starting at 1, incremented on save) | 
|  | 107 | +   */ | 
|  | 108 | +  version: number; | 
|  | 109 | + | 
|  | 110 | +  /** | 
|  | 111 | +   * The system prompt text with variable placeholders. Variables are only supported | 
|  | 112 | +   * when using the Responses API. | 
|  | 113 | +   */ | 
|  | 114 | +  prompt?: string; | 
|  | 115 | +} | 
|  | 116 | + | 
|  | 117 | +export type PromptListResponse = Array<Prompt>; | 
|  | 118 | + | 
|  | 119 | +export interface PromptCreateParams { | 
|  | 120 | +  /** | 
|  | 121 | +   * The prompt text content with variable placeholders. | 
|  | 122 | +   */ | 
|  | 123 | +  prompt: string; | 
|  | 124 | + | 
|  | 125 | +  /** | 
|  | 126 | +   * List of variable names that can be used in the prompt template. | 
|  | 127 | +   */ | 
|  | 128 | +  variables?: Array<string>; | 
|  | 129 | +} | 
|  | 130 | + | 
|  | 131 | +export interface PromptRetrieveParams { | 
|  | 132 | +  /** | 
|  | 133 | +   * The version of the prompt to get (defaults to latest). | 
|  | 134 | +   */ | 
|  | 135 | +  version?: number; | 
|  | 136 | +} | 
|  | 137 | + | 
|  | 138 | +export interface PromptUpdateParams { | 
|  | 139 | +  /** | 
|  | 140 | +   * The updated prompt text content. | 
|  | 141 | +   */ | 
|  | 142 | +  prompt: string; | 
|  | 143 | + | 
|  | 144 | +  /** | 
|  | 145 | +   * Set the new version as the default (default=True). | 
|  | 146 | +   */ | 
|  | 147 | +  set_as_default: boolean; | 
|  | 148 | + | 
|  | 149 | +  /** | 
|  | 150 | +   * The current version of the prompt being updated. | 
|  | 151 | +   */ | 
|  | 152 | +  version: number; | 
|  | 153 | + | 
|  | 154 | +  /** | 
|  | 155 | +   * Updated list of variable names that can be used in the prompt template. | 
|  | 156 | +   */ | 
|  | 157 | +  variables?: Array<string>; | 
|  | 158 | +} | 
|  | 159 | + | 
|  | 160 | +export interface PromptSetDefaultVersionParams { | 
|  | 161 | +  /** | 
|  | 162 | +   * The version to set as default. | 
|  | 163 | +   */ | 
|  | 164 | +  version: number; | 
|  | 165 | +} | 
|  | 166 | + | 
|  | 167 | +Prompts.Versions = Versions; | 
|  | 168 | + | 
|  | 169 | +export declare namespace Prompts { | 
|  | 170 | +  export { | 
|  | 171 | +    type ListPromptsResponse as ListPromptsResponse, | 
|  | 172 | +    type Prompt as Prompt, | 
|  | 173 | +    type PromptListResponse as PromptListResponse, | 
|  | 174 | +    type PromptCreateParams as PromptCreateParams, | 
|  | 175 | +    type PromptRetrieveParams as PromptRetrieveParams, | 
|  | 176 | +    type PromptUpdateParams as PromptUpdateParams, | 
|  | 177 | +    type PromptSetDefaultVersionParams as PromptSetDefaultVersionParams, | 
|  | 178 | +  }; | 
|  | 179 | + | 
|  | 180 | +  export { Versions as Versions }; | 
|  | 181 | +} | 
0 commit comments