Klarna Openplugin Demo#

[1]:
pip install openplugin-sdk
Requirement already satisfied: openplugin-sdk in /Users/shrikant/Misc/miniconda3/envs/openplugin/lib/python3.9/site-packages (0.1.4)
Collecting httpx<0.28.0,>=0.27.0 (from openplugin-sdk)
  Using cached httpx-0.27.0-py3-none-any.whl (75 kB)
Collecting pydantic<3.0.0,>=2.6.3 (from openplugin-sdk)
  Using cached pydantic-2.6.4-py3-none-any.whl (394 kB)
Requirement already satisfied: anyio in /Users/shrikant/Misc/miniconda3/envs/openplugin/lib/python3.9/site-packages (from httpx<0.28.0,>=0.27.0->openplugin-sdk) (3.6.2)
Requirement already satisfied: certifi in /Users/shrikant/Misc/miniconda3/envs/openplugin/lib/python3.9/site-packages (from httpx<0.28.0,>=0.27.0->openplugin-sdk) (2023.7.22)
Requirement already satisfied: httpcore==1.* in /Users/shrikant/Misc/miniconda3/envs/openplugin/lib/python3.9/site-packages (from httpx<0.28.0,>=0.27.0->openplugin-sdk) (1.0.2)
Requirement already satisfied: idna in /Users/shrikant/Misc/miniconda3/envs/openplugin/lib/python3.9/site-packages (from httpx<0.28.0,>=0.27.0->openplugin-sdk) (3.4)
Requirement already satisfied: sniffio in /Users/shrikant/Misc/miniconda3/envs/openplugin/lib/python3.9/site-packages (from httpx<0.28.0,>=0.27.0->openplugin-sdk) (1.3.0)
Requirement already satisfied: h11<0.15,>=0.13 in /Users/shrikant/Misc/miniconda3/envs/openplugin/lib/python3.9/site-packages (from httpcore==1.*->httpx<0.28.0,>=0.27.0->openplugin-sdk) (0.14.0)
Requirement already satisfied: annotated-types>=0.4.0 in /Users/shrikant/Misc/miniconda3/envs/openplugin/lib/python3.9/site-packages (from pydantic<3.0.0,>=2.6.3->openplugin-sdk) (0.6.0)
Collecting pydantic-core==2.16.3 (from pydantic<3.0.0,>=2.6.3->openplugin-sdk)
  Using cached pydantic_core-2.16.3-cp39-cp39-macosx_11_0_arm64.whl (1.8 MB)
Requirement already satisfied: typing-extensions>=4.6.1 in /Users/shrikant/Misc/miniconda3/envs/openplugin/lib/python3.9/site-packages (from pydantic<3.0.0,>=2.6.3->openplugin-sdk) (4.9.0)
Installing collected packages: pydantic-core, pydantic, httpx
  Attempting uninstall: pydantic-core
    Found existing installation: pydantic_core 2.16.2
    Uninstalling pydantic_core-2.16.2:
      Successfully uninstalled pydantic_core-2.16.2
  Attempting uninstall: pydantic
    Found existing installation: pydantic 2.6.1
    Uninstalling pydantic-2.6.1:
      Successfully uninstalled pydantic-2.6.1
  Attempting uninstall: httpx
    Found existing installation: httpx 0.26.0
    Uninstalling httpx-0.26.0:
      Successfully uninstalled httpx-0.26.0
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
openplugin 0.0.31 requires fastapi<0.96.0,>=0.95.2, but you have fastapi 0.109.2 which is incompatible.
openplugin 0.0.31 requires langchain<0.0.179,>=0.0.178, but you have langchain 0.1.7 which is incompatible.
openplugin 0.0.31 requires pydantic==1.10.14, but you have pydantic 2.6.4 which is incompatible.
Successfully installed httpx-0.27.0 pydantic-2.6.4 pydantic-core-2.16.3
Note: you may need to restart the kernel to use updated packages.
[2]:
# 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.4, server_status=success
[5]:
openplugin_manifest_url = "https://raw.githubusercontent.com/ImpromptAI/openplugin-manifests/main/vendor-owned/unofficial/klarna/manifest.json"
prompt = "Show me some T Shirts."
output_module_name = "summary_response"

response = svc.run(
        openplugin_manifest_url=openplugin_manifest_url,
        prompt=prompt,
        output_module_names=[output_module_name],
)
print(response.value)
The response includes a list of clothing products with details such as name, price, URL, and attributes. Some of the products mentioned are Lacoste Men's T-shirts 3-pack in black, MANGDIUP Women's scoop neck T-shirts in white, Nike Shortsleeve Crewneck T-shirts 2-pack in black, Moschino T-shirts and Polos in black, and Diesel T-shirt con logo peekaboo in black. The products vary in price, materials, colors, sizes, and target groups. The prices range from $1.49 to $143.00, catering to both men and women. Each product has a unique URL for purchase.
[ ]: