Skip to main content

licos-dev-sdk

服务端模型和文件工具 SDK。

身份选择(0.6.0 起)

LICOS_CURRENT_USER_ID 表示容器启动时配置的执行用户。SDK 不用它推断当前网页登录者,也不读取进程级 LICOS_USER_TOKEN 作为模型请求凭证。项目身份指运行时配置的项目所有者身份,按接口选择:

接口 默认身份 以网页登录用户执行
模型目录、模型详情、端点解析 项目身份 显式传 user_token
LLM、视觉、图片生成、视频生成、语音识别客户端 项目身份 每次用户请求创建客户端并传 user_token
check_credit_availability 项目身份 显式传 user_token
可观测性 项目身份 保持项目身份
文档、表格、图片排版等本地文件工具 无需用户 Token 无需用户 Token

需要以网页登录用户执行时,从本次认证会话取得不含 Bearer 前缀的 Token,并让积分检查和模型调用使用同一用户身份:

from licos_dev_sdk import LLMClient, check_credit_availability

# token 来自本次请求的认证会话。
availability = check_credit_availability(user_token=token, resource_code='LLM_INVOKE')
result = LLMClient(user_token=token).invoke('你好')

用户标识、名称和企业信息来自平台认证结果。项目所有者、工作空间等资源归属字段单独保留;模型实际计费上下文以平台模型详情接口签发的签名为准。

以网页登录用户执行的业务入口缺少 Token 时应返回登录错误,不能省略参数后使用项目身份。不要把请求 Token 或用户 ID 写入 os.environ,不要跨用户共享带身份的客户端。显式传入的 Token 为空或失效时直接报错,由调用方更新登录凭证后创建新客户端,不换取容器用户或项目所有者的 Token。

独立 licos-dev CLI 的模型和积分命令默认使用 LICOS_CURRENT_USER_ID,可用 --identity project 选择项目身份;HTTP 服务通过 CLI 代表登录用户执行时使用 --token-stdin。SDK 默认身份与 CLI 默认身份不同,调用时按上述接口规则显式选择。

编程项目登录身份

  • 有内置登录时使用内置登录会话;没有内置登录时使用当前 LICOS 网页登录。内置登录未登录或过期时不能切换成平台用户。
  • Node 服务端使用 createProjectAuth({ mode: 'builtin', resolveBuiltinToken }) 或 createProjectAuth({ mode: 'platform' }),每次请求调用 await projectAuth.userToken(request)。内置解析器必须读取已有认证会话并返回用户已授权的 LICOS 凭证。
  • 无内置登录的浏览器用户接口使用 @kmlckj/licos-platform-sdk/browser 的 createProjectUserFetch:平台登录桥领取一次性票据,项目后端兑换 Token。不要直接读取跨域平台 localStorage,不在 URL 中传 Token,不修改全局 fetch。项目级 API 保持原有请求方法。
  • Python 使用 ProjectAuth;Agent/Workflow 通过 config/licos-auth.json 配置模式,内置登录设置 resolver: "模块:函数",业务代码使用 ctx.identity.user_token。
  • 当前用户、企业知识库、本体用户操作显式传 userToken/user_token。模型、积分和普通知识库按业务选择用户或项目身份。数据库、对象存储和可观测性继续使用项目身份。
  • OAuth 接入 SDK 的用户、知识库、模型能力分别申请 project.user、project.knowledge、project.models;新增范围需要用户重新授权。业务自签 JWT 不能直接充当 LICOS Token。
  • 修改已有项目时先接它的现有登录机制,不能用新模板的默认平台模式覆盖。真实 Token 只存在于运行时请求/会话,不写入源代码、共享环境变量或 Agent 提示词。

Metadata

Release files for licos-dev-sdk 0.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for licos-dev-sdk 0.6.2
File Size Uploaded
licos_dev_sdk-0.6.2.tar.gz 133.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for licos-dev-sdk 0.6.2
File Interpreter ABI Platform
licos_dev_sdk-0.6.2-py3-none-any.whl Python 3 none any Details

Total release size: 251.8 kB

Release files / licos_dev_sdk-0.6.2.tar.gz

Download URL licos_dev_sdk-0.6.2.tar.gz
Size 133.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6d1d9f18b8f85cdd875c59a2f693e88010ffaebe3aa2e72eba74c921b269a8db
BLAKE2b-256 checksum
How to use checksums
e87d32e92c92dd2c5576af2e125130b6442d95d8c291be2d5cd9e0bc37737561
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / licos_dev_sdk-0.6.2-py3-none-any.whl

Download URL licos_dev_sdk-0.6.2-py3-none-any.whl
Size 118.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e06bce66869a58692e25c23de410ea200533ad86a7ec8d81d2d938f5a22978d1
BLAKE2b-256 checksum
How to use checksums
412df6d94b5d5137d7cadbb8c4da52406d3d90cb0ca624ca5aedc03a622b2faf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

This release

0.6.2 This release

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.10

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.24

2 release files

0.2.18

2 release files

0.2.17

2 release files

0.2.16

2 release files

0.2.15

2 release files

0.2.11

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page