update sphinx generator

This commit is contained in:
jinli.yl 2024-07-17 18:18:00 +08:00
commit 7b48d8e620
27 changed files with 469 additions and 12 deletions

8
.gitignore vendored
View file

@ -141,6 +141,10 @@ docs/sphinx_doc/build/
# Used to save loggings and files
*runs/
agentscope.db
memoryscope.db
tmp*.json
cradle*
cradle*
# sphinx docs
memory_scope*.rst

14
LICENSE
View file

@ -213,7 +213,7 @@ also licensed under the terms of the Apache 2.0.
--------------------------------------------------------------------------------
Code in src/agentscope/web/static/js/socket.io.js is adapted from
Code in src/memoryscope/web/static/js/socket.io.js is adapted from
https://cdnjs.cloudflare.com/ajax/libs/socket.io/3.1.3/socket.io.js (MIT License)
Copyright (c) 2014-2021 Guillermo Rauch
@ -238,7 +238,7 @@ SOFTWARE.
--------------------------------------------------------------------------------
Code in src/agentscope/web/static/js/jquery-3.3.1.min.js is adapted from
Code in src/memoryscope/web/static/js/jquery-3.3.1.min.js is adapted from
https://code.jquery.com/jquery-3.3.1.min.js (MIT License)
Copyright (c) JS Foundation and other contributors
@ -263,7 +263,7 @@ SOFTWARE.
--------------------------------------------------------------------------------
Code in src/agentscope/web/static/js/bootstrap.bundle.min.js is adapted from
Code in src/memoryscope/web/static/js/bootstrap.bundle.min.js is adapted from
https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.bundle.min.js
(MIT License)
@ -290,7 +290,7 @@ SOFTWARE.
--------------------------------------------------------------------------------
Code in src/agentscope/web/static/js/bootstrap-table.min.js is adapted from
Code in src/memoryscope/web/static/js/bootstrap-table.min.js is adapted from
https://unpkg.com/bootstrap-table@1.18.0/dist/bootstrap-table.min.js (MIT
License)
@ -316,7 +316,7 @@ SOFTWARE.
--------------------------------------------------------------------------------
Code in src/agentscope/web/static/css/bootstrap.min.css is adapted from
Code in src/memoryscope/web/static/css/bootstrap.min.css is adapted from
https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css (MIT
License)
@ -344,7 +344,7 @@ SOFTWARE.
--------------------------------------------------------------------------------
Fonts in src/agentscope/web/static/fonts/KRYPTON.ttf is adapted from
Fonts in src/memoryscope/web/static/fonts/KRYPTON.ttf is adapted from
https://github.com/githubnext/monaspace (SIL Open Font License 1.1). These
fonts are distributed with their original license. See https://github
.com/githubnext/monaspace/blob/main/LICENSE for the full text of the license.
@ -369,7 +369,7 @@ OTHER DEALINGS IN THE FONT SOFTWARE.
--------------------------------------------------------------------------------
Fonts in src/agentscope/web/static/fonts/OSWALD.ttf is adapted from
Fonts in src/memoryscope/web/static/fonts/OSWALD.ttf is adapted from
https://fonts.google.com/specimen/Oswald (SIL Open Font License 1.1). These
fonts are distributed with their original license. See https://github
.com/googlefonts/OswaldFont/blob/main/OFL.txt for the full text of the license.

View file

@ -4,8 +4,6 @@
Please use the following commands to build sphinx doc of MemoryScope.
参考https://github.com/modelscope/agentscope/blob/main/docs/README.md
```shell
# step 1: Install dependencies
pip install sphinx sphinx-autobuild sphinx_rtd_theme myst-parser sphinxcontrib-mermaid
@ -17,4 +15,5 @@ cd sphinx_doc
./build_sphinx_doc.sh
# step 4: view sphinx_doc/build/html/index.html using your browser
```
cd docs/sphinx_doc/build/html && python -m http.server 8899
```

32
docs/sphinx_doc/Makefile Normal file
View file

@ -0,0 +1,32 @@
# Makefile
SPHINXBUILD = sphinx-build
SPHINXPROJ = MemoryScope-Doc
ASSETSDIR = assets
BUILDDIR = build/html
SOURCEDIR_EN = en/source
BUILDDIR_EN = build/html/en
SOURCEDIR_ZH = zh_CN/source
BUILDDIR_ZH = build/html/zh_CN
# English document
en:
@$(SPHINXBUILD) -b html "$(SOURCEDIR_EN)" "$(BUILDDIR_EN)"
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR_EN)"
# Chinese document
zh_CN:
@$(SPHINXBUILD) -b html "$(SOURCEDIR_ZH)" "$(BUILDDIR_ZH)"
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR_ZH)"
index:
@cp "$(ASSETSDIR)/redirect.html" "$(BUILDDIR)/index.html"
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR_EN)" "$(BUILDDIR_EN)" $(O)
all: en zh_CN index
.PHONY: all en zh_CN index

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="refresh" content="0; url=en/index.html" />
<title>MemoryScope Documentation</title>
</head>
<body>
<p>Redirecting to English documentation...</p>
<p>If you are not redirected, <a href="en/index.html">click here</a>.</p>
</body>
</html>

View file

@ -0,0 +1,9 @@
#!/bin/bash
rm -rf build/html/*
rm en/source/agentscope*.rst
rm zh_CN/source/agentscope*.rst
rm en/source/memory_scope*.rst
rm zh_CN/source/memory_scope*.rst
sphinx-apidoc -f -o en/source ../../memory_scope -t template -e
sphinx-apidoc -f -o zh_CN/source ../../memory_scope -t template -e
make clean all

View file

@ -0,0 +1,4 @@
.language-selector a {
color: white;
width: 20px;
}

View file

@ -0,0 +1,5 @@
<!-- language_selector.html -->
<div class="language-selector">
<a href="{{ pathto('../en/' + pagename) }}">English</a></li> |
<a href="{{ pathto('../zh_CN/' + pagename) }}">中文</a></li>
</div>

View file

@ -0,0 +1,3 @@
<!-- layout.html -->
{% extends "!layout.html" %} {% block sidebartitle %} {{ super() }} {% include
"language_selector.html" %} {% endblock %}

View file

@ -0,0 +1,93 @@
# -*- coding: utf-8 -*-
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath("/home/hmp/memoryscope"))
# -- Project information -----------------------------------------------------
language = "en"
project = "MemoryScope"
copyright = "2024, Alibaba Tongyi Lab"
author = "EcoML team of Alibaba Tongyi Lab"
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"sphinxcontrib.mermaid",
"myst_parser",
"sphinx.ext.autosectionlabel",
]
# Prefix document path to section labels, otherwise autogenerated labels would
# look like 'heading' rather than 'path/to/file:heading'
autosectionlabel_prefix_document = True
autosummary_generate = True
autosummary_ignore_module_all = False
autodoc_member_order = "bysource"
autodoc_default_options = {
"members": True,
"special-members": "__init__",
}
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
autodoc_default_options = {
"members": True,
"special-members": "__init__",
}
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_theme_options = {
"navigation_depth": 2,
}
source_suffix = {
".rst": "restructuredtext",
".md": "markdown",
}
html_css_files = [
"custom.css",
]

View file

@ -0,0 +1,26 @@
.. MemoryScope documentation master file, created by
sphinx-quickstart on Fri Jan 5 17:53:54 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
:github_url: https://github.com/modelscope/memoryscope
MemoryScope Documentation
======================================
.. toctree::
:maxdepth: 1
:glob:
:caption: MemoryScope API Reference
memory_scope
memory_scope.chat
memory_scope.constants
memory_scope.enumeration
memory_scope.memory
memory_scope.models
memory_scope.scheme
memory_scope.storage
memory_scope.utils

View file

@ -0,0 +1,7 @@
memory_scope
============
.. toctree::
:maxdepth: 4
memory_scope

View file

@ -0,0 +1,8 @@
Get Involved
===============
.. toctree::
:maxdepth: 2
301-community.md
302-contribute.md

View file

@ -0,0 +1,34 @@
# Welcome to MemoryScope Tutorial
MemoryScope is an innovative multi-agent platform designed to empower developers to build multi-agent applications with ease, reliability, and high performance. It features three high-level capabilities:
- **Easy-to-Use**: Programming in pure Python with various prebuilt components for immediate use, suitable for developers or users with different levels of customization requirements.
- **High Robustness**: Supporting customized fault-tolerance controls and retry mechanisms to enhance application stability.
- **Actor-Based Distribution**: Enabling developers to build distributed multi-agent applications in a centralized programming manner for streamlined development.
## Tutorial Navigator
- [About MemoryScope](101-memoryscope.md)
- [Installation](102-installation.md)
- [Quick Start](103-example.md)
- [Model](203-model.md)
- [Prompt Engineering](206-prompt.md)
- [Agent](201-agent.md)
- [Memory](205-memory.md)
- [Response Parser](203-parser.md)
- [System Prompt Optimization](209-prompt_opt.md)
- [Tool](204-service.md)
- [Pipeline and MsgHub](202-pipeline.md)
- [Distribution](208-distribute.md)
- [MemoryScope Studio](209-gui.md)
- [Retrieval Augmented Generation (RAG)](210-rag.md)
- [Logging](105-logging.md)
- [Monitor](207-monitor.md)
- [Example: Werewolf Game](104-usecase.md)
### Getting Involved
- [Joining MemoryScope Community](301-community.md)
- [Contribute to MemoryScope](302-contribute.md)

View file

@ -0,0 +1,11 @@
loguru
tiktoken
pillow
requests
openai
numpy
sphinx
sphinx-autobuild
sphinx_rtd_theme
sphinxcontrib-mermaid
myst-parser

View file

@ -0,0 +1,5 @@
{{ basename | heading }}
.. automodule:: {{ qualname }}
{%- for option in automodule_options %}
:{{ option }}:
{%- endfor %}

View file

@ -0,0 +1,10 @@
{%- macro automodule(modname, options) -%}
.. automodule:: {{ modname }}
{%- for option in options %}
:{{ option }}:
{%- endfor %}
{%- endmacro %}
{{- pkgname | heading }}
{{ automodule(pkgname, automodule_options) }}

View file

@ -0,0 +1,4 @@
.language-selector a {
color: white;
width: 20px;
}

View file

@ -0,0 +1,5 @@
<!-- language_selector.html -->
<div class="language-selector">
<a href="{{ pathto('../en/' + pagename) }}">English</a></li> |
<a href="{{ pathto('../zh_CN/' + pagename) }}">中文</a></li>
</div>

View file

@ -0,0 +1,3 @@
<!-- layout.html -->
{% extends "!layout.html" %} {% block sidebartitle %} {{ super() }} {% include
"language_selector.html" %} {% endblock %}

View file

@ -0,0 +1,93 @@
# -*- coding: utf-8 -*-
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath("/home/hmp/memoryscope"))
# -- Project information -----------------------------------------------------
language = "zh_CN"
project = "MemoryScope"
copyright = "2024, Alibaba Tongyi Lab"
author = "EcoML team of Alibaba Tongyi Lab"
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"sphinxcontrib.mermaid",
"myst_parser",
"sphinx.ext.autosectionlabel",
]
# Prefix document path to section labels, otherwise autogenerated labels would
# look like 'heading' rather than 'path/to/file:heading'
autosectionlabel_prefix_document = True
autosummary_generate = True
autosummary_ignore_module_all = False
autodoc_member_order = "bysource"
autodoc_default_options = {
"members": True,
"special-members": "__init__",
}
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
autodoc_default_options = {
"members": True,
"special-members": "__init__",
}
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_theme_options = {
"navigation_depth": 4,
}
source_suffix = {
".rst": "restructuredtext",
".md": "markdown",
}
html_css_files = [
"custom.css",
]

View file

@ -0,0 +1,26 @@
.. MemoryScope documentation master file, created by
sphinx-quickstart on Fri Jan 5 17:53:54 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
:github_url: https://github.com/modelscope/memoryscope
MemoryScope 文档
======================================
.. toctree::
:maxdepth: 1
:glob:
:caption: MemoryScope API 文档
memory_scope
memory_scope.agent
memory_scope.chat
memory_scope.constants
memory_scope.enumeration
memory_scope.memory
memory_scope.models
memory_scope.scheme
memory_scope.storage
memory_scope.utils

View file

@ -0,0 +1,7 @@
memory_scope
============
.. toctree::
:maxdepth: 4
memory_scope

View file

@ -0,0 +1,8 @@
参与贡献
===============
.. toctree::
:maxdepth: 2
301-community.md
302-contribute.md

View file

@ -0,0 +1,34 @@
# 欢迎来到 MemoryScope 教程
AgentScope是一款全新的Multi-Agent框架专为应用开发者打造旨在提供高易用、高可靠的编程体验
- **高易用**AgentScope支持纯Python编程提供多种语法工具实现灵活的应用流程编排内置丰富的API服务Service以及应用样例供开发者直接使用。
- **高鲁棒**确保开发便捷性和编程效率的同时针对不同能力的大模型AgentScope提供了全面的重试机制、定制化的容错控制和面向Agent的异常处理以确保应用的稳定、高效运行
- **基于Actor的分布式机制**AgentScope设计了一种新的基于Actor的分布式机制实现了复杂分布式工作流的集中式编程和自动并行优化即用户可以使用中心化编程的方式完成分布式应用的流程编排同时能够零代价将本地应用迁移到分布式的运行环境中。
## 教程大纲
- [关于AgentScope](101-memoryscope.md)
- [安装](102-installation.md)
- [快速开始](103-example.md)
- [模型](203-model.md)
- [提示工程](206-prompt.md)
- [Agent](201-agent.md)
- [记忆](205-memory.md)
- [结果解析](203-parser.md)
- [系统提示优化](209-prompt_opt.md)
- [工具](204-service.md)
- [Pipeline和MsgHub](202-pipeline.md)
- [分布式](208-distribute.md)
- [MemoryScope Studio](209-gui.md)
- [检索增强生成RAG](210-rag.md)
- [日志](105-logging.md)
- [监控器](207-monitor.md)
- [样例:狼人杀游戏](104-usecase.md)
### 参与贡献
- [加入AgentScope社区](301-community.md)
- [贡献到AgentScope](302-contribute.md)

View file

@ -0,0 +1 @@
""" Chat."""

View file

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
""" Import modules in utils package."""
from .datetime_handler import DatetimeHandler
from .global_context import GlobalContext
from .logger import Logger
from .memory_handler import MemoryHandler
__all__ = [
"DatetimeHandler",
"GlobalContext",
"Logger",
"MemoryHandler",
]