chore: Add Chinese README and refactor NPU backend to use Unix domain sockets

- Introduced a new Chinese version of the README (README_CN.md) to provide localized documentation for AgentOS.
- Refactored the NPU bridge to utilize Unix domain sockets instead of HTTP loopback, enhancing security and performance.
- Updated the NPU backend to include a server socket configuration, ensuring proper communication over Unix sockets.
- Modified the Ntex client to support both network and Unix socket transports, improving flexibility in backend communication.
- Adjusted validation logic to enforce the use of Unix sockets for local model endpoints, rejecting loopback HTTP addresses.
- Enhanced error messages and documentation throughout the codebase to clarify the new socket-based architecture.
This commit is contained in:
emmettlu
2026-08-02 15:48:09 +08:00
parent eee7fed161
commit f863f83960
8 changed files with 1157 additions and 65 deletions
@@ -1,4 +1,4 @@
use agentos_npu::{LoopbackServerConfig, bridge_chat};
use agentos_npu::{DEFAULT_NPU_SERVER_SOCKET, UnixSocketServerConfig, bridge_chat};
use agentos_protocol::ChatRequest;
use anyhow::{Context, Result, bail};
use clap::Parser;
@@ -30,9 +30,9 @@ async fn main() -> Result<()> {
serde_json::from_slice(&input).context("parse agentos.chat.v1 request")?;
request.validate()?;
request.parallel_tool_calls = false;
let config = LoopbackServerConfig {
endpoint: std::env::var("AGENTOS_NPU_SERVER_URL")
.unwrap_or_else(|_| "http://127.0.0.1:8031/v1/chat/completions".into()),
let config = UnixSocketServerConfig {
socket_path: std::env::var_os("AGENTOS_NPU_SERVER_SOCKET")
.map_or_else(|| DEFAULT_NPU_SERVER_SOCKET.into(), Into::into),
model: std::env::var("AGENTOS_NPU_SERVER_MODEL").unwrap_or_else(|_| "agentos-npu".into()),
timeout: Duration::from_secs(
std::env::var("AGENTOS_NPU_SERVER_TIMEOUT_S")