A lightweight Python SDK for the Pythinker API.
Reason this release was yanked:
Released alongside aborted pythinker-cli line; pythinker-code is the canonical name.
Project description
Pythinker SDK
Pythinker SDK provides a convenient way to access the Pythinker API and build agent workflows in Python.
Installation
Pythinker SDK requires Python 3.12 or higher. We recommend using uv as the package manager.
uv init --python 3.12 # or higher
Then add Pythinker SDK as a dependency:
uv add pythinker-sdk
Examples
Simple chat completion
import asyncio
from pythinker_sdk import Pythinker, Message, generate
async def main() -> None:
pythinker = Pythinker(
base_url="https://api.pythinker-ai.ai/v1",
api_key="your_pythinker_api_key_here",
model="pythinker-ai",
)
history = [
Message(role="user", content="Who are you?"),
]
result = await generate(
chat_provider=pythinker,
system_prompt="You are a helpful assistant.",
tools=[],
history=history,
)
print(result.message)
print(result.usage)
asyncio.run(main())
Streaming output
import asyncio
from pythinker_sdk import Pythinker, Message, StreamedMessagePart, generate
async def main() -> None:
pythinker = Pythinker(
base_url="https://api.pythinker-ai.ai/v1",
api_key="your_pythinker_api_key_here",
model="pythinker-ai",
)
history = [
Message(role="user", content="Who are you?"),
]
def output(message_part: StreamedMessagePart) -> None:
print(message_part)
result = await generate(
chat_provider=pythinker,
system_prompt="You are a helpful assistant.",
tools=[],
history=history,
on_message_part=output,
)
print(result.message)
print(result.usage)
asyncio.run(main())
Upload video
import asyncio
from pathlib import Path
from pythinker_sdk import Pythinker, Message, TextPart, generate
async def main() -> None:
pythinker = Pythinker(
base_url="https://api.pythinker-ai.ai/v1",
api_key="your_pythinker_api_key_here",
model="pythinker-ai",
)
video_path = Path("demo.mp4")
video_part = await pythinker.files.upload_video(
data=video_path.read_bytes(),
mime_type="video/mp4",
)
history = [
Message(
role="user",
content=[
TextPart(text="Please describe this video."),
video_part,
],
),
]
result = await generate(
chat_provider=pythinker,
system_prompt="You are a helpful assistant.",
tools=[],
history=history,
)
print(result.message)
print(result.usage)
asyncio.run(main())
Tool calling with step
import asyncio
from pydantic import BaseModel
from pythinker_sdk import CallableTool2, Pythinker, Message, SimpleToolset, StepResult, ToolOk, ToolReturnValue, step
class AddToolParams(BaseModel):
a: int
b: int
class AddTool(CallableTool2[AddToolParams]):
name: str = "add"
description: str = "Add two integers."
params: type[AddToolParams] = AddToolParams
async def __call__(self, params: AddToolParams) -> ToolReturnValue:
return ToolOk(output=str(params.a + params.b))
async def main() -> None:
pythinker = Pythinker(
base_url="https://api.pythinker-ai.ai/v1",
api_key="your_pythinker_api_key_here",
model="pythinker-ai",
)
toolset = SimpleToolset()
toolset += AddTool()
history = [
Message(role="user", content="Please add 2 and 3 with the add tool."),
]
result: StepResult = await step(
chat_provider=pythinker,
system_prompt="You are a precise math tutor.",
toolset=toolset,
history=history,
)
print(result.message)
print(await result.tool_results())
asyncio.run(main())
Environment variables
PYTHINKER_API_KEY: API key for the Pythinker API.PYTHINKER_BASE_URL: Override the API base URL (defaults tohttps://api.pythinker-ai.ai/v1).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pythinker_sdk-1.0.0.tar.gz.
File metadata
- Download URL: pythinker_sdk-1.0.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6359ee4793bbf5c530f3e84e46e4e79406e192cdc0e1074dbe585c4be040adf6
|
|
| MD5 |
ff8184d081abad24180414d07de67420
|
|
| BLAKE2b-256 |
f5a4568853dfea0206c079c6acd623565751946d136695420143cc9007665740
|
Provenance
The following attestation bundles were made for pythinker_sdk-1.0.0.tar.gz:
Publisher:
release-pythinker-sdk.yml on mohamed-elkholy95/Pythinker-Code
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pythinker_sdk-1.0.0.tar.gz -
Subject digest:
6359ee4793bbf5c530f3e84e46e4e79406e192cdc0e1074dbe585c4be040adf6 - Sigstore transparency entry: 1464544353
- Sigstore integration time:
-
Permalink:
mohamed-elkholy95/Pythinker-Code@5bd0f7b786909725442d0a5910a10473a376992f -
Branch / Tag:
refs/tags/pythinker-sdk-1.0.0 - Owner: https://github.com/mohamed-elkholy95
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pythinker-sdk.yml@5bd0f7b786909725442d0a5910a10473a376992f -
Trigger Event:
push
-
Statement type:
File details
Details for the file pythinker_sdk-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pythinker_sdk-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bf83694553db80555683ab560f90594508f95fa39626d8ca75cef866009fa22
|
|
| MD5 |
663cd00475cb91359b78d48039e5ac7f
|
|
| BLAKE2b-256 |
5b4f1a27ea63da5a35b11606afc833b2c897c40d01031f15ff57707a816a2ecc
|
Provenance
The following attestation bundles were made for pythinker_sdk-1.0.0-py3-none-any.whl:
Publisher:
release-pythinker-sdk.yml on mohamed-elkholy95/Pythinker-Code
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pythinker_sdk-1.0.0-py3-none-any.whl -
Subject digest:
4bf83694553db80555683ab560f90594508f95fa39626d8ca75cef866009fa22 - Sigstore transparency entry: 1464544428
- Sigstore integration time:
-
Permalink:
mohamed-elkholy95/Pythinker-Code@5bd0f7b786909725442d0a5910a10473a376992f -
Branch / Tag:
refs/tags/pythinker-sdk-1.0.0 - Owner: https://github.com/mohamed-elkholy95
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pythinker-sdk.yml@5bd0f7b786909725442d0a5910a10473a376992f -
Trigger Event:
push
-
Statement type: