chore: migrate project into clean repository

This commit is contained in:
yuuux
2026-08-13 16:50:52 +08:00
commit d1d25a09e7
27405 changed files with 9422808 additions and 0 deletions

View File

@@ -0,0 +1,176 @@
"""
External content
################
Copyright (c) 2021 Nordic Semiconductor ASA
SPDX-License-Identifier: Apache-2.0
Introduction
============
This extension allows to import sources from directories out of the Sphinx
source directory. They are copied to the source directory before starting the
build. Note that the copy is *smart*, that is, only updated files are actually
copied. Therefore, incremental builds detect changes correctly and behave as
expected.
Paths for external content included via e.g. figure, literalinclude, etc.
are adjusted as needed.
Configuration options
=====================
- ``external_content_contents``: A list of external contents. Each entry is
a tuple with two fields: the external base directory and a file glob pattern.
- ``external_content_directives``: A list of directives that should be analyzed
and their paths adjusted if necessary. Defaults to ``DEFAULT_DIRECTIVES``.
- ``external_content_keep``: A list of file globs (relative to the destination
directory) that should be kept even if they do not exist in the source
directory. This option can be useful for auto-generated files in the
destination directory.
"""
import filecmp
import os
from pathlib import Path
import re
import shutil
import tempfile
from typing import Dict, Any, List, Optional
from sphinx.application import Sphinx
__version__ = "0.1.0"
DEFAULT_DIRECTIVES = ("figure", "image", "include", "literalinclude")
"""Default directives for included content."""
def adjust_includes(
fname: Path,
basepath: Path,
directives: List[str],
encoding: str,
dstpath: Optional[Path] = None,
) -> None:
"""Adjust included content paths.
Args:
fname: File to be processed.
basepath: Base path to be used to resolve content location.
directives: Directives to be parsed and adjusted.
encoding: Sources encoding.
dstpath: Destination path for fname if its path is not the actual destination.
"""
if fname.suffix != ".rst":
return
dstpath = dstpath or fname.parent
def _adjust(m):
directive, fpath = m.groups()
# ignore absolute paths
if fpath.startswith("/"):
fpath_adj = fpath
else:
fpath_adj = Path(os.path.relpath(basepath / fpath, dstpath)).as_posix()
return f".. {directive}:: {fpath_adj}"
with open(fname, "r+", encoding=encoding) as f:
content = f.read()
content_adj, modified = re.subn(
r"\.\. (" + "|".join(directives) + r")::\s*([^`\n]+)", _adjust, content
)
if modified:
f.seek(0)
f.write(content_adj)
f.truncate()
def sync_contents(app: Sphinx) -> None:
"""Synchronize external contents.
Args:
app: Sphinx application instance.
"""
srcdir = Path(app.srcdir).resolve()
to_copy = []
to_delete = set(f for f in srcdir.glob("**/*") if not f.is_dir())
to_keep = set(
f
for k in app.config.external_content_keep
for f in srcdir.glob(k)
if not f.is_dir()
)
for content in app.config.external_content_contents:
prefix_src, glob = content
for src in prefix_src.glob(glob):
if src.is_dir():
to_copy.extend(
[(f, prefix_src) for f in src.glob("**/*") if not f.is_dir()]
)
else:
to_copy.append((src, prefix_src))
for entry in to_copy:
src, prefix_src = entry
dst = (srcdir / src.relative_to(prefix_src)).resolve()
if dst in to_delete:
to_delete.remove(dst)
if not dst.parent.exists():
dst.parent.mkdir(parents=True)
# just copy if it does not exist
if not dst.exists():
shutil.copy(src, dst)
adjust_includes(
dst,
src.parent,
app.config.external_content_directives,
app.config.source_encoding,
)
# if origin file is modified only copy if different
elif src.stat().st_mtime > dst.stat().st_mtime:
with tempfile.TemporaryDirectory() as td:
# adjust origin includes before comparing
src_adjusted = Path(td) / src.name
shutil.copy(src, src_adjusted)
adjust_includes(
src_adjusted,
src.parent,
app.config.external_content_directives,
app.config.source_encoding,
dstpath=dst.parent,
)
if not filecmp.cmp(src_adjusted, dst):
dst.unlink()
shutil.move(os.fspath(src_adjusted), os.fspath(dst))
# remove any previously copied file not present in the origin folder,
# excepting those marked to be kept.
# for file in to_delete - to_keep:
# file.unlink()
def setup(app: Sphinx) -> Dict[str, Any]:
app.add_config_value("external_content_contents", [], "env")
app.add_config_value("external_content_directives", DEFAULT_DIRECTIVES, "env")
app.add_config_value("external_content_keep", [], "")
app.connect("builder-inited", sync_contents)
return {
"version": __version__,
"parallel_read_safe": True,
"parallel_write_safe": True,
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

View File

@@ -0,0 +1,14 @@
.. _api :
===============================
接口说明
===============================
.. toctree::
:maxdepth: 1
:caption: 目录
:glob:
conns/*
session/*
stream_text/*

View File

@@ -0,0 +1,64 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
import sys
import os
from pathlib import Path
LSCHAT_BASE = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(LSCHAT_BASE / "docs" / "source" / "_extensions"))
project = 'lschat'
copyright = '2024, ListenAI'
author = 'ListenAI'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
"breathe",
"sphinx_rtd_theme",
'sphinx_tabs.tabs',
'external_content',
]
templates_path = ['_templates']
exclude_patterns = []
breathe_projects = {
"lschat": "doxygen/xml",
}
breathe_default_project = "lschat"
breathe_domain_by_extension = {
"h": "c",
"c": "c",
}
breathe_show_enumvalue_initializer = True
breathe_default_members = ("members", )
language = 'zh_CN'
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_logo = "_static/img/logo.svg"
html_theme_options = {
"logo_only": False,
"prev_next_buttons_location": None
}
html_domain_indices = False
html_split_index = True
html_show_sourcelink = False
html_show_sphinx = False
html_theme = "sphinx_rtd_theme"
html_static_path = ['_static']
external_content_contents = [
(LSCHAT_BASE / "doc", "[!_]*"),
(LSCHAT_BASE, "samples/**/*.rst"),
]

