[全量] 初始化项目代码、配置、文档及Agent协同harness

This commit is contained in:
2026-04-02 11:36:05 +08:00
parent 0553309cdf
commit 87e571d9ec
1133 changed files with 221948 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
"""
Text rewriting functions for style transformation.
"""
from fastapi import Body
from sse_starlette.sse import EventSourceResponse
from typing import AsyncIterable
import json
async def formal_style_iterator(text: str) -> AsyncIterable[str]:
"""正式风格改写"""
yield json.dumps({"text": text}, ensure_ascii=False)
async def formal_style(text: str = Body(..., description="输入文本")):
"""正式风格改写"""
return EventSourceResponse(formal_style_iterator(text))
async def party_style_iterator(text: str) -> AsyncIterable[str]:
"""党政风格改写"""
yield json.dumps({"text": text}, ensure_ascii=False)
async def party_style(text: str = Body(..., description="输入文本")):
"""党政风格改写"""
return EventSourceResponse(party_style_iterator(text))
async def col_style_iterator(text: str) -> AsyncIterable[str]:
"""口语风格改写"""
yield json.dumps({"text": text}, ensure_ascii=False)
async def col_style(text: str = Body(..., description="输入文本")):
"""口语风格改写"""
return EventSourceResponse(col_style_iterator(text))
async def chi_to_ens_iterator(text: str) -> AsyncIterable[str]:
"""中文转英文"""
yield json.dumps({"text": text}, ensure_ascii=False)
async def chi_to_ens(text: str = Body(..., description="输入文本")):
"""中文转英文"""
return EventSourceResponse(chi_to_ens_iterator(text))
async def ens_to_chi_iterator(text: str) -> AsyncIterable[str]:
"""英文转中文"""
yield json.dumps({"text": text}, ensure_ascii=False)
async def ens_to_chi(text: str = Body(..., description="输入文本")):
"""英文转中文"""
return EventSourceResponse(ens_to_chi_iterator(text))