Skip to main content

DeepAnything is a project that provides DeepSeek R1's deep thinking capabilities for various large language models (LLMs).

Project description

DeepAnything

Python Version License 中文版

DeepAnything is a project that provides DeepSeek R1's deep thinking capabilities for various large language models (LLMs).

Key Features

  • Provides an interface similar to OpenAI
  • Supports using various models compatible with the OpenAI API as response models and thinking models
  • Offers a server that provides a simple configuration to obtain an API interface compatible with the OpenAI API, and can be called using the official OpenAI SDK.
  • Supports using QWQ-32b as a thinking model

Installation Guide

Install via pip:

pip install deepanything

Quick Start

1. Integrate into Code

Chat Completion

from deepanything.ReasonClient import DeepseekReasonClient
from deepanything.ResponseClient import OpenaiResponseClient
from deepanything.DeepAnythingClient import DeepAnythingClient

think_client = DeepseekReasonClient(
    base_url="https://api.siliconflow.cn/v1",
    api_key="sk-xxxxxxxxx"
)

response_client = OpenaiResponseClient(
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
    api_key="sk-xxxxxxxxxx",
)

da_client = DeepAnythingClient(
    reason_client=think_client,
    response_client=response_client,
    reason_prompt="<Think>{}</Think>"
)

completions = da_client.chat_completion(
    messages=[
        {
            "role": "user",
            "content": "你好"
        }
    ],
    reason_model="Pro/deepseek-ai/DeepSeek-R1",
    response_model="qwen-max-latest",
    show_model="R1-qwen-max"
)

Streaming Call

stream = da_client.chat_completion(
    messages=[
        {
            "role": "user",
            "content": "你好"
        }
    ],
    reason_model="Pro/deepseek-ai/DeepSeek-R1",
    response_model="qwen-max-latest",
    show_model="R1-qwen-max",
    stream=True
)

for chunk in stream:
    print(chunk)

Asynchronous Usage

from deepanything.ReasonClient import AsyncDeepseekReasonClient
from deepanything.ResponseClient import AsyncOpenaiResponseClient
from deepanything.DeepAnythingClient import AsyncDeepAnythingClient
import asyncio

think_client = AsyncDeepseekReasonClient(
    base_url="https://api.siliconflow.cn/v1",
    api_key="sk-xxxxxxxxx"
)

response_client = AsyncOpenaiResponseClient(
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
    api_key="sk-xxxxxxxxxx",
)

da_client = AsyncDeepAnythingClient(
    reason_client=think_client,
    response_client=response_client,
    reason_prompt="<Think>{}</Think>"
)

async def main():
    completions = await da_client.chat_completion(
        messages=[
            {
                "role": "user",
                "content": "你好"
            }
        ],
        reason_model="Pro/deepseek-ai/DeepSeek-R1",
        response_model="qwen-max-latest",
        show_model="R1-qwen-max"
    )
    print(completions)

asyncio.run(main())

More example can be find in examples.

2. Use as a Server

 python -m deepanything --host host --port port --config config.json
Parameter Description
--host Server listening address, will override the setting in config.json
--port Server listening port, will override the setting in config.json
--config Configuration file path

Configuration File Format

Below is an example of a configuration file:

// Using R1 with Qwen-Max-Latest
{
  "host" : "0.0.0.0",
  "port" : 8080,
  "reason_clients": [
    {
      "name" : "siliconflow",
      "type" : "deepseek",
      "base_url" : "https://api.siliconflow.cn/v1",
      "api_key" : "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    }
  ],
  "response_clients": [
    {
      "name" : "qwen",
      "type" : "openai",
      "base_url" : "https://dashscope.aliyuncs.com/compatible-mode/v1",
      "api_key" : "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    }
  ],
  "models": [
    {
      "name": "R1-Qwen-max",
      "reason_client" : "siliconflow",
      "response_client" : "qwen",
      "reason_model": "Pro/deepseek-ai/DeepSeek-R1",
      "response_model" :  "qwen-max-latest"
    }
  ],
  "api_keys" : [
    "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  ],
  "log": {
    "version": 1,
    "disable_existing_loggers": false,
    "formatters": {
        "default": {
            "()": "uvicorn.logging.DefaultFormatter",
            "fmt": "%(levelprefix)s %(message)s",
            "use_colors": null
        },
        "access": {
            "()": "uvicorn.logging.AccessFormatter",
            "fmt": "%(levelprefix)s %(client_addr)s - \"%(request_line)s\" %(status_code)s"
        }
    },
    "handlers": {
        "default": {
            "formatter": "default",
            "class": "logging.StreamHandler",
            "stream": "ext://sys.stderr"
        },
        "access": {
            "formatter": "access",
            "class": "logging.StreamHandler",
            "stream": "ext://sys.stdout"
        }
    },
    "loggers": {
        "uvicorn": {"handlers": ["default"], "level": "INFO", "propagate": false},
        "uvicorn.error": {"level": "INFO"},
        "uvicorn.access": {"handlers": ["access"], "level": "INFO", "propagate": false}
    }
  }
}

Detailed Explanation

  • reason_clients: Configuration for thinking models, currently supports deepseek and openai types. When the type is openai, deepanything directly uses the model's output as the thinking content, and it is recommended to use qwq-32b in this case.
  • response_clients: Configuration for response models, currently only supports the openai type.
  • api_keys: API keys for user authentication. When left blank or an empty list, the server does not use API keys for authentication.
  • log: Log configuration. If this item is not filled in, the default logging configuration of uvicorn will be used. For details, please refer to uvicorn logging configuration.

Deploying with Docker

1. Pull the Image

docker pull junity233/deepanything:latest

2. Create config.json

First, create a folder in your desired directory, and then create a file named config.json inside it. This folder will be mounted into the container:

mkdir deepanything-data               # You can replace this with another name
vim deepanything-data/config.json     # Edit the configuration file, you can refer to examples/config.json

3. Run the Container

# Remember to modify the port mapping
docker run -v ./deepanything-data:/data -p 8080:8080 junity233/deepanything:latest

License

This project is licensed under the MIT License

Contact Us

Email: 1737636624@qq.com

GitHub Issues: https://github.com/junity233/deep-anything/issues

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

deepanything-0.1.7.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

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

deepanything-0.1.7-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file deepanything-0.1.7.tar.gz.

File metadata

  • Download URL: deepanything-0.1.7.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for deepanything-0.1.7.tar.gz
Algorithm Hash digest
SHA256 4ba534215d649e95b96f56e11c070c8b7282be187352c2b631d55771b3eb6b17
MD5 3fbd6a7e3cd6034d07250ca1f8046f12
BLAKE2b-256 53004110c9f1754cd7f8a5382e5dfcf7e7716894c2bff3b3085a554557810fd1

See more details on using hashes here.

File details

Details for the file deepanything-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: deepanything-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for deepanything-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f3c0294f2c92df011e61943916a546086ee3fe9d8c6352e524282a1097a64d39
MD5 b1c75104c6664f91fc4195904d151aa9
BLAKE2b-256 7341696d0d6f65df934a91aead2656b40921a0839c9a0c6298eba3a4586e1bc7

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