Skip to main content

一个轻量AI Agent框架,基于DeepSeek API

Project description

Oak DeepSeek

一个轻量的 AI Agent 框架,基于 DeepSeek API 构建。通过队列通信和多线程设计,快速构建支持工具调用、子 Agent 协作的智能体。

安装

pip install oak-deepseek

快速开始

下面是一个完整示例,展示如何创建两个 Agent(主 Agent 和子 Agent)并让它们协作计算数学表达式。

from queue import Queue
from threading import Thread
import os

from oak_deepseek.engine import AgentEngine

def add(a: int, b: int) -> str:
    """
    这个函数用于两个整数相加,并返回str结果给你
    :return: 加法结果
    """
    return f"{a + b}"

def mul(a: int, b: int) -> str:
    """
    这个函数用于两个整数相乘,并返回str结果给你
    :return: 乘法结果
    """
    return f"{a * b}"

engine: AgentEngine = AgentEngine()
engine.create_agent(
    key=("sys","sys"),
    description="一个能进行数学计算的agent",
    prompt="你是一个严谨细致的数学计算助手,任何计算仅使用工具完成",
    tools=[add],
    sub_agents=[("sys","sub")]
)

engine.create_agent(
    key=("sys","sub"),
    description="能进行乘法计算",
    prompt="你是一个严谨细致的数学计算助手,任何计算仅使用工具完成",
    loop="ReAct",
    tools=[mul]
)
history_queue = Queue()

task_queue = Queue()
task_queue.put("计算(679+678)*(2+78)")

def go():
    engine.run(task_queue, key=("sys", "sys"), history_queue=history_queue, api_key=os.getenv("DEEPSEEK_API_KEY"))

def messages():
    while True:
        msg = history_queue.get(block=True)
        if msg is None:
            return
        print(f"{msg},")


if __name__ == "__main__":
    agent_thread = Thread(target=go)
    agent_thread.start()

    print_thread = Thread(target=messages)
    print_thread.start()

    agent_thread.join()
    history_queue.put(None)
    print_thread.join()

更多示例请参考test文件夹

许可证

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

oak_deepseek-0.2.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

oak_deepseek-0.2.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file oak_deepseek-0.2.0.tar.gz.

File metadata

  • Download URL: oak_deepseek-0.2.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for oak_deepseek-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0ccf27828ce6667410c45905ac0f2ed7bd427a91ea76b3ebf271e7512462ef10
MD5 8a76f52f2746c6a6d3c98cd8f2aa55cb
BLAKE2b-256 8e7e9f8fbedd304c30b123d781ea690d691acf4873c4069bafa2b65a4da40390

See more details on using hashes here.

Provenance

The following attestation bundles were made for oak_deepseek-0.2.0.tar.gz:

Publisher: publish-to-pypi.yml on WyxGenius/oak-deepseek

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oak_deepseek-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: oak_deepseek-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for oak_deepseek-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f39170e7572bd72a1649eb753d81004c1670155ae8b7f62e31b2ace76055b1ea
MD5 b557c1ba05c8f6ff68063f02cf045f9c
BLAKE2b-256 3263bf6ebc2be2699d21fb41b4f2008caec32d8c670b368ff6b3feb3f4f988e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for oak_deepseek-0.2.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on WyxGenius/oak-deepseek

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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