Skip to main content

The AgenOps plateform

Project description

phospho Python Client

This is a Python client for phospho.

For more information, see the docs at docs.phospho.app.

Please note the project is still under development.

Requirements

  • Python 3.8 or higher

Installation

pip install --upgrade phospho

Getting started

Grab your API key from your phospho dashboard and set it as an environment variable:

export PHOSPHO_API_KEY="your-api-key"

Setup the project ID you want to work with (you can create a new project and get its ID from your dashboard):

export PHOSPHO_PROJECT_ID="your-project-id"

Create a new client instance:

from phospho import Client

client = Client()

Manage the sessions of your project

Create a new session:

# Returns a new Session object
session = client.create_session(data=None)
"""
data: dict=None
Additional data to be stored with the session
"""

List all the sessions of your project:

# Returns a list of objects Session
sessions = client.sessions.list()

Operations on a session:

# For a session already created
# Returns a new Session object
session = client.sessions.get("session-id-here")

# Get the session id
session.id

# Get the session content
session.content

# Update the session content
# New keys will be added, existing keys will be updated
session.update(data={"your-key": "your value"})

# Make sure the ssession is up to date with the server
session.refresh()

# List all the tasks of the session
# Return a list of objects Task
tasks = session.list_tasks()

Manage the tasks of your session

Create a new task:

# Returns a new Task object
task = client.tasks.create(session_id, sender_id, input, additional_input=None, data=None)
"""
session_id: str
Id of the session the task belongs to

sender_id: str
Identifier of the sender of the task, can be null

input: str
Input of the task (sometime called "the prompt")

additional_input: dict=None
Additional input to be used with the task

data: dict=None
Additional data to be stored with the task
"""

Operations on a Task:

# For a task already created
# Returns a Task object
task = client.tasks.get("task-id-here")

# Get the task id
task.id

# Get the task content
task.content

# Refresh the task content
task.refresh()

# Update the task content
# New keys will be added, existing keys will be updated
task.update(data={"your-key": "your value"})

# List all the steps of the task
# Return a list of objects Step
steps = task.list_steps()

Manage the steps of your task

Create a new step:

# Returns a new Step object
step = client.steps.create(task_id, input, name, status, is_last, additional_input=None, data=None)
"""
task_id: str
Id of the task the step belongs to

input: str
Input of the step (sometime called "the prompt")

name: str
Name of the step

status: str
Status of the step

is_last: bool
Whether the step is the last one of the task (usually, the output of the last step is the output of the task)

additional_input: dict=None
Additional input to be used with the step

data: dict=None
Additional data to be stored with the step
"""

Operations on a Step:

# For a step already created
# Returns a Step object
step = client.steps.get("step-id-here")

# Get the step id
step.id

# Get the step content
step.content

# Refresh the step content
step.refresh()

# Update the step content
# New keys will be added, existing keys will be updated
step.update(status=None,is_last=None,output=None,additional_output=None, data=None)
"""
status: str=None
Status of the step

is_last: bool=None
Whether the step is the last one of the task (usually, the output of the last step is the output of the task)

output: str=None
Output of the step

additional_output: dict=None
Additional output of the step

data: dict=None
Additional data to be stored with the step
"""

Usage

See the documentation for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phospho-0.1.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

phospho-0.1.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file phospho-0.1.0.tar.gz.

File metadata

  • Download URL: phospho-0.1.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.8 Darwin/20.6.0

File hashes

Hashes for phospho-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a1baff8ead18006079c084b3d94876e49f0d6e88cfc18d7f12327e36f9700ea8
MD5 af2bdce993b161f4a70498f3a1c3199d
BLAKE2b-256 ddb3860050da1ea34dde2c9529e5fee15e78a39e1a32d4d7bba6762b9258aca5

See more details on using hashes here.

File details

Details for the file phospho-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: phospho-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.8 Darwin/20.6.0

File hashes

Hashes for phospho-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 244553e2db657321ecdf685a77240b114c260fd5aab3a8c36490e8bd1cc974cf
MD5 d5240010f9bf1394148a3cfdb8a8a814
BLAKE2b-256 04250ea337822fc6b391360c14abe413fa5934785653b513d598f75335219ffd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page