API Client

API Client represents a low level interface for Model API. All API operation can be performed using this.

class abeja.opsbeellm.deployment.APIClient(credential: dict | None = None, timeout: int | None = None, max_retry_count: int | None = None)

A Low-Level client for OpsBee LLM Deployment API

from abeja.opsbeellm.deployment import APIClient

api_client = APIClient()
create_deployment(organization_id: str, name: str, type: str, description: str | None = None) dict

create a deployment

API reference: POST /opsbee-llm/organizations/<organization_id>/deployments

Request Syntax:
organization_id = "1410000000000"
name = "deployment name"
description = "deployment description"
type = "qa"
response = api_client.create_deployment(
    organization_id, name, type, description)
Params:
  • organization_id (str): organization identifier

  • name (str): deployment name

  • description (str): [optional] deployment description

  • type (str): deployment type. available type are “qa” or “chat”.

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890123",
    'organization_id': "1410000000000",
    'name': "deployment name",
    'description': "deployment description",
    'type': "qa",
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

delete_deployment(organization_id: str, deployment_id: str) dict

delete a deployment

API reference: DELETE /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "9968625354849"
response = api_client.delete_deployment(
    organization_id, deployment_id)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier

Return type:

dict

Returns:

Response Syntax:

{
    'message': 'deployment 9968625354849 was deleted.
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_deployment(organization_id: str, deployment_id: str) dict

get deployment

API reference: GET /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "9968625354849"
response = api_client.get_deployment(
    organization_id, deployment_id)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier

Return type:

dict

Returns:

Response Syntax:

{
    'id': '9968625354849',
    'organization_id': '3208401525829',
    'name': 'deployment-chat-gpt35-turbo',
    'description': 'Chat用デプロイメント',
    'type': 'chat',
    'history_count': 3,
    'created_at': '2023-12-04T16:01:52+09:00',
    'updated_at': '2023-12-04T16:01:52+09:00',
},
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_deployments(organization_id: str, offset: int | None = 0, limit: int | None = 1000) dict

get deployments

API reference: GET /opsbee-llm/organizations/<organization_id>/deployments

Request Syntax:
organization_id = "1410000000000"
offset = 0
limit = 1000
response = api_client.get_deployments(
    organization_id, offset, limit)
Params:
  • organization_id (str): organization identifier

  • offset (int): [optional] offset of deployments ( which starts from 0 )

  • limit (int): [optional] max number of deployments to be returned

Return type:

dict

Returns:

Response Syntax:

{
    'organization_id': '3208401525829'
    'deployments': [
        {
            'id': '3053595942757',
            'organization_id': '3208401525829',
            'name': 'deploymentA',
            'description': 'deploymentAの説明',
            'type': 'qa',
            'history_count': 0,
            'created_at': '2023-12-15T16:50:33+09:00',
            'updated_at': '2023-12-15T16:50:33+09:00'
        },
        {
            'id': '9968625354849',
            'organization_id': '3208401525829',
            'name': 'deployment-chat-gpt35-turbo',
            'description': 'Chat用デプロイメント',
            'type': 'chat',
            'history_count': 3,
            'created_at': '2023-12-04T16:01:52+09:00',
            'updated_at': '2023-12-04T16:01:52+09:00',
        },
        ...
    ],
    'offset': 0,
    'limit': 1000,
    'has_next': False,
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

update_deployment(organization_id: str, deployment_id: str, name: str, description: str | None = None) dict

update a deployment

API reference: PATCH /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "9968625354849"
name = "deployment name"
description = "deployment description"
response = api_client.update_deployment(
    organization_id, deployment_id, name, description)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier

  • name (str): deployment name

  • description (str): [optional] deployment description

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890123",
    'organization_id': "1410000000000",
    'name': "deployment name",
    'description': "deployment description",
    'type': "qa",
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

class abeja.opsbeellm.history.APIClient(credential: dict | None = None, timeout: int | None = None, max_retry_count: int | None = None)

A Low-Level client for OpsBee LLM History API

from abeja.opsbeellm.history import APIClient

api_client = APIClient()
add_chat_histories_to_dataset(organization_id: str, deployment_id: str, dataset_id: str, history_ids: List[str]) dict

add chat histories to a dataset

API reference: POST /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/histories/<history_id>/datasets/<dataset_id>/items

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
dataset_id = "1234567890127"
history_ids = ["1234567890125", "1234567890126"]
response = api_client.add_chat_history_to_dataset(
    organization_id, deployment_id, dataset_id, history_ids)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • dataset_id (str): dataset identifier

  • history_ids (list): list of history identifiers

Return type:

dict

Returns:

Response Syntax:

{
    'message': "Successfully added histories to dataset 1234567890127",
}
add_qa_histories_to_dataset(organization_id: str, deployment_id: str, dataset_id: str, history_ids: List[str]) dict

add qa histories to a dataset

API reference: POST /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/qa_histories/<history_id>/datasets/<dataset_id>/items

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
dataset_id = "1234567890127"
history_ids = ["1234567890125", "1234567890126"]
response = api_client.add_qa_history_to_dataset(
    organization_id, deployment_id, dataset_id, history_ids)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • dataset_id (str): dataset identifier

  • history_ids (list): list of history identifiers

Return type:

dict

Returns:

Response Syntax:

{
    'message': "Successfully added qa histories to dataset 1234567890127",
}
create_chat_history(organization_id: str, deployment_id: str, thread_id: str, input_text: str, output_text: str, input_token_count: int | None = 0, output_token_count: int | None = 0, tag_ids: list | None = None, metadata: List[Dict] | None = None) dict

create a chat history

API reference: POST /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/threads/<thread_id>/histories

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
thread_id = "1234567890123"
input_text = "ABEJAについて教えて"
output_text = "ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。"
tag_ids = ['1111111111111', '2222222222222']
metadata = [{'metadata1': 'value1'}, {'metadata2': 'value2'}]
response = api_client.create_chat_history(
    organization_id, deployment_id, thread_id, input_text, output_text, tag_ids, metadata)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • thread_id (str): thread identifier

  • input_text (str): input text to LLM

  • output_text (str): output text from LLM

  • input_token_count (str): token count of input text

  • output_token_count (str): token count of output text

  • tag_ids (list): list of tag identifiers

  • metadata (list[dict]): list of {key: value} metadata

    (key size limited under 65535 bytes. value size limited under 65535 bytes. number of keys limited under 20)

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890123",
    'organization_id': "1410000000000",
    'deployment_id': "1234567890123",
    'thread_id': "1234567890126",
    'thread_name': "スレッドA",
    'input_text': "ABEJAについて教えて",
    'output_text': "ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。",
    'input_token_count': 10,
    'output_token_count': 10,
    'tags': [
        {
            'id': "1234567890123",
            'name': "OK",
            'description': "",
            'color': "green",
        },
        {
            'id': "1345667887931",
            'name': "NG",
            'description': "",
            'color': "red",
        },
        ...
    ],
    'metadata': [
        {
            'id': "1234567890123",
            'key': "metadata1",
            'value': "dummy1",
        },
        {
            'id': "1345667871931",
            'key': "metadata2",
            'value': "dummy2",
        },
        ...
    ],
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

create_chat_history_metadata(organization_id: str, deployment_id: str, thread_id: str, history_id: str, key: str, value: str) dict

create a chat history metadata

API reference: POST /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/threads/<thread_id>/histories/<history_id>/metadata

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
thread_id = "1234567890124"
history_id = "1234567890125"
key = "metadata1"
value = "dummy1"
response = api_client.create_chat_history_metadata(
    organization_id, deployment_id, thread_id, history_id, key, value)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • thread_id (str): thread identifier

  • history_id (str): history identifier

  • key (str): key name of key-value metadata (limited to 65535 bytes and limited to number of keys is under 20)

  • value (str): value of key-value metadata (limited to 65535 bytes)

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890130",
    'organization_id': "1410000000000",
    'deployment_id': "1234567890123",
    'history_id': "1234567890125",
    'key': "metadata1",
    'value': "dummy1",
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

create_qa_history(organization_id: str, deployment_id: str, input_text: str, output_text: str, input_token_count: int | None = 0, output_token_count: int | None = 0, tag_ids: list | None = None, metadata: List[Dict] | None = None) dict

create a qa history

API reference: POST /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/qa_histories

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
input_text = "ABEJAについて教えて"
output_text = "ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。"
tag_ids = ['1111111111111', '2222222222222']
metadata = [{'metadata1': 'value1'}, {'metadata2': 'value2'}]
response = api_client.create_qa_history(
    organization_id, deployment_id, input_text, output_text, tag_ids, metadata)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • input_text (str): input text to LLM

  • output_text (str): output text from LLM

  • input_token_count (str): token count of input text

  • output_token_count (str): token count of output text

  • tag_ids (list): [optional] list of tag identifiers

  • metadata (list[dict]): [optional] list of {key: value} metadata

    (key size limited under 65535 bytes. value size limited under 65535 bytes. number of keys limited under 20)

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890123",
    'organization_id': "1410000000000",
    'deployment_id': "1234567890123",
    'thread_id': "1234567890126",
    'thread_name': "QA用スレッド",
    'input_text': "ABEJAについて教えて",
    'output_text': "ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。",
    'input_token_count': 10,
    'output_token_count': 10,
    'tags': [
        {
            'id': "1234567890123",
            'name': "OK",
            'description': "",
            'color': "green",
        },
        {
            'id': "1345667887931",
            'name': "NG",
            'description': "",
            'color': "red",
        },
        ...
    ],
    'metadata': [
        {
            'id': "1234567890123",
            'key': "metadata1",
            'value': "dummy1",
        },
        {
            'id': "1345667871931",
            'key': "metadata2",
            'value': "dummy2",
        },
        ...
    ],
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

create_qa_history_metadata(organization_id: str, deployment_id: str, history_id: str, key: str, value: str) dict

create a chat history metadata

API reference: POST /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/qa_histories/<history_id>/metadata

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
history_id = "1234567890125"
key = "metadata1"
value = "dummy1"
response = api_client.create_qa_history_metadata(
    organization_id, deployment_id, history_id, key, value)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • history_id (str): history identifier

  • key (str): key name of key-value metadata (limited to 65535 bytes and limited to number of keys is under 20)

  • value (str): value of key-value metadata (limited to 65535 bytes)

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890130",
    'organization_id': "1410000000000",
    'deployment_id': "1234567890123",
    'history_id': "1234567890125",
    'key': "metadata1",
    'value': "dummy1",
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

create_tag(organization_id: str, name: str, description: str | None = None, color: str | None = 'grey') dict

create a tag

API reference: POST /opsbee-llm/organizations/<organization_id>/tags

Request Syntax:
organization_id = "1410000000000"
name = "OK"
description = "有益な出力文が出力されるときのタグです"
color = "green"
response = api_client.create_tag(
    organization_id, name, description, color)
Params:
  • organization_id (str): organization identifier

  • name (str): tag name

  • description (str): [optional] tag description

  • color (str): [optional] tag color

    available colors are “red”, “orange”, “yellow”, “olive”, “green”, “teal”, “blue”, “violet”, “purple”, “pink”, “brown”, “grey”, “black”. default is “grey”.

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890123",
    'organization_id': "1410000000000",
    'name': "OK",
    'description': "有益な出力文が出力されるときのタグです",
    'color': "green",
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

create_thread(organization_id: str, deployment_id: str, name: str, description: str | None = None) dict

create a thread

API reference: POST /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/threads

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
name = "thread A to B"
description = "A さんと B さんのチャット"
response = api_client.create_thread(
    organization_id, deployment_id, name, description)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • name (str): thread name

  • description (str): [optional] thread description

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890123",
    'organization_id': "1410000000000",
    'deployment_id': "1234567890123",
    'name': "thread A to B",
    'description': "A さんと B さんのチャット",
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

delete_chat_history(organization_id: str, deployment_id: str, thread_id: str, history_id: str) dict

delete a chat history

API reference: DELETE /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/threads/<thread_id>/histories/<history_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
thread_id = "1234567890124"
history_id = "1234567890125"
response = api_client.delete_chat_history(
    organization_id, deployment_id, thread_id, history_id)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • thread_id (str): thread identifier

  • history_id (str): history identifier

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890125",
    'organization_id': "1410000000000",
    'deployment_id': "1234567890123",
    'thread_id': "1234567890124",
    'thread_name': "チャット用スレッド",
    'input_text': "ABEJAについて教えて",
    'output_text': "ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。",
    'input_token_count': 10,
    'output_token_count': 10,
    'tags': [
        {
            'id': "1234567890123",
            'name': "OK",
            'description': "",
            'color': "green",
        },
        {
            'id': "1345667887931",
            'name': "NG",
            'description': "",
            'color': "red",
        },
        ...
    ],
    'metadata': [
        {
            'id': "1234567890123",
            'key': "metadata1",
            'value': "dummy1",
        },
        {
            'id': "1345667871931",
            'key': "metadata2",
            'value': "dummy2",
        },
        ...
    ],
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

delete_chat_history_metadata(organization_id: str, deployment_id: str, thread_id: str, history_id: str, metadata_id: str) dict

delete a chat history metadata

API reference: DELETE /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/threads/<thread_id>

/histories/<history_id>/metadata/<metadata_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
thread_id = "1234567890124"
history_id = "1234567890125"
metadata_id = "1234567890130"
response = api_client.delete_chat_history_metadata(
    organization_id, deployment_id, thread_id, history_id, metadata_id)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • thread_id (str): thread identifier

  • history_id (str): history identifier

  • metadata_id (str): metadata identifier

Return type:

dict

Returns:

Response Syntax:

{
    'message': 'metadata 1234567890130 was deleted.'
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

delete_qa_history(organization_id: str, deployment_id: str, history_id: str) dict

delete a qa history

API reference: DELETE /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/qa_histories/<history_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
history_id = "1234567890125"
response = api_client.delete_qa_history(
    organization_id, deployment_id, history_id)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • history_id (str): history identifier

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890123",
    'organization_id': "1410000000000",
    'deployment_id': "1234567890123",
    'thread_id': "1234567890126",
    'thread_name': "QA用スレッド",
    'input_text': "ABEJAについて教えて",
    'output_text': "ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。",
    'input_token_count': 10,
    'output_token_count': 10,
    'tags': [
        {
            'id': "1234567890123",
            'name': "OK",
            'description': "",
            'color': "green",
        },
        {
            'id': "1345667887931",
            'name': "NG",
            'description': "",
            'color': "red",
        },
        ...
    ],
    'metadata': [
        {
            'id': "1234567890123",
            'key': "metadata1",
            'value': "dummy1",
        },
        {
            'id': "1345667871931",
            'key': "metadata2",
            'value': "dummy2",
        },
        ...
    ],
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

delete_qa_history_metadata(organization_id: str, deployment_id: str, history_id: str, metadata_id: str) dict

delete a qa history metadata

API reference: DELETE /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/qa_histories/<history_id>/metadata/<metadata_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
history_id = "1234567890125"
metadata_id = "1234567890130"
response = api_client.delete_qa_history_metadata(
    organization_id, deployment_id, history_id, metadata_id)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • history_id (str): history identifier

  • metadata_id (str): metadata identifier

Return type:

dict

Returns:

Response Syntax:

{
    'message': 'metadata 1234567890130 was deleted.'
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

delete_tag(organization_id: str, tag_id: str) dict

delete a tag

API reference: DELETE /opsbee-llm/organizations/<organization_id>/tags/<tag_id>

Request Syntax:
organization_id = "1410000000000"
tag_id = "9968625354849"
response = api_client.delete_tags(
    organization_id, deployment_id, tag_id)
Params:
  • organization_id (str): organization identifier

  • tag_id (str): tag identifier

Return type:

dict

Returns:

Response Syntax:

{
    'message': 'tag 9968625354849 was deleted.
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

delete_thread(organization_id: str, deployment_id: str, thread_id: str) dict

delete a thread

API reference: DELETE /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/threads/<thread_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "9968625354849"
thread_id = "1234567890125"
response = api_client.delete_thread(
    organization_id, deployment_id, thread_id)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier

  • thread_id (str): thread identifier

Return type:

dict

Returns:

Response Syntax:

{
    'message': 'thread 9968625354849 was deleted.
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_chat_histories(organization_id: str, deployment_id: str, search_query: str | None = None, offset: int | None = 0, limit: int | None = 1000, sort_by: str | None = 'updated_at', sort_order: str | None = 'desc') dict

get chat histories

API reference: GET /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/histories

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
offset = 0
limit = 1000
sort_by = "updated_at"
sort_order = "desc"
response = api_client.get_chat_histories(
    organization_id, deployment_id, offset, limit, sort_by, sort_order)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • search_query (str): [optional] search query
    • available search keys is below:
      • history_id:

      • input_text:

      • output_text:

      • input_token_count:

      • output_token_count:

      • tag_id:

      • tag_name:

      • metadata_id:

      • metadata_key:

      • metadata_value:

      • created_at:

      • updated_at:

    • AND and OR operators are available for each keys.

    • * operators are available for input_text:, output_text: keys.

    • <=, <, >=, > operators are available for input_token_count:, output_token_count:, created_at, updated_at keys.

    example:

    search_query=’input_text:”ABEJA*” AND input_token_count:>=10 AND metadata_key:metadata1 AND metadata_key:metadata2’

  • offset (int): [optional] offset of histories ( which starts from 0 )

  • limit (int): [optional] max number of histories to be returned

  • sort_by (str): [optional] field to sort the results by
    • available options include:
      • id

      • thread_id

      • input_text

      • output_text

      • input_token_count

      • output_token_count

      • created_at

      • updated_at

    • Defaults to updated_at if not specified.

  • sort_order (str): [optional] the order in which results are sorted
    • Available options:
      • asc for ascending order (e.g., oldest to newest)

      • desc for descending order (e.g., newest to oldest)

    • Defaults to desc if not specified.

Return type:

dict

Returns:

Response Syntax:

{
    'organization_id': '1410000000000'
    'deployment_id': '1234567890123',
    'thread_id': '1234567890126',
    'thread_name': 'thread name',
    'histories': [
        {
            'id': "1234567890123",
            'organization_id': "1410000000000",
            'deployment_id': "1234567890123",
            'thread_id': "1234567890126",
            'thread_name': "thread name",
            'input_text': "ABEJAについて教えて",
            'output_text': "ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。",
            'input_token_count': 10,
            'output_token_count': 10,
            'tags': [
                {
                    'id': "1234567890127",
                    'name': "OK",
                    'description': "",
                    'color': "green",
                },
                {
                    'id': "1345667887931",
                    'name': "NG",
                    'description': "",
                    'color': "red",
                },
                ...
            ],
            'metadata': [
                {
                    'id': "1234567890156",
                    'key': "metadata1",
                    'value': "dummy1",
                },
                {
                    'id': "1345667871931",
                    'key': "metadata2",
                    'value': "dummy2",
                },
                ...
            ],
            'created_at' : "2023-12-04T16:01:52+09:00",
            'updated_at' : "2023-12-04T16:01:52+09:00",
        },
        ...
    ],
    'offset': 0,
    'limit': 1000,
    'sort_by': "updated_at",
    'sort_order': "desc",
    'total': 10,
    'has_next': False,
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_chat_history(organization_id: str, deployment_id: str, thread_id: str, history_id: str) dict

get chat history

API reference: GET /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/threads/<thread_id>/histories/<history_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
thread_id = "1234567890125"
history_id = "1234567890129"
response = api_client.get_chat_history(
    organization_id, deployment_id, thread_id, history_id)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • thread_id (str): thread identifier

  • history_id (str): history identifier

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890123",
    'organization_id': "1410000000000",
    'deployment_id': "1234567890123",
    'thread_id': "1234567890126",
    'thread_name': "thread name",
    'input_text': "ABEJAについて教えて",
    'output_text': "ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。",
    'input_token_count': 10,
    'output_token_count': 10,
    'tags': [
        {
            'id': "1234567890127",
            'name': "OK",
            'description': "",
            'color': "green",
        },
        {
            'id': "1345667887931",
            'name': "NG",
            'description': "",
            'color': "red",
        },
        ...
    ],
    'metadata': [
        {
            'id': "1234567890156",
            'key': "metadata1",
            'value': "dummy1",
        },
        {
            'id': "1345667871931",
            'key': "metadata2",
            'value': "dummy2",
        },
        ...
    ],
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_qa_histories(organization_id: str, deployment_id: str, search_query: str | None = None, offset: int | None = 0, limit: int | None = 1000, sort_by: str | None = 'updated_at', sort_order: str | None = 'desc') dict

get qa histories

API reference: GET /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/qa_histories

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
offset = 0
limit = 1000
sort_by = "updated_at"
sort_order = "desc"
response = api_client.get_qa_histories(
    organization_id, deployment_id, offset, limit, sort_by, sort_order)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • search_query (str): [optional] search query
    • available search keys is below:
      • history_id:

      • input_text:

      • output_text:

      • input_token_count:

      • output_token_count:

      • tag_id:

      • tag_name:

      • metadata_id:

      • metadata_key:

      • metadata_value:

      • created_at:

      • updated_at:

    • AND and OR operators are available for each keys.

    • * operators are available for input_text:, output_text: keys.

    • <=, <, >=, > operators are available for input_token_count:, output_token_count:, created_at, updated_at keys.

    example:

    search_query=’input_text:”ABEJA*” AND input_token_count:>=10 AND metadata_key:metadata1 AND metadata_key:metadata2’

  • offset (int): [optional] offset of histories ( which starts from 0 )

  • limit (int): [optional] max number of histories to be returned

  • sort_by (str): [optional] field to sort the results by
    • available options include:
      • id

      • input_text

      • output_text

      • input_token_count

      • output_token_count

      • created_at

      • updated_at

    • Defaults to updated_at if not specified.

  • sort_order (str): [optional] the order in which results are sorted
    • Available options:
      • asc for ascending order (e.g., oldest to newest)

      • desc for descending order (e.g., newest to oldest)

    • Defaults to desc if not specified.

Return type:

dict

Returns:

Response Syntax:

{
    'organization_id': '1410000000000'
    'deployment_id': '1234567890123',
    'thread_id': '1234567890126',
    'thread_name': 'QA用スレッド',
    'histories': [
        {
            'id': "1234567890123",
            'organization_id': "1410000000000",
            'deployment_id': "1234567890123",
            'thread_id': "1234567890126",
            'thread_name': "QA用スレッド",
            'input_text': "ABEJAについて教えて",
            'output_text': "ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。",
            'input_token_count': 10,
            'output_token_count': 10,
            'tags': [
                {
                    'id': "1234567890127",
                    'name': "OK",
                    'description': "",
                    'color': "green",
                },
                {
                    'id': "1345667887931",
                    'name': "NG",
                    'description': "",
                    'color': "red",
                },
                ...
            ],
            'metadata': [
                {
                    'id': "1234567890156",
                    'key': "metadata1",
                    'value': "dummy1",
                },
                {
                    'id': "1345667871931",
                    'key': "metadata2",
                    'value': "dummy2",
                },
                ...
            ],
            'created_at' : "2023-12-04T16:01:52+09:00",
            'updated_at' : "2023-12-04T16:01:52+09:00",
        },
        ...
    ],
    'offset': 0,
    'limit': 1000,
    'sort_by': "updated_at",
    'sort_order': "desc",
    'total': 10,
    'has_next': False,
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_qa_history(organization_id: str, deployment_id: str, history_id: str) dict

get qa histories

API reference: GET /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/qa_histories/<history_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
history_id = "1234567890125"
response = api_client.get_qa_histories(
    organization_id, deployment_id, history_id)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • history_id (str): history identifier

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890123",
    'organization_id': "1410000000000",
    'deployment_id': "1234567890123",
    'thread_id': "1234567890126",
    'thread_name': "QA用スレッド",
    'input_text': "ABEJAについて教えて",
    'output_text': "ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。",
    'input_token_count': 10,
    'output_token_count': 10,
    'tags': [
        {
            'id': "1234567890127",
            'name': "OK",
            'description': "",
            'color': "green",
        },
        {
            'id': "1345667887931",
            'name': "NG",
            'description': "",
            'color': "red",
        },
        ...
    ],
    'metadata': [
        {
            'id': "1234567890156",
            'key': "metadata1",
            'value': "dummy1",
        },
        {
            'id': "1345667871931",
            'key': "metadata2",
            'value': "dummy2",
        },
        ...
    ],
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_tag(organization_id: str, tag_id: str) dict

get tags

API reference: GET /opsbee-llm/organizations/<organization_id>/tags/<tag_id>

Request Syntax:
organization_id = "1410000000000"
tag_id = "1234567890125"
response = api_client.get_tag(
    organization_id, tag_id)
Params:
  • organization_id (str): organization identifier

  • tag_id (str): tag identifier

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890125",
    'name': "OK",
    'description': "",
    'color': "green",
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
},
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_tags(organization_id: str, offset: int | None = 0, limit: int | None = 1000) dict

get history tags

API reference: GET /opsbee-llm/organizations/<organization_id>/tags

Request Syntax:
organization_id = "1410000000000"
offset = 0
limit = 1000
response = api_client.get_tags(
    organization_id, offset, limit)
Params:
  • organization_id (str): organization identifier

  • offset (int): [optional] offset of tags ( which starts from 0 )

  • limit (int): [optional] max number of tags to be returned

Return type:

dict

Returns:

Response Syntax:

{
    'organization_id': '1410000000000'
    'tags': [
        {
            'id': "1234567890125",
            'name': "OK",
            'description': "",
            'color': "green",
            'created_at' : "2023-12-04T16:01:52+09:00",
            'updated_at' : "2023-12-04T16:01:52+09:00",
        },
        {
            'id': "1345667887931",
            'name': "NG",
            'description': "",
            'color': "red",
            'created_at' : "2023-12-04T16:01:52+09:00",
            'updated_at' : "2023-12-04T16:01:52+09:00",
        },
        ...
    ],
    'offset': 0,
    'limit': 1000,
    'has_next': False,
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_thread(organization_id: str, deployment_id: str, thread_id: str) dict

get thread

API reference: GET /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/threads/<thread_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
thread_id = "1234567890125"
response = api_client.get_thread(
    organization_id, deployment_id, thread_id)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • thread_id (str): thread identifier

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890125",
    'organization_id': "1410000000000",
    'deployment_id': "1234567890123",
    'name': "thread A to B",
    'description': "threadA description",
    'created_at' : 2023-12-13T04:42:34.913644Z,
    'updated_at' : 2023-12-13T04:42:34.913644Z,
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_threads(organization_id: str, deployment_id: str, offset: int | None = 0, limit: int | None = 1000) dict

get threads

API reference: GET /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/threads

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
offset = 0
limit = 1000
response = api_client.get_threads(
    organization_id, deployment_id, offset, limit)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • offset (int): [optional] offset of threads ( which starts from 0 )

  • limit (int): [optional] max number of threads to be returned

Return type:

dict

Returns:

Response Syntax:

{
    'organization_id': '1410000000000'
    'deployment_id': '1234567890123',
    'threads': [
        {
            'id': "1234567890124",
            'organization_id': "1410000000000",
            'deployment_id': "1234567890123",
            'name': "thread A to B",
            'description': "A さんと B さんのチャット",
            'created_at' : 2023-12-04T16:01:52+09:00,
            'updated_at' : 2023-12-04T16:01:52+09:00,
        },
        {
            'id': "1234567890125",
            'organization_id': "1410000000000",
            'deployment_id': "1234567890123",
            'name': "thread A to C",
            'description': "A さんと C さんのチャット",
            'created_at' : "2023-12-04T16:01:52+09:00",
            'updated_at' : "2023-12-04T16:01:52+09:00",
        },
        ...
    ],
    'offset': 0,
    'limit': 1000,
    'total': 10,
    'has_next': False,
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

update_chat_history(organization_id: str, deployment_id: str, thread_id: str, history_id: str, input_text: str | None = None, output_text: str | None = None, input_token_count: int | None = None, output_token_count: int | None = None, tag_ids: list | None = None) dict

update a chat history

API reference: PATCH /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/threads/<thread_id>/histories/<history_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
thread_id = "1234567890124"
history_id = "1234567890125"
input_text = "ABEJAについて教えて"
output_text = "ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。"
response = api_client.update_qa_history(
    organization_id, deployment_id, thread_id, history_id, input_text, output_text)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • thread_id (str): thread identifier

  • history_id (str): history identifier

  • input_text (str): [optional] input text to LLM. if None is specified, the input_text does not updated.

  • output_text (str): [optional] output text from LLM. if None is specified, the output_text does not updated.

  • input_token_count (str): [optional] token count of input text. if None is specified, the input_token_count does not updated.

  • output_token_count (str): [optional] token count of output text. if None is specified, the output_token_count does not updated.

  • tag_ids (list): [optional] list of tag identifiers. if None is specified, the tag_ids does not updated.

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890123",
    'organization_id': "1410000000000",
    'deployment_id': "1234567890123",
    'thread_id': "1234567890126",
    'thread_name': "チャット用スレッド",
    'input_text': "ABEJAについて教えて",
    'output_text': "ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。",
    'input_token_count': 10,
    'output_token_count': 10,
    'tags': [
        {
            'id': "1234567890123",
            'name': "OK",
            'description': "",
            'color': "green",
        },
        {
            'id': "1345667887931",
            'name': "NG",
            'description': "",
            'color': "red",
        },
        ...
    ],
    'metadata': [
        {
            'id': "1234567890123",
            'key': "metadata1",
            'value': "dummy1",
        },
        {
            'id': "1345667871931",
            'key': "metadata2",
            'value': "dummy2",
        },
        ...
    ],
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

update_chat_history_metadata(organization_id: str, deployment_id: str, thread_id: str, history_id: str, metadata_id: str, key: str, value: str) dict

update a chat history metadata

API reference: PATCH /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/threads/<thread_id>

/histories/<history_id>/metadata/<metadata_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
thread_id = "1234567890124"
history_id = "1234567890125"
metadata_id = "1234567890130"
key = "metadata1"
value = "dummy1"
response = api_client.update_chat_history_metadata(
    organization_id, deployment_id, thread_id, history_id, metadata_id, key, value)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • thread_id (str): thread identifier

  • history_id (str): history identifier

  • metadata_id (str): metadata identifier

  • key (str): key name of key-value metadata (limited to 65535 bytes and limited to number of keys is under 20)

  • value (str): value of key-value metadata (limited to 65535 bytes)

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890130",
    'organization_id': "1410000000000",
    'deployment_id': "1234567890123",
    'history_id': "1234567890125",
    'key': "metadata1",
    'value': "dummy1",
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

update_qa_history(organization_id: str, deployment_id: str, history_id: str, input_text: str | None = None, output_text: str | None = None, input_token_count: int | None = None, output_token_count: int | None = None, tag_ids: list | None = None) dict

update a qa history

API reference: PATCH /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/qa_histories/<history_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
history_id = "1234567890125"
input_text = "ABEJAについて教えて"
output_text = "ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。"
response = api_client.update_qa_history(
    organization_id, deployment_id, history_id, input_text, output_text)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • history_id (str): history identifier

  • input_text (str): [optional] input text to LLM. if None is specified, the input_text does not updated.

  • output_text (str): [optional] output text from LLM. if None is specified, the output_text does not updated.

  • input_token_count (str): [optional] token count of input text. if None is specified, the input_token_count does not updated.

  • output_token_count (str): [optional] token count of output text. if None is specified, the output_token_count does not updated.

  • tag_ids (list): [optional] list of tag identifiers. if None is specified, the tag_ids does not updated.

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890123",
    'organization_id': "1410000000000",
    'deployment_id': "1234567890123",
    'thread_id': "1234567890126",
    'thread_name': "QA用スレッド",
    'input_text': "ABEJAについて教えて",
    'output_text': "ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。",
    'input_token_count': 10,
    'output_token_count': 10,
    'tags': [
        {
            'id': "1234567890123",
            'name': "OK",
            'description': "",
            'color': "green",
        },
        {
            'id': "1345667887931",
            'name': "NG",
            'description': "",
            'color': "red",
        },
        ...
    ],
    'metadata': [
        {
            'id': "1234567890123",
            'key': "metadata1",
            'value': "dummy1",
        },
        {
            'id': "1345667871931",
            'key': "metadata2",
            'value': "dummy2",
        },
        ...
    ],
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

update_qa_history_metadata(organization_id: str, deployment_id: str, history_id: str, metadata_id: str, key: str, value: str) dict

update a qa history metadata

API reference: PATCH /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/qa_histories/<history_id>/metadata/<metadata_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
history_id = "1234567890125"
metadata_id = "1234567890130"
key = "metadata1"
value = "dummy1"
response = api_client.update_qa_history_metadata(
    organization_id, deployment_id, thread_id, history_id, metadata_id, key, value)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • history_id (str): history identifier

  • metadata_id (str): metadata identifier

  • key (str): key name of key-value metadata (limited to 65535 bytes and limited to number of keys is under 20)

  • value (str): value of key-value metadata (limited to 65535 bytes)

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890130",
    'organization_id': "1410000000000",
    'deployment_id': "1234567890123",
    'history_id': "1234567890125",
    'key': "metadata1",
    'value': "dummy1",
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

update_tag(organization_id: str, tag_id: str, name: str, description: str | None = None, color: str | None = 'grey') dict

update a tag

API reference: PATCH /opsbee-llm/organizations/<organization_id>/tags/<tag_id>

Request Syntax:
organization_id = "1410000000000"
tag_id = "1234567890123"
name = "OK"
description = "有益な出力文が出力されるときのタグです"
color = "green"
response = api_client.update_tag(
    organization_id, tag_id, name, description, color)
Params:
  • organization_id (str): organization identifier

  • tag_id (str): tag identifier

  • name (str): tag name

  • description (str): [optional] tag description.

  • color (str): [optional] tag color

    available colors are “red”, “orange”, “yellow”, “olive”, “green”, “teal”, “blue”, “violet”, “purple”, “pink”, “brown”, “grey”, “black”. default is “grey”.

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890123",
    'organization_id': "1410000000000",
    'name': "OK",
    'description': "有益な出力文が出力されるときのタグです",
    'color': "green",
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

update_thread(organization_id: str, deployment_id: str, thread_id: str, name: str, description: str | None = None) dict

update a thread

API reference: PATCH /opsbee-llm/organizations/<organization_id>/deployments/<deployment_id>/threads/<thread_id>

Request Syntax:
organization_id = "1410000000000"
deployment_id = "1234567890123"
thread_id = "1234567890125"
name = "thread A to B"
description = "A さんと B さんのチャット"
response = api_client.update_thread(
    organization_id, deployment_id, thread_id, name, description)
Params:
  • organization_id (str): organization identifier

  • deployment_id (str): deployment identifier for OpsBee LLM

  • thread_id (str): thread identifier

  • name (str): thread name

  • description (str): [optional] thread description

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890125",
    'organization_id': "1410000000000",
    'deployment_id': "1234567890123",
    'name': "thread A to B",
    'description': "A さんと B さんのチャット",
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

class abeja.opsbeellm.dataset.APIClient(credential: dict | None = None, timeout: int | None = None, max_retry_count: int | None = None)

A Low-Level client for OpsBee LLM Dataset API

from abeja.opsbeellm.dataset import APIClient

api_client = APIClient()
create_dataset(organization_id: str, name: str, type: str, description: str | None = None) dict

create a dataset

API reference: POST /opsbee-llm/organizations/<organization_id>/datasets

Request Syntax:
organization_id = "1410000000000"
name = "datasetA"
description = "datasetA description"
type = "qa"
response = api_client.create_dataset(
    organization_id, name, type, description)
Params:
  • organization_id (str): organization identifier

  • name (str): dataset name

  • type (str): dataset type. available type are “qa” or “llm”.

  • description (str): [optional] dataset description

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890123",
    'organization_id': "1410000000000",
    'name': "datasetA",
    'description': "datasetA description",
    'type': "qa",
    'item_count': 0,
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

create_dataset_item(organization_id: str, dataset_id: str, inputs: list[dict], outputs: list[dict], tags: list | None = None, metadata: List[Dict] | None = None) dict

create dataset item

API reference: POST /opsbee-llm/organizations/<organization_id>/datasets/<dataset_id>/items

Request Syntax:
organization_id = "1410000000000"
dataset_id = "1234567890123"
inputs = [{"thread_name": "スレッドA"}, {"input_text": "ABEJAについて教えて"}]
outputs = [{"thread_name": "スレッドA"}, {"output_text": "ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。"}]
tags = ["OK1", "OK2"]
metadata = [{"metadata1": "value1"}, {"metadata2": "value2"}]
response = api_client.create_datatset_item(
    organization_id, dataset_id, inputs, outputs, tags, metadata)
Params:
  • organization_id (str): organization identifier

  • dataset_id (str): dataset identifier

  • item_id (str): item identifier

  • inputs (list[dict]): list of key-value input data.

  • outputs (list[dict]): list of key-value output data

  • tags (list): [optional] list of tags

  • metadata (list[dict]): [optional] list of key-value metadata

Return type:

dict

Returns:

Response Syntax:

{
    'id': '3053595942757',
    'organization_id': '1410000000000',
    'dataset_id': '1234567890123',
    'inputs': [
        {"thread_name": "スレッドA"},
        {'input_text': 'ABEJAについて教えて'},
    ],
    'outputs': [
        {"thread_name": "スレッドA"},
        {'output_text': 'ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。'},
    ],
    tags: [
        "OK1", "OK2"
    ],
    matadata: [
        { metadata1: "value1" },
        { metadata2: "value2" },
    ]
    'created_at': '2023-12-15T16:50:33+09:00',
    'updated_at': '2023-12-15T16:50:33+09:00'
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

delete_dataset(organization_id: str, dataset_id: str) dict

delete a dataset

API reference: DELETE /opsbee-llm/organizations/<organization_id>/datasets/<dataset_id>

Request Syntax:
organization_id = "1410000000000"
dataset_id = "1234567890123"
response = api_client.delete_dataset(
    organization_id, dataset_id)
Params:
  • organization_id (str): organization identifier

  • dataset_id (str): dataset identifier

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890123",
    'organization_id': "1410000000000",
    'name': "datasetA",
    'description': "datasetA description",
    'type': "qa",
    'item_count': 0,
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

delete_dataset_item(organization_id: str, dataset_id: str, item_id: str) dict

delete dataset item

API reference: DELETE /opsbee-llm/organizations/<organization_id>/datasets/<dataset_id>/items/<item_id>

Request Syntax:
organization_id = "1410000000000"
dataset_id = "1234567890123"
item_id = "3053595942757"
response = api_client.delete_datatset_item(
    organization_id, dataset_id, item_id)
Params:
  • organization_id (str): organization identifier

  • dataset_id (str): dataset identifier

  • item_id (str): item identifier

Return type:

dict

Returns:

Response Syntax:

{
    'id': '3053595942757',
    'organization_id': '1410000000000',
    'dataset_id': '1234567890123',
    'inputs': [
        {'input_text': 'ABEJAについて教えて'},
        ...
    ],
    'outputs': [
        {'output_text': 'ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。'},
        ...
    ],
    tags: [
        "OK1", "OK2", ...
    ],
    matadata: [
        { metadata1: "value1" },
        { metadata2: "value2" },
        ...
    ]
    'created_at': '2023-12-15T16:50:33+09:00',
    'updated_at': '2023-12-15T16:50:33+09:00'
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_dataset(organization_id: str, dataset_id: str) dict

get dataset

API reference: GET /opsbee-llm/organizations/<organization_id>/datasets/<dataset_id>

Request Syntax:
organization_id = "1410000000000"
dataset_id = "3053595942757"
response = api_client.get_datatset(
    organization_id, dataset_id)
Params:
  • organization_id (str): organization identifier

  • dataset_id (str): dataset identifier

Return type:

dict

Returns:

Response Syntax:

{
    'id': '3053595942757',
    'organization_id': '1410000000000',
    'name': 'datasetA',
    'description': 'datasetAの説明',
    'type': 'qa',
    'item_count': 100,
    'created_at': '2023-12-15T16:50:33+09:00',
    'updated_at': '2023-12-15T16:50:33+09:00'
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_dataset_item(organization_id: str, dataset_id: str, item_id: str) dict

get dataset item

API reference: GET /opsbee-llm/organizations/<organization_id>/datasets/<dataset_id>/items/<item_id>

Request Syntax:
organization_id = "1410000000000"
dataset_id = "1234567890123"
item_id = "3053595942757"
response = api_client.get_datatset_item(
    organization_id, dataset_id, item_id)
Params:
  • organization_id (str): organization identifier

  • dataset_id (str): dataset identifier

  • item_id (str): item identifier

Return type:

dict

Returns:

Response Syntax:

{
    'id': '3053595942757',
    'organization_id': '1410000000000',
    'dataset_id': '1234567890123',
    'inputs': [
        {'input_text': 'ABEJAについて教えて'},
        ...
    ],
    'outputs': [
        {'output_text': 'ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。'},
        ...
    ],
    tags: [
        "OK1", "OK2", ...
    ],
    matadata: [
        { metadata1: "value1" },
        { metadata2: "value2" },
        ...
    ]
    'created_at': '2023-12-04T16:01:52+09:00',
    'updated_at': '2023-12-04T16:01:52+09:00'
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_dataset_items(organization_id: str, dataset_id: str, search_query: str | None = None, offset: int | None = 0, limit: int | None = 1000) dict

get dataset items

API reference: GET /opsbee-llm/organizations/<organization_id>/datasets/<dataset_id>/items

Request Syntax:
organization_id = "1410000000000"
dataset_id = "1234567890123"
offset = 0
limit = 1000
response = api_client.get_datatset_items(
    organization_id, dataset_id, offset, limit)
Params:
  • organization_id (str): organization identifier

  • dataset_id (str): dataset identifier

  • search_query (str): [optional] search query
    • available search keys is below:
      • item_id:

      • input_keys:

      • input_values:

      • output_keys:

      • output_values:

      • tag_values:

      • metadata_keys:

      • metadata_values:

      • created_at:

      • updated_at:

    • AND and OR operators are available for each keys.

    • * operators are available for input_keys:, input_values:, output_keys:, output_values: keys.

    • <=, <, >=, > operators are available for created_at, updated_at keys.

    example:

    search_query=’input_values:”ABEJA*” AND created_at:>=”2024-09-17T00:00:00” AND metadata_keys:metadata1 AND metadata_keys:metadata2’

  • offset (int): [optional] offset of datasets ( which starts from 0 )

  • limit (int): [optional] max number of datasets to be returned

Return type:

dict

Returns:

Response Syntax:

{
    'organization_id': '1410000000000'
    'dataset_id': '1234567890123',
    'items': [
        {
            'id': '3053595942757',
            'organization_id': '1410000000000',
            'dataset_id': '1234567890123',
            'inputs': [
                {'input_text': 'ABEJAについて教えて'},
                ...
            ],
            'outputs': [
                {'output_text': 'ABEJAは、スペイン語で「ミツバチ」の意味であり、植物の受粉を手伝い、世界の食料生産を支える存在として社名になっています。'},
                ...
            ],
            tags: [
                "OK1", "OK2", ...
            ],
            matadata: [
                { metadata1: "value1" },
                { metadata2: "value2" },
                ...
            ]
            'created_at': '2023-12-15T16:50:33+09:00',
            'updated_at': '2023-12-15T16:50:33+09:00'
        },
        ...
    ],
    'offset': 0,
    'limit': 1000,
    'total': 10,
    'has_next': False,
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_datasets(organization_id: str, offset: int | None = 0, limit: int | None = 1000) dict

get datasets

API reference: GET /opsbee-llm/organizations/<organization_id>/datasets

Request Syntax:
organization_id = "1410000000000"
offset = 0
limit = 1000
response = api_client.get_datatsets(
    organization_id, offset, limit)
Params:
  • organization_id (str): organization identifier

  • offset (int): [optional] offset of datasets ( which starts from 0 )

  • limit (int): [optional] max number of datasets to be returned

Return type:

dict

Returns:

Response Syntax:

{
    'organization_id': '1410000000000'
    'datasets': [
        {
            'id': '3053595942757',
            'organization_id': '1410000000000',
            'name': 'datasetA',
            'description': 'datasetAの説明',
            'type': 'qa',
            'item_count': 100,
            'created_at': '2023-12-15T16:50:33+09:00',
            'updated_at': '2023-12-15T16:50:33+09:00'
        },
        {
            'id': '9968625354849',
            'organization_id': '1410000000000',
            'name': 'datasetB',
            'description': 'datasetBの説明',
            'type': 'llm',
            'item_count': 300,
            'created_at': '2023-12-04T16:01:52+09:00',
            'updated_at': '2023-12-04T16:01:52+09:00',
        },
        ...
    ],
    'offset': 0,
    'limit': 1000,
    'has_next': False,
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

update_dataset(organization_id: str, dataset_id: str, name: str, description: str | None = None) dict

update a dataset

API reference: PATCH /opsbee-llm/organizations/<organization_id>/datasets/<dataset_id>

Request Syntax:
organization_id = "1410000000000"
dataset_id = "1234567890123"
name = "datasetA"
description = "datasetA description"
response = api_client.update_dataset(
    organization_id, dataset_id, name, description)
Params:
  • organization_id (str): organization identifier

  • dataset_id (str): dataset identifier

  • name (str): dataset name

  • description (str): [optional] dataset description

Return type:

dict

Returns:

Response Syntax:

{
    'id': "1234567890123",
    'organization_id': "1410000000000",
    'name': "datasetA",
    'description': "datasetA description",
    'type': "qa",
    'item_count': 0,
    'created_at' : "2023-12-04T16:01:52+09:00",
    'updated_at' : "2023-12-04T16:01:52+09:00",
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError