Skip to content

Latest commit

 

History

History
347 lines (235 loc) · 45.5 KB

README.md

File metadata and controls

347 lines (235 loc) · 45.5 KB

Prompts

(prompts)

Overview

Available Operations

list

Returns a list of your prompts. The prompts are returned sorted by creation date, with the most recent prompts appearing first

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.prompts.list()

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
limit Optional[float] A limit on the number of objects to be returned. Limit can range between 1 and 50, and the default is 10
starting_after Optional[str] A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, ending with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include after=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the next page of the list.
ending_before Optional[str] A cursor for use in pagination. ending_before is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, starting with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include before=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the previous page of the list.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetAllPromptsResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

create

Create a prompt

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.prompts.create(request={
        "display_name": "Jed6",
        "prompt_config": {
            "messages": [
                {
                    "role": "system",
                    "content": "<value>",
                },
                {
                    "role": "system",
                    "content": [
                        {
                            "type": "image_url",
                            "image_url": {
                                "url": "https://well-worn-formation.biz",
                            },
                        },
                        {
                            "type": "text",
                            "text": "<value>",
                        },
                        {
                            "type": "text",
                            "text": "<value>",
                        },
                    ],
                },
                {
                    "role": "assistant",
                    "content": "<value>",
                },
            ],
        },
        "path": "Customer Service/Billing/Refund",
    })

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
request models.CreatePromptRequestBody ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.CreatePromptResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

retrieve

Retrieves a prompt object

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.prompts.retrieve(id="<id>")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ Unique identifier of the prompt
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetOnePromptResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

update

Update a prompt

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.prompts.update(id="<id>", path="Customer Service/Billing/Refund")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
id str ✔️ Unique identifier of the prompt
owner Optional[str] N/A
domain_id Optional[str] N/A
created Optional[str] N/A
updated Optional[str] N/A
created_by_id OptionalNullable[str] N/A
updated_by_id OptionalNullable[str] N/A
display_name Optional[str] The prompt’s name, meant to be displayable in the UI.
description OptionalNullable[str] The prompt’s description, meant to be displayable in the UI. Use this field to optionally store a long form explanation of the prompt for your own purpose
prompt_config Optional[models.UpdatePromptPromptConfig] A list of messages compatible with the openAI schema
metadata Optional[models.UpdatePromptMetadata] N/A
path Optional[str] The path where the entity is stored in the project structure. The first element of the path always represents the project name. Any subsequent path element after the project will be created as a folder in the project if it does not exists. Customer Service/Billing/Refund
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.UpdatePromptResponseBody

Errors

Error Type Status Code Content Type
models.UpdatePromptPromptsResponseBody 404 application/json
models.APIError 4XX, 5XX */*

delete

Delete a prompt

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    orq.prompts.delete(id="<id>")

    # Use the SDK ...

Parameters

Parameter Type Required Description
id str ✔️ Unique identifier of the prompt
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

list_versions

Returns a list of your prompt versions. The prompt versions are returned sorted by creation date, with the most recent prompt versions appearing first

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.prompts.list_versions(prompt_id="<id>")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
prompt_id str ✔️ N/A
limit Optional[float] A limit on the number of objects to be returned. Limit can range between 1 and 50, and the default is 10
starting_after Optional[str] A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, ending with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include after=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the next page of the list.
ending_before Optional[str] A cursor for use in pagination. ending_before is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, starting with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include before=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the previous page of the list.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ListPromptVersionsResponseBody

Errors

Error Type Status Code Content Type
models.APIError 4XX, 5XX */*

get_version

Retrieves a specific version of a prompt by its ID and version ID.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.prompts.get_version(prompt_id="<id>", version_id="<id>")

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
prompt_id str ✔️ The unique identifier of the prompt
version_id str ✔️ The unique identifier of the prompt version
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetPromptVersionResponseBody

Errors

Error Type Status Code Content Type
models.GetPromptVersionPromptsResponseBody 404 application/json
models.APIError 4XX, 5XX */*