Working with tasks#
from pprint import pprint
from dotenv import load_dotenv
from genai.client import Client
from genai.credentials import Credentials
# make sure you have a .env file under genai root with
# GENAI_KEY=<your-genai-key>
# GENAI_API=<genai-api-endpoint>
load_dotenv()
def heading(text: str) -> str:
"""Helper function for centering text."""
return "\n" + f" {text} ".center(80, "=") + "\n"
client = Client(credentials=Credentials.from_env())
print(heading("Show all existing tasks"))
for task in client.task.list(
tune=True, # optional
).results:
pprint(task.model_dump())