Skip to content

Latest commit

 

History

History
339 lines (233 loc) · 22.2 KB

File metadata and controls

339 lines (233 loc) · 22.2 KB

Sessions

Overview

Available Operations

create

Create a thread for traces.

Example Usage

from orq_ai_sdk import Orq
import os


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

    res = orq.sessions.create(external_id="<id>", duration=7329.24, contact_ids=[
        "<value 1>",
        "<value 2>",
    ], billing={
        "input_cost": 5975.95,
        "output_cost": 754.22,
        "total_cost": 2965.14,
    }, usage={
        "prompt_tokens": 424835,
        "completion_tokens": 793505,
        "total_tokens": 726901,
    }, traces_count=451437, tags=[
        "<value 1>",
        "<value 2>",
        "<value 3>",
    ])

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
external_id str ✔️ N/A
duration float ✔️ N/A
contact_ids List[str] ✔️ N/A
billing models.ThreadBilling ✔️ N/A
usage models.ThreadUsage ✔️ N/A
traces_count int ✔️ N/A
tags List[str] ✔️ N/A
project_id Optional[str] ➖ N/A
started_at date ➖ N/A
updated_at date ➖ N/A
title Optional[str] ➖ N/A
client Optional[str] ➖ N/A
repo Optional[str] ➖ N/A
kind Optional[models.ThreadKind] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.Thread

Errors

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

get_count

Get total count of trace threads.

Example Usage

from orq_ai_sdk import Orq
import os


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

    res = orq.sessions.get_count(filters={
        "interval": "SESSION_INTERVAL_LAST_30_MINUTES",
    })

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
filters models.ThreadFilters ✔️ N/A
limit Optional[int] ➖ N/A
page Optional[int] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.GetThreadCountResponse

Errors

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

list

List trace threads from your workspace.

Example Usage

from orq_ai_sdk import Orq
import os


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

    res = orq.sessions.list(filters={
        "interval": "SESSION_INTERVAL_LAST_7_DAYS",
    })

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
filters models.ThreadFilters ✔️ N/A
limit Optional[int] ➖ N/A
page Optional[int] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.ListThreadsResponse

Errors

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

list_tags

Retrieves all unique thread tags in the workspace.

Example Usage

from orq_ai_sdk import Orq
import os


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

    res = orq.sessions.list_tags()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

List[str]

Errors

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

get

Get a trace thread.

Example Usage

from orq_ai_sdk import Orq
import os


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

    res = orq.sessions.get(session_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
session_id str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.Thread

Errors

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

delete

Delete a trace thread.

Example Usage

from orq_ai_sdk import Orq
import os


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

    orq.sessions.delete(session_id="<id>")

    # Use the SDK ...

Parameters

Parameter Type Required Description
session_id str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Errors

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

update

Update a trace thread.

Example Usage

from orq_ai_sdk import Orq
import os


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

    res = orq.sessions.update(session_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
session_id str ✔️ N/A
external_id Optional[str] ➖ N/A
duration Optional[float] ➖ N/A
contact_ids List[str] ➖ N/A
billing Optional[models.ThreadBilling] ➖ N/A
usage Optional[models.ThreadUsage] ➖ N/A
traces_count Optional[int] ➖ N/A
tags List[str] ➖ N/A
project_id Optional[str] ➖ N/A
started_at date ➖ N/A
updated_at date ➖ N/A
clear_contact_ids Optional[bool] ➖ Remove every contact id. Mutually exclusive with contact_ids.
clear_tags Optional[bool] ➖ Remove every tag. Mutually exclusive with tags.
title Optional[str] ➖ N/A
client Optional[str] ➖ N/A
repo Optional[str] ➖ N/A
kind Optional[models.ThreadKind] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.Thread

Errors

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