Skip to main content

A modern Python client library for OpenCode server

Project description

OpenCode Python Client

Python Pydantic License

Python 客户端库,用于与 OpenCode 服务器交互。

安装

uv add my-opencode-cli
# 或
pip install my-opencode-cli

快速开始

import asyncio
from my_opencode_cli import AsyncOpenCode

async def main():
    async with AsyncOpenCode(start_server=True) as client:
        # 快速提问
        answer = await client.ask("什么是 Python 装饰器?")
        print(answer)

        # 流式输出
        async for event in client.ask_stream("写一个快速排序"):
            if event.type == "message.part.updated":
                text = event.properties.part.text
                if text:
                    print(text, end="")

asyncio.run(main())

同步客户端:

from my_opencode_cli import OpenCode

with OpenCode(start_server=True) as client:
    print(client.ask("什么是闭包?"))

文档

详细文档请参阅 docs/guide/

开发

git clone https://github.com/iibyteCoder/my-opencode-cli.git
cd my-opencode-cli
uv sync --all-extras

# 测试
uv run pytest

# 类型检查
uv run mypy src/opencode_client --strict

许可证

MIT License

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

my_opencode_cli-0.2.1.tar.gz (184.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

my_opencode_cli-0.2.1-py3-none-any.whl (41.9 kB view details)

Uploaded Python 3

File details

Details for the file my_opencode_cli-0.2.1.tar.gz.

File metadata

  • Download URL: my_opencode_cli-0.2.1.tar.gz
  • Upload date:
  • Size: 184.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for my_opencode_cli-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ae0b2a2ad5d304bfbc13b554138a49ba282464964655669972b4d307a9bc4d28
MD5 8f77b1c06b0d9e71d27a9d9ec425c91f
BLAKE2b-256 3bee6538ff24df36cf4efe9a1a11b45f56b2941c96577770f1e1d053ed657735

See more details on using hashes here.

File details

Details for the file my_opencode_cli-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: my_opencode_cli-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 41.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for my_opencode_cli-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a3da2022d725ef900b7584204e209f6a1f942ccfda4017b8623c34d9cb758a4f
MD5 e7137cd48c42f057612ed85a11f5e437
BLAKE2b-256 2770332ace82d59e335b057820b2d6fc4c5813e445a84861323dc45a67981c65

See more details on using hashes here.

Supported by

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