Select a plugin Demo#

[1]:
pip install openplugin-sdk==0.1.5
Requirement already satisfied: openplugin-sdk==0.1.5 in /opt/homebrew/Cellar/jupyterlab/4.1.3/libexec/lib/python3.12/site-packages (0.1.5)
Requirement already satisfied: httpx<0.28.0,>=0.27.0 in /opt/homebrew/Cellar/jupyterlab/4.1.3/libexec/lib/python3.12/site-packages (from openplugin-sdk==0.1.5) (0.27.0)
Requirement already satisfied: pydantic<3.0.0,>=2.6.3 in /opt/homebrew/Cellar/jupyterlab/4.1.3/libexec/lib/python3.12/site-packages (from openplugin-sdk==0.1.5) (2.6.3)
Requirement already satisfied: anyio in /opt/homebrew/Cellar/jupyterlab/4.1.3/libexec/lib/python3.12/site-packages (from httpx<0.28.0,>=0.27.0->openplugin-sdk==0.1.5) (4.3.0)
Requirement already satisfied: certifi in /opt/homebrew/opt/python-certifi/lib/python3.12/site-packages (from httpx<0.28.0,>=0.27.0->openplugin-sdk==0.1.5) (2024.2.2)
Requirement already satisfied: httpcore==1.* in /opt/homebrew/Cellar/jupyterlab/4.1.3/libexec/lib/python3.12/site-packages (from httpx<0.28.0,>=0.27.0->openplugin-sdk==0.1.5) (1.0.4)
Requirement already satisfied: idna in /opt/homebrew/Cellar/jupyterlab/4.1.3/libexec/lib/python3.12/site-packages (from httpx<0.28.0,>=0.27.0->openplugin-sdk==0.1.5) (3.6)
Requirement already satisfied: sniffio in /opt/homebrew/Cellar/jupyterlab/4.1.3/libexec/lib/python3.12/site-packages (from httpx<0.28.0,>=0.27.0->openplugin-sdk==0.1.5) (1.3.1)
Requirement already satisfied: h11<0.15,>=0.13 in /opt/homebrew/Cellar/jupyterlab/4.1.3/libexec/lib/python3.12/site-packages (from httpcore==1.*->httpx<0.28.0,>=0.27.0->openplugin-sdk==0.1.5) (0.14.0)
Requirement already satisfied: annotated-types>=0.4.0 in /opt/homebrew/Cellar/jupyterlab/4.1.3/libexec/lib/python3.12/site-packages (from pydantic<3.0.0,>=2.6.3->openplugin-sdk==0.1.5) (0.6.0)
Requirement already satisfied: pydantic-core==2.16.3 in /opt/homebrew/Cellar/jupyterlab/4.1.3/libexec/lib/python3.12/site-packages (from pydantic<3.0.0,>=2.6.3->openplugin-sdk==0.1.5) (2.16.3)
Requirement already satisfied: typing-extensions>=4.6.1 in /opt/homebrew/Cellar/jupyterlab/4.1.3/libexec/lib/python3.12/site-packages (from pydantic<3.0.0,>=2.6.3->openplugin-sdk==0.1.5) (4.10.0)
Note: you may need to restart the kernel to use updated packages.
[3]:
# setup openplugin service with remote server url
from openplugin_sdk import OpenpluginService
import os

openplugin_server_endpoint = "..."
openplugin_api_key = "..."

svc = OpenpluginService(openplugin_server_endpoint=openplugin_server_endpoint, openplugin_api_key=openplugin_api_key)
print(f"openplugin_version: {svc.remote_server_version()}, server_status={svc.ping()}")
openplugin_version: 0.1.6, server_status=success
[5]:
from openplugin_sdk import Config

openplugin_manifest_url = (
        "https://assistant-management-data.s3.amazonaws.com/Klarna_Shopping2.json"
)
prompt = "Show me some T Shirts."
openplugin_manifest_urls = [openplugin_manifest_url]
config = Config(
        openai_api_key="..."
)
response = svc.select_a_plugin(
        openplugin_manifest_urls=openplugin_manifest_urls,
        prompt=prompt,
        config=config,
)
print(response)
https://assistant-management-data.s3.amazonaws.com/Klarna_Shopping2.json
[ ]: