funai
对 OpenAI 兼容接口的大语言模型做了一层薄封装,目前内置了 Moonshot(月之暗面)和 DeepSeek 两个 provider,API Key 通过 funsecret 统一管理。
安装
pip install funai
用法示例
from funai.llm import get_model
model = get_model("deepseek") # 或 "moonshot"
answer = model.fun_chat("你好,介绍一下你自己")
也可以直接实例化具体的 provider:
from funai.llm import Deepseek, Moonshot
model = Deepseek(api_key="sk-xxx", model_name="deepseek-chat")
# 不传 api_key 时会用 funsecret 从本地缓存读取 "funai"/"deepseek"/"api_key"
answer = model.fun_chat("讲个笑话")
Moonshot:默认model_name="moonshot-v1-8k",base_url="https://api.moonshot.cn/v1"Deepseek:默认model_name="deepseek-chat",base_url="https://api.deepseek.com"
两者都继承自 funai.llm.models.BaseModel(本质是 openai.OpenAI 客户端的子类)。fun_chat() 是对 chat.completions.create 的简单封装:传入 prompt(或自定义 messages),直接返回模型回复的文本内容。
传入不支持的 provider 时,get_model() 会抛出 funai.llm.UnsupportedProviderError。
关于 farfarfun
farfarfun 是一个专注于实用工具库的开源组织, 涵盖云存储、数据处理、AI、多媒体与开发工具链等方向。
- 🏠 组织主页:https://github.com/farfarfun
- 📦 PyPI:https://pypi.org/user/niuliangtao/
- 📧 联系:farfarfun@qq.com
本项目基于 MIT 协议开源。
Metadata
Release files for funai 1.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| funai-1.0.12-py3-none-any.whl | Python 3 | none | any | Details for funai-1.0.12-py3-none-any.whl |
Release files / funai-1.0.12-py3-none-any.whl
| Download URL | funai-1.0.12-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f6b04a989106d48fa59eda9275c20ed6095135445930673a3719c1df839abc11
|
|
BLAKE2b-256 checksum How to use checksums |
20a3fce9fcb67c9cfc793cebd8c16913c735d61d185d1be822b107bdc9940573
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for funai 1.0.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.