View File

@@ -0,0 +1,13 @@
.. _lsc_connect:
=======================================
平台连接
=======================================
说明
****************************************
调用大模型平台服务时,需先建立连接并鉴权。
接口介绍
****************************************
.. doxygengroup:: lsc_connect

View File

@@ -0,0 +1,90 @@
========
快速开始
========
lschat支持在linux平台和zephyr-rtos(当前仅支持CSK6多模态开发板)下编译运行
环境搭建
--------
.. tabs::
.. group-tab:: Ubuntu
.. code-block:: bash
apt-get install cmake git
pip install kconfiglib
.. group-tab:: Zephyr
zephyr环境搭建见: `zephyr_v3.4.0 <https://docs.zephyrproject.org/3.4.0/>`_
代码拉取
--------
.. tabs::
.. group-tab:: Ubuntu
.. code-block:: bash
git clone https://cloud.listenai.com/CSKG962172/ls_chat.git
git submodule update --init --recursive
.. group-tab:: Zephyr
.. code-block:: bash
west init -m https://cloud.listenai.com/CSKG962172/ls_chat.git
west update
编译示例
--------
.. tabs::
.. group-tab:: Ubuntu
.. code-block:: bash
cmake -B build -DDEFCONF_FILE=prj-linux.conf -S samples/lsc_connect
cmake --build build
.. group-tab:: Zephyr
.. code-block:: bash
west build -p -b csk6_duomotai_devkit samples/lsc_connect
运行示例
--------
.. tabs::
.. group-tab:: Ubuntu
成功编译后直接运行build目录下的lsc_connect,可见如下日志输出:
.. code-block:: bash
./build/lsc_connect
./build/lsc_connect
[lsc_core] lsc connect
[lsc_conn] [conn_auth] dev_id:F97CE114C70DE8E2 pro_id:ce1dda98-f2b8-46f9-a7b9-8aee214a459b ser_id:c684eb9e-ff8f-4264-ad03-0369b38ab793
[lisa-ws] websocket thread waiting for connect sem
[core-sntp] Using server ntp.aliyun.com for time query
[core-sntp] Server DNS resolved: Address=0xcb6b0658
[core-sntp] Obtained current time for SNTP request packet: Time=1719904825s 719ms
[core-sntp] Sending serialized SNTP request packet to the server: Addr=3412788824, Port=123
[core-sntp] Received server response: PacketSize=48
[core-sntp] Updating system time: ServerTime=3928893625 705ms ClockOffset=-2085978496s
......
......
......
[lsc_conn] [_ws_event_cb] evt:2
[lsc_core] [_lsc_core_conn_evt_cb] evt:conn connected
[lsc_conn] ws data: 81, {"action":"connected","cid":"9a0b421aef94","code":"0","data":"","desc":"success"}
[lsc_core] [_lsc_core_conn_evt_cb] evt:conn data cjson
[main] evt : lsc connected
.. group-tab:: Zephyr
.. code-block:: bash
west flash

View File

@@ -0,0 +1,42 @@
.. _index :
====================================
LSCHAT
====================================
简介
-------------------------------------
LSCHAT是由聆思科技提供一套跨平台的SDK, 封装了一系列与聆思云端交互能力,可让项目快速接入聆思云端大模型。
.. image:: _static/img/lschat.png
- conn: 负责云端的连接和数据收发
- session_core: 负责会话管理,数据打包和解析
- xx_session: 负责实例化会话具体行为,包含启动,停止,发送数据,监听关联事件等
- lisa: 跨平台标准接口,提供一系列跨平台的基础能力
能力
------------------------------
- 物体识别
- 文生图
- 音乐播控
- 闲聊
- TTS合成
已支持的平台
-------------------------------
- zephyr
- linux
.. note::
跨平台能力由lisa组件提供,具体细节见lisa组件。
.. toctree::
:maxdepth: 1
:caption: 目录
getting_started.rst
api.rst
samples/samples.rst

View File

@@ -0,0 +1,6 @@
.. _session_objrec:
物体识别
###################################
.. doxygengroup:: session_objrec

View File

@@ -0,0 +1,13 @@
.. _session_request:
服务请求
############################################
说明
********************************************
该会话用于请求云端服务技能,比如语音合成等
接口介绍
*********************************************
.. doxygengroup:: session_request

View File

@@ -0,0 +1,13 @@
.. _session_text:
文本会话
############################################
说明
********************************************
该会话用于通过文本和云端进行交互,并获取云端下发的结果
接口介绍
********************************************
.. doxygengroup:: session_text

View File

@@ -0,0 +1,13 @@
.. _session_voice:
闲聊会话
#################################
说明
********************************
该会话将语音上传到云端,云端会进行自动语音识别,语义理解,并下发相应结果
接口介绍
********************************
.. doxygengroup:: session_voice

View File

@@ -0,0 +1,8 @@
.. _lsc_stream_text:
流式文本
=======================
目前大模型平台下发的文本时采用的流式的方式。
.. doxygengroup:: lsc_stream_text