gengwiki-python
梗Wiki 的 Python SDK,支持 Python 3.10 及以上。
pip install gengwiki
到个人中心创建 Key,然后保存到本机,之后的代码里就不用再写它了。
gengwiki keys add 老哥 # 粘贴时不显示,也不会留在命令历史里
gengwiki status # 查看当前 Key、人设和额度
from gengwiki import GengWiki
client = GengWiki() # 也可以传入 Key,或者设置环境变量 GENGWIKI_API_KEY
client.search_memes("躺平")
client.meme("tang-ping").body
client.persona().as_message() # {"role": "system", "content": "..."}
更多用法见 example/。
切换人设
一个 Key 终身绑定一个人设,所以切换人设就是切换到绑定了它的 Key。没有这样的 Key 时,登录后会自动创建一个并保存。
persona = client.use_persona("温柔姐姐") # 按标题或 id
messages = [persona.as_message(), {"role": "user", "content": "你好"}]
client.personas("关键词") 可以浏览人设目录。Claude 的系统提示不放在消息列表里,所以要写成 system=persona.prompt。
命令行
安装后可以用 gengwiki,也可以用 python -m gengwiki。
gengwiki login # 登录,密码不会保存
gengwiki status # 当前站点、Key、人设和额度
gengwiki search 躺平 # 也有 meme、trending、personas
gengwiki use 温柔姐姐 # 切换人设
gengwiki sync --images # 下载全部内容供离线使用
gengwiki keys # 也有 add、use、remove、secret、remote、rotate、revoke
给大模型用的工具
tools = client.tools.openai() # OpenAI 和 DeepSeek 等的 Chat Completions
tools = client.tools.responses() # OpenAI 的 Responses API
tools = client.tools.anthropic() # Claude
while True:
reply = llm.chat.completions.create(model=model, messages=messages, tools=tools).choices[0].message
results = client.tools.run(reply)
if not results:
break
messages += [reply, *results]
Claude 的回复用法相同,只是追加时写成 {"role": "assistant", "content": reply.content}。Responses API 把 response 传给 run,追加时写成 input += [*response.output, *results]。
共有 5 个工具,分别是 search_memes、get_meme、trending_memes、search_stickers 和 search_lexicon。可以用 client.tools.openai(["search_memes"]) 只选其中几个。
开发
uv run python -m unittest discover -s tests -t .
tests/test_live.py 用来对照真实服务,只有设置了 GENGWIKI_LIVE_API 和 GENGWIKI_LIVE_SITE 才会运行,需要指向一套载入了 tests/live_seed.sql 的临时环境,绝对不要指向生产环境。
Metadata
Release files for gengwiki 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gengwiki-0.1.0.tar.gz | 22.8 kB | Without provenance | Details for gengwiki-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gengwiki-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for gengwiki-0.1.0-py3-none-any.whl |
Total release size: 49.9 kB
Release files / gengwiki-0.1.0.tar.gz
| Download URL | gengwiki-0.1.0.tar.gz |
|---|---|
| Size | 22.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d69d5dabbeda55020cd03058ae00422272a70db184c47ba56487b5211117ad3b
|
|
BLAKE2b-256 checksum How to use checksums |
066f00a8035fddf80bd3d10b39a86e533f9e7bd1fb9fffe9df8138585d8ba7fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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":true}
|
Release files / gengwiki-0.1.0-py3-none-any.whl
| Download URL | gengwiki-0.1.0-py3-none-any.whl |
|---|---|
| Size | 27.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c0ab75edfcc35f4dc53b673f41681b43b61ae4d194238d1151101e763913eba0
|
|
BLAKE2b-256 checksum How to use checksums |
d994c95c37a6a99cdb1c85723c75f06bc13b36b6106b4949db9d0d6bf41f938c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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":true}
|
Security for gengwiki 0.1.0
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.