pyllym 1.16.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyllym-1.16.0a1/.claude/hooks/block-dangerous-commands.sh +77 -0
- pyllym-1.16.0a1/.claude/settings.json +84 -0
- pyllym-1.16.0a1/.claude/settings.local.json +20 -0
- pyllym-1.16.0a1/.claude/skills/add-provider/SKILL.md +62 -0
- pyllym-1.16.0a1/.claude/skills/bdd-build/SKILL.md +77 -0
- pyllym-1.16.0a1/.claude/skills/dev-checks/SKILL.md +46 -0
- pyllym-1.16.0a1/.claude/skills/pyllym-structured-prompting/SKILL.md +240 -0
- pyllym-1.16.0a1/.env.example +58 -0
- pyllym-1.16.0a1/.github/dependabot.yml +46 -0
- pyllym-1.16.0a1/.gitignore +30 -0
- pyllym-1.16.0a1/CLAUDE.md +130 -0
- pyllym-1.16.0a1/LICENSE +22 -0
- pyllym-1.16.0a1/PKG-INFO +696 -0
- pyllym-1.16.0a1/README.md +629 -0
- pyllym-1.16.0a1/examples/.gitignore +2 -0
- pyllym-1.16.0a1/examples/README.md +62 -0
- pyllym-1.16.0a1/examples/_bootstrap.py +31 -0
- pyllym-1.16.0a1/examples/analysis_tools.toml +92 -0
- pyllym-1.16.0a1/examples/chat.py +23 -0
- pyllym-1.16.0a1/examples/moderation.py +225 -0
- pyllym-1.16.0a1/examples/stats.py +377 -0
- pyllym-1.16.0a1/examples/stream.py +23 -0
- pyllym-1.16.0a1/examples/structured.py +36 -0
- pyllym-1.16.0a1/examples/tools.py +35 -0
- pyllym-1.16.0a1/new-branch.sh +60 -0
- pyllym-1.16.0a1/pyproject.toml +93 -0
- pyllym-1.16.0a1/reactullm-pyllum.contract.json +174 -0
- pyllym-1.16.0a1/reactullm-pyllum.runtime.json +100 -0
- pyllym-1.16.0a1/src/pyllym/__init__.py +280 -0
- pyllym-1.16.0a1/src/pyllym/agent.py +74 -0
- pyllym-1.16.0a1/src/pyllym/aliases.json +553 -0
- pyllym-1.16.0a1/src/pyllym/aliases.py +35 -0
- pyllym-1.16.0a1/src/pyllym/attachment.py +221 -0
- pyllym-1.16.0a1/src/pyllym/bdd/__init__.py +59 -0
- pyllym-1.16.0a1/src/pyllym/bdd/__main__.py +69 -0
- pyllym-1.16.0a1/src/pyllym/bdd/brief.py +120 -0
- pyllym-1.16.0a1/src/pyllym/bdd/builder.py +173 -0
- pyllym-1.16.0a1/src/pyllym/bdd/checks.py +61 -0
- pyllym-1.16.0a1/src/pyllym/bdd/planner.py +140 -0
- pyllym-1.16.0a1/src/pyllym/bdd/renderer.py +106 -0
- pyllym-1.16.0a1/src/pyllym/bdd/safety.py +141 -0
- pyllym-1.16.0a1/src/pyllym/bdd/schema.py +87 -0
- pyllym-1.16.0a1/src/pyllym/bdd/sequence.py +147 -0
- pyllym-1.16.0a1/src/pyllym/bdd/toml_spec.py +367 -0
- pyllym-1.16.0a1/src/pyllym/celery/__init__.py +36 -0
- pyllym-1.16.0a1/src/pyllym/celery/tasks.py +218 -0
- pyllym-1.16.0a1/src/pyllym/chat.py +497 -0
- pyllym-1.16.0a1/src/pyllym/chunk.py +9 -0
- pyllym-1.16.0a1/src/pyllym/citation.py +44 -0
- pyllym-1.16.0a1/src/pyllym/configuration.py +116 -0
- pyllym-1.16.0a1/src/pyllym/connection.py +277 -0
- pyllym-1.16.0a1/src/pyllym/content.py +77 -0
- pyllym-1.16.0a1/src/pyllym/context.py +60 -0
- pyllym-1.16.0a1/src/pyllym/cost.py +269 -0
- pyllym-1.16.0a1/src/pyllym/embedding.py +37 -0
- pyllym-1.16.0a1/src/pyllym/errors.py +140 -0
- pyllym-1.16.0a1/src/pyllym/image.py +85 -0
- pyllym-1.16.0a1/src/pyllym/message.py +184 -0
- pyllym-1.16.0a1/src/pyllym/mime_type.py +136 -0
- pyllym-1.16.0a1/src/pyllym/model/__init__.py +11 -0
- pyllym-1.16.0a1/src/pyllym/model/info.py +181 -0
- pyllym-1.16.0a1/src/pyllym/model/modalities.py +17 -0
- pyllym-1.16.0a1/src/pyllym/model/pricing.py +54 -0
- pyllym-1.16.0a1/src/pyllym/model/pricing_category.py +52 -0
- pyllym-1.16.0a1/src/pyllym/model/pricing_tier.py +44 -0
- pyllym-1.16.0a1/src/pyllym/models.json +64119 -0
- pyllym-1.16.0a1/src/pyllym/models.py +284 -0
- pyllym-1.16.0a1/src/pyllym/models_schema.json +169 -0
- pyllym-1.16.0a1/src/pyllym/moderation.py +55 -0
- pyllym-1.16.0a1/src/pyllym/persistence/__init__.py +27 -0
- pyllym-1.16.0a1/src/pyllym/persistence/models.py +173 -0
- pyllym-1.16.0a1/src/pyllym/protocol.py +265 -0
- pyllym-1.16.0a1/src/pyllym/protocols/__init__.py +1 -0
- pyllym-1.16.0a1/src/pyllym/protocols/anthropic.py +537 -0
- pyllym-1.16.0a1/src/pyllym/protocols/chat_completions.py +682 -0
- pyllym-1.16.0a1/src/pyllym/protocols/converse.py +619 -0
- pyllym-1.16.0a1/src/pyllym/protocols/fal.py +123 -0
- pyllym-1.16.0a1/src/pyllym/protocols/gemini.py +922 -0
- pyllym-1.16.0a1/src/pyllym/provider.py +338 -0
- pyllym-1.16.0a1/src/pyllym/providers/__init__.py +1 -0
- pyllym-1.16.0a1/src/pyllym/providers/anthropic.py +39 -0
- pyllym-1.16.0a1/src/pyllym/providers/azure.py +33 -0
- pyllym-1.16.0a1/src/pyllym/providers/bedrock.py +227 -0
- pyllym-1.16.0a1/src/pyllym/providers/capabilities.py +37 -0
- pyllym-1.16.0a1/src/pyllym/providers/cerebras.py +10 -0
- pyllym-1.16.0a1/src/pyllym/providers/databricks.py +14 -0
- pyllym-1.16.0a1/src/pyllym/providers/deepseek.py +10 -0
- pyllym-1.16.0a1/src/pyllym/providers/doubao.py +14 -0
- pyllym-1.16.0a1/src/pyllym/providers/ernie.py +13 -0
- pyllym-1.16.0a1/src/pyllym/providers/fal.py +40 -0
- pyllym-1.16.0a1/src/pyllym/providers/gemini.py +154 -0
- pyllym-1.16.0a1/src/pyllym/providers/gpustack.py +33 -0
- pyllym-1.16.0a1/src/pyllym/providers/huggingface.py +10 -0
- pyllym-1.16.0a1/src/pyllym/providers/minimax.py +15 -0
- pyllym-1.16.0a1/src/pyllym/providers/mistral.py +9 -0
- pyllym-1.16.0a1/src/pyllym/providers/moonshot.py +15 -0
- pyllym-1.16.0a1/src/pyllym/providers/nvidia.py +10 -0
- pyllym-1.16.0a1/src/pyllym/providers/ollama.py +33 -0
- pyllym-1.16.0a1/src/pyllym/providers/openai.py +51 -0
- pyllym-1.16.0a1/src/pyllym/providers/openai_compatible.py +61 -0
- pyllym-1.16.0a1/src/pyllym/providers/openrouter.py +9 -0
- pyllym-1.16.0a1/src/pyllym/providers/perplexity.py +25 -0
- pyllym-1.16.0a1/src/pyllym/providers/qwen.py +15 -0
- pyllym-1.16.0a1/src/pyllym/providers/vertexai.py +106 -0
- pyllym-1.16.0a1/src/pyllym/providers/vllm.py +44 -0
- pyllym-1.16.0a1/src/pyllym/providers/xai.py +10 -0
- pyllym-1.16.0a1/src/pyllym/providers/zhipu.py +15 -0
- pyllym-1.16.0a1/src/pyllym/py.typed +0 -0
- pyllym-1.16.0a1/src/pyllym/reactllm_bridge.py +165 -0
- pyllym-1.16.0a1/src/pyllym/reactullm_bridge.py +228 -0
- pyllym-1.16.0a1/src/pyllym/reactullm_handoff.py +352 -0
- pyllym-1.16.0a1/src/pyllym/reactullm_runtime.py +405 -0
- pyllym-1.16.0a1/src/pyllym/search_results.py +45 -0
- pyllym-1.16.0a1/src/pyllym/speech.py +73 -0
- pyllym-1.16.0a1/src/pyllym/stream_accumulator.py +249 -0
- pyllym-1.16.0a1/src/pyllym/streaming.py +167 -0
- pyllym-1.16.0a1/src/pyllym/tdg/__init__.py +66 -0
- pyllym-1.16.0a1/src/pyllym/tdg/__main__.py +86 -0
- pyllym-1.16.0a1/src/pyllym/tdg/brief.py +120 -0
- pyllym-1.16.0a1/src/pyllym/tdg/builder.py +288 -0
- pyllym-1.16.0a1/src/pyllym/tdg/checks.py +61 -0
- pyllym-1.16.0a1/src/pyllym/tdg/deps.py +251 -0
- pyllym-1.16.0a1/src/pyllym/tdg/planner.py +140 -0
- pyllym-1.16.0a1/src/pyllym/tdg/renderer.py +106 -0
- pyllym-1.16.0a1/src/pyllym/tdg/runs.py +142 -0
- pyllym-1.16.0a1/src/pyllym/tdg/safety.py +141 -0
- pyllym-1.16.0a1/src/pyllym/tdg/schema.py +87 -0
- pyllym-1.16.0a1/src/pyllym/tdg/sequence.py +147 -0
- pyllym-1.16.0a1/src/pyllym/tdg/toml_spec.py +367 -0
- pyllym-1.16.0a1/src/pyllym/thinking.py +42 -0
- pyllym-1.16.0a1/src/pyllym/tokens.py +53 -0
- pyllym-1.16.0a1/src/pyllym/tool.py +197 -0
- pyllym-1.16.0a1/src/pyllym/tool_call.py +23 -0
- pyllym-1.16.0a1/src/pyllym/toolset.py +343 -0
- pyllym-1.16.0a1/src/pyllym/transcription.py +44 -0
- pyllym-1.16.0a1/src/pyllym/uploaded_file.py +59 -0
- pyllym-1.16.0a1/src/pyllym/utils.py +124 -0
- pyllym-1.16.0a1/src/pyllym/video.py +87 -0
- pyllym-1.16.0a1/tests/__init__.py +0 -0
- pyllym-1.16.0a1/tests/conftest.py +103 -0
- pyllym-1.16.0a1/tests/factories.py +165 -0
- pyllym-1.16.0a1/tests/seed_fixtures.py +69 -0
- pyllym-1.16.0a1/tests/test_bdd.py +551 -0
- pyllym-1.16.0a1/tests/test_bedrock.py +42 -0
- pyllym-1.16.0a1/tests/test_behaviors.py +164 -0
- pyllym-1.16.0a1/tests/test_capabilities.py +58 -0
- pyllym-1.16.0a1/tests/test_celery.py +107 -0
- pyllym-1.16.0a1/tests/test_chat.py +193 -0
- pyllym-1.16.0a1/tests/test_core.py +67 -0
- pyllym-1.16.0a1/tests/test_errors.py +44 -0
- pyllym-1.16.0a1/tests/test_fal.py +66 -0
- pyllym-1.16.0a1/tests/test_gemini_extra.py +57 -0
- pyllym-1.16.0a1/tests/test_ollama.py +114 -0
- pyllym-1.16.0a1/tests/test_persistence.py +52 -0
- pyllym-1.16.0a1/tests/test_provider_matrix.py +89 -0
- pyllym-1.16.0a1/tests/test_reactullm_bridge.py +215 -0
- pyllym-1.16.0a1/tests/test_reactullm_handoff.py +199 -0
- pyllym-1.16.0a1/tests/test_reactullm_runtime.py +358 -0
- pyllym-1.16.0a1/tests/test_review_fixes.py +177 -0
- pyllym-1.16.0a1/tests/test_seeder.py +20 -0
- pyllym-1.16.0a1/tests/test_tdg_deps.py +166 -0
- pyllym-1.16.0a1/tests/test_tdg_runs.py +104 -0
- pyllym-1.16.0a1/tests/test_toolset.py +175 -0
- pyllym-1.16.0a1/tests/test_value_objects.py +51 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# PreToolUse hook: hard-block dangerous shell commands.
|
|
4
|
+
#
|
|
5
|
+
# Claude Code invokes this before every Bash tool call and pipes the tool
|
|
6
|
+
# input as JSON on stdin, e.g. {"tool_name":"Bash","tool_input":{"command":"..."}}.
|
|
7
|
+
#
|
|
8
|
+
# Exit 0 -> allow the command.
|
|
9
|
+
# Exit 2 -> block the command; stderr is shown to Claude as the reason.
|
|
10
|
+
# JSON on stdout -> structured decision (we use exit codes for simplicity).
|
|
11
|
+
#
|
|
12
|
+
# This is defense-in-depth, NOT a sandbox. A determined pattern can evade a
|
|
13
|
+
# static denylist. The real boundary is human review + running untrusted code
|
|
14
|
+
# only where secrets/network are unreachable (see CLAUDE.md security model).
|
|
15
|
+
|
|
16
|
+
set -euo pipefail
|
|
17
|
+
|
|
18
|
+
input="$(cat)"
|
|
19
|
+
|
|
20
|
+
# Pull the command string out of the JSON without needing jq.
|
|
21
|
+
command="$(printf '%s' "$input" | python3 -c '
|
|
22
|
+
import json, sys
|
|
23
|
+
try:
|
|
24
|
+
data = json.load(sys.stdin)
|
|
25
|
+
except Exception:
|
|
26
|
+
print("")
|
|
27
|
+
sys.exit(0)
|
|
28
|
+
print(data.get("tool_input", {}).get("command", ""))
|
|
29
|
+
' 2>/dev/null || printf '')"
|
|
30
|
+
|
|
31
|
+
# Nothing to inspect -> allow.
|
|
32
|
+
[ -z "$command" ] && exit 0
|
|
33
|
+
|
|
34
|
+
block() {
|
|
35
|
+
echo "BLOCKED by block-dangerous-commands hook: $1" >&2
|
|
36
|
+
echo "Command: $command" >&2
|
|
37
|
+
exit 2
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# --- Dangerous patterns (POSIX ERE, case-insensitive) -------------------------
|
|
41
|
+
# Each entry: "regex::human reason". Bash `[[ =~ ]]` uses POSIX ERE, which has
|
|
42
|
+
# NO \b word boundary and NO \d — use (^|[^alnum]) style guards and explicit
|
|
43
|
+
# whitespace via [[:space:]]. Keep patterns conservative to avoid false
|
|
44
|
+
# positives on legitimate project commands.
|
|
45
|
+
patterns=(
|
|
46
|
+
'rm[[:space:]]+(-[[:alnum:]]*[rf][[:alnum:]]*[[:space:]]+)+(/|~|\$HOME|\*|\.($|[[:space:]]))::recursive/forced rm of root, home, or wildcard'
|
|
47
|
+
':[[:space:]]*\([[:space:]]*\)[[:space:]]*\{[[:space:]]*:[[:space:]]*\|[[:space:]]*:[[:space:]]*&::fork bomb'
|
|
48
|
+
'(^|[^[:alnum:]])mkfs(\.[[:alnum:]]+)?([^[:alnum:]]|$)::filesystem format (mkfs)'
|
|
49
|
+
'(^|[^[:alnum:]])dd[[:space:]][^|]*of=/dev/::dd writing to a raw device'
|
|
50
|
+
'>[[:space:]]*/dev/(sd|nvme|disk|hd)::redirect into a raw disk device'
|
|
51
|
+
'(^|[^[:alnum:]])shred([^[:alnum:]]|$)::secure-erase (shred)'
|
|
52
|
+
'(^|[^[:alnum:]])(shutdown|reboot|halt|poweroff)([^[:alnum:]]|$)::power state change'
|
|
53
|
+
'chmod[[:space:]]+-R[[:space:]]+0*777[[:space:]]+/::recursive world-writable on root'
|
|
54
|
+
'chown[[:space:]]+-R[[:space:]].*[[:space:]]+/[[:space:]]*$::recursive chown of root'
|
|
55
|
+
'git[[:space:]]+push[[:space:]].*--force::git push --force (use --force-with-lease)'
|
|
56
|
+
'git[[:space:]]+push[[:space:]].*(^|[[:space:]])-f($|[[:space:]])::git push -f (use --force-with-lease)'
|
|
57
|
+
'git[[:space:]]+reset[[:space:]]+--hard.*origin/::hard reset onto a remote ref (discards local work)'
|
|
58
|
+
'git[[:space:]]+clean[[:space:]]+-[[:alpha:]]*f[[:alpha:]]*d::git clean -fd (deletes untracked files)'
|
|
59
|
+
'curl[[:space:]].*\|[[:space:]]*(sudo[[:space:]]+)?(bash|sh|zsh)([^[:alnum:]]|$)::piping remote script straight into a shell'
|
|
60
|
+
'wget[[:space:]].*\|[[:space:]]*(sudo[[:space:]]+)?(bash|sh|zsh)([^[:alnum:]]|$)::piping remote script straight into a shell'
|
|
61
|
+
'eval[[:space:]].*\$\(curl::eval of remote content'
|
|
62
|
+
'sudo[[:space:]]+rm([^[:alnum:]]|$)::sudo rm'
|
|
63
|
+
'(pip|pip3|python[0-9.]*[[:space:]]+-m[[:space:]]+pip)[[:space:]]+.*--break-system-packages::pip --break-system-packages'
|
|
64
|
+
'/dev/(tcp|udp)/::raw network socket via /dev/tcp'
|
|
65
|
+
'history[[:space:]]+-c([^[:alnum:]]|$)::clearing shell history'
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
shopt -s nocasematch
|
|
69
|
+
for entry in "${patterns[@]}"; do
|
|
70
|
+
regex="${entry%%::*}"
|
|
71
|
+
reason="${entry##*::}"
|
|
72
|
+
if [[ "$command" =~ $regex ]]; then
|
|
73
|
+
block "$reason"
|
|
74
|
+
fi
|
|
75
|
+
done
|
|
76
|
+
|
|
77
|
+
exit 0
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/claude-code-settings.json",
|
|
3
|
+
"permissions": {
|
|
4
|
+
"deny": [
|
|
5
|
+
"Bash(rm -rf /*)",
|
|
6
|
+
"Bash(rm -rf ~*)",
|
|
7
|
+
"Bash(rm -rf .*)",
|
|
8
|
+
"Bash(sudo rm*)",
|
|
9
|
+
"Bash(mkfs*)",
|
|
10
|
+
"Bash(dd*of=/dev/*)",
|
|
11
|
+
"Bash(shutdown*)",
|
|
12
|
+
"Bash(reboot*)",
|
|
13
|
+
"Bash(halt*)",
|
|
14
|
+
"Bash(poweroff*)",
|
|
15
|
+
"Bash(shred*)",
|
|
16
|
+
"Bash(git push*--force*)",
|
|
17
|
+
"Bash(git push*-f*)",
|
|
18
|
+
"Bash(git reset --hard*origin/*)",
|
|
19
|
+
"Bash(git clean -*f*d*)",
|
|
20
|
+
"Bash(chmod -R 777 /*)",
|
|
21
|
+
"Bash(curl*|*sh*)",
|
|
22
|
+
"Bash(curl*|*bash*)",
|
|
23
|
+
"Bash(wget*|*sh*)",
|
|
24
|
+
"Bash(wget*|*bash*)",
|
|
25
|
+
"Bash(history -c*)",
|
|
26
|
+
"Read(./.env)",
|
|
27
|
+
"Read(./.env.*)",
|
|
28
|
+
"Read(./**/*secret*)",
|
|
29
|
+
"Read(./llm_ignore/**)"
|
|
30
|
+
],
|
|
31
|
+
"ask": [
|
|
32
|
+
"Bash(rm:*)",
|
|
33
|
+
"Bash(rmdir:*)",
|
|
34
|
+
"Bash(mv:*)",
|
|
35
|
+
"Bash(truncate:*)",
|
|
36
|
+
"Bash(:>*)",
|
|
37
|
+
"Bash(find:* -delete)",
|
|
38
|
+
"Bash(find:* -exec rm *)",
|
|
39
|
+
"Bash(xargs rm:*)",
|
|
40
|
+
"Bash(chmod -R:*)",
|
|
41
|
+
"Bash(chown -R:*)",
|
|
42
|
+
"Bash(git rm:*)",
|
|
43
|
+
"Bash(git reset --hard:*)",
|
|
44
|
+
"Bash(git clean:*)",
|
|
45
|
+
"Bash(git checkout -- :*)",
|
|
46
|
+
"Bash(git restore:*)",
|
|
47
|
+
"Bash(git branch -D:*)",
|
|
48
|
+
"Bash(git branch -d:*)",
|
|
49
|
+
"Bash(git stash drop:*)",
|
|
50
|
+
"Bash(git stash clear:*)",
|
|
51
|
+
"Bash(cargo clean:*)"
|
|
52
|
+
],
|
|
53
|
+
"allow": [
|
|
54
|
+
"Bash(.venv/bin/ruff check*)",
|
|
55
|
+
"Bash(.venv/bin/ruff format*)",
|
|
56
|
+
"Bash(.venv/bin/mypy*)",
|
|
57
|
+
"Bash(.venv/bin/pytest*)",
|
|
58
|
+
"Bash(.venv/bin/python*)",
|
|
59
|
+
"Bash(pytest*)",
|
|
60
|
+
"Bash(ruff check*)",
|
|
61
|
+
"Bash(ruff format*)",
|
|
62
|
+
"Bash(mypy src*)",
|
|
63
|
+
"Bash(git status*)",
|
|
64
|
+
"Bash(git diff*)",
|
|
65
|
+
"Bash(git log*)",
|
|
66
|
+
"Bash(git fetch*)",
|
|
67
|
+
"Bash(git add*)",
|
|
68
|
+
"Bash(git branch*)"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"hooks": {
|
|
72
|
+
"PreToolUse": [
|
|
73
|
+
{
|
|
74
|
+
"matcher": "Bash",
|
|
75
|
+
"hooks": [
|
|
76
|
+
{
|
|
77
|
+
"type": "command",
|
|
78
|
+
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/block-dangerous-commands.sh"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(/Users/kaarlekulvik/Projects/malayopython_reticulatus_llm/.venv/bin/ruff check *)",
|
|
5
|
+
"Bash(python -c \"import ast; ast.parse\\(open\\('src/pyllym/bdd/planner.py'\\).read\\(\\)\\); ast.parse\\(open\\('src/pyllym/bdd/builder.py'\\).read\\(\\)\\); print\\('syntax ok'\\)\")",
|
|
6
|
+
"Bash(python -c \"from pyllym.bdd import planner, builder; print\\('planner.plan_from_spec:', hasattr\\(planner,'plan_from_spec'\\)\\); print\\('builder.build:', hasattr\\(builder,'build'\\)\\)\")",
|
|
7
|
+
"Bash(python3 -c \"import ast; ast.parse\\(open\\('src/pyllym/bdd/planner.py'\\).read\\(\\)\\); ast.parse\\(open\\('src/pyllym/bdd/builder.py'\\).read\\(\\)\\); print\\('syntax ok'\\)\")",
|
|
8
|
+
"Bash(/Users/kaarlekulvik/Projects/malayopython_reticulatus_llm/.venv/bin/pytest tests/test_bdd.py -q)",
|
|
9
|
+
"Bash(python3 -c ' *)",
|
|
10
|
+
"Bash(.venv/bin/python -c ' *)",
|
|
11
|
+
"Bash(.venv/bin/ruff check *)",
|
|
12
|
+
"Bash(.venv/bin/ruff format *)",
|
|
13
|
+
"Bash(git fetch *)",
|
|
14
|
+
"Bash(python3 -c \"import json; json.load\\(open\\('.claude/settings.json'\\)\\); print\\('settings.json: valid JSON'\\)\")",
|
|
15
|
+
"Bash(.venv/bin/pip list *)",
|
|
16
|
+
"Bash(.venv/bin/pip show *)",
|
|
17
|
+
"Bash(grep -viE \"no .torch|torch./cuda dependency|no in-library|not of pyllym|torch\\\\`/cuda\")"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: add-provider
|
|
3
|
+
description: Add a new OpenAI-compatible AI provider to pyllym — create the provider class under src/pyllym/providers/ and register it in the package façade. Use when the user wants to "add a provider", "support <vendor>'s API", or wire up a new OpenAI-compatible endpoint.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# add-provider
|
|
7
|
+
|
|
8
|
+
Add a provider following pyllym's **Provider (where/who) → Protocol (wire format)
|
|
9
|
+
→ Connection (aiohttp)** architecture. For any endpoint that speaks the
|
|
10
|
+
OpenAI chat-completions wire format this is a ~10-line file plus one line of
|
|
11
|
+
registration. Non-compatible vendors (Anthropic, Gemini, Bedrock Converse, fal)
|
|
12
|
+
implement their own protocol instead — that is a larger task; flag it rather
|
|
13
|
+
than forcing `OpenAICompatible`.
|
|
14
|
+
|
|
15
|
+
## Steps for an OpenAI-compatible provider
|
|
16
|
+
|
|
17
|
+
1. **Create `src/pyllym/providers/<slug>.py`.** Subclass `OpenAICompatible`.
|
|
18
|
+
Use an existing minimal provider such as `providers/deepseek.py` as the
|
|
19
|
+
template:
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
"""<Vendor> API integration."""
|
|
23
|
+
|
|
24
|
+
from __future__ import annotations
|
|
25
|
+
|
|
26
|
+
from .openai_compatible import OpenAICompatible
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class <Vendor>(OpenAICompatible):
|
|
30
|
+
default_api_base = "https://api.<vendor>.com/v1"
|
|
31
|
+
assume_models = True # skip a models-exist preflight when the vendor
|
|
32
|
+
# has no /models listing
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
- `default_api_base` — the chat-completions base URL.
|
|
36
|
+
- `assume_models` — set `True` when the vendor doesn't expose a model list.
|
|
37
|
+
- Only override headers / config options if the vendor needs a non-standard
|
|
38
|
+
auth header; otherwise `OpenAICompatible` handles `Authorization: Bearer`.
|
|
39
|
+
|
|
40
|
+
2. **Register it** in `src/pyllym/__init__.py`, inside
|
|
41
|
+
`_register_builtin_providers()`, by appending a `(slug, ClassName)` tuple to
|
|
42
|
+
the `registrations` list (keep it grouped with its peers). Registration is
|
|
43
|
+
defensive — a module that fails to import is silently skipped.
|
|
44
|
+
|
|
45
|
+
3. **Config / env fallback.** Provider options fall back to the uppercase env
|
|
46
|
+
var of the same name (e.g. `<vendor>_api_key` → `<VENDOR>_API_KEY`); values
|
|
47
|
+
set via `pyllym.configure()` win. No extra wiring needed for the standard
|
|
48
|
+
API-key case.
|
|
49
|
+
|
|
50
|
+
4. **Verify** with the `dev-checks` skill (ruff, mypy, pytest). Confirm the
|
|
51
|
+
provider is discoverable:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
.venv/bin/python -c "import pyllym; print('<slug>' in [p.slug for p in pyllym.list_providers()])"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Conventions
|
|
58
|
+
|
|
59
|
+
- `from __future__ import annotations` at the top; PEP 604 unions; builtin
|
|
60
|
+
generics.
|
|
61
|
+
- Don't hand-edit `models.json` — it's generated. Prefer `pyllym.models.refresh()`.
|
|
62
|
+
- Keep provider modules thin: they declare *where/who*, not wire format.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bdd-build
|
|
3
|
+
description: >-
|
|
4
|
+
Drive the BDD→TDD workflow with pyllym.bdd: generate a red pytest suite plus
|
|
5
|
+
a build brief from a TOML spec, then implement code until the suite is green
|
|
6
|
+
without editing the generated tests. Use when the user asks to "build from a
|
|
7
|
+
spec", mentions a .toml spec, a BRIEF_*.md or *.plan.json file, wants to
|
|
8
|
+
scaffold tests from a TOML spec, or asks to implement against a generated
|
|
9
|
+
bdd_pending suite.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# BDD build workflow
|
|
13
|
+
|
|
14
|
+
Two phases with a mandatory human review gate between them.
|
|
15
|
+
|
|
16
|
+
## Phase 1 — generate the specification
|
|
17
|
+
|
|
18
|
+
1. Run the builder from a TOML spec (request mode needs a configured provider
|
|
19
|
+
key; plan mode does not):
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
python -m pyllym.bdd <spec-path> --out tests/generated --model <model-id>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`<spec-path>` is a `.toml` spec file or a directory of them. Mode is
|
|
26
|
+
auto-detected from the presence of `[[cases]]` (override with `--toml-mode
|
|
27
|
+
plan|request`):
|
|
28
|
+
|
|
29
|
+
- **plan mode** — the spec carries hand-written `[[cases]]`; the plan is
|
|
30
|
+
built deterministically with **no LLM** (no model/key needed).
|
|
31
|
+
- **request mode** — a loose spec (`[[rules]]`/`[[edge_cases]]`, no cases);
|
|
32
|
+
the planner model fills the plan. Pass `--api-hint "<module path /
|
|
33
|
+
existing signatures>"` when the target module already exists — the
|
|
34
|
+
planner must honor it exactly.
|
|
35
|
+
|
|
36
|
+
A spec may absorb mermaid `sequenceDiagram` blocks via `[[sequences]]`
|
|
37
|
+
tables as binding collaboration contracts. Encourage the user to provide
|
|
38
|
+
them — they make generation materially more airtight: every diagram message
|
|
39
|
+
gets an id (`M1`, ...), test cases must claim coverage of each id (as must
|
|
40
|
+
every rule/edge id), and the build fails mechanically on any gap
|
|
41
|
+
(`PlanValidationError`). If it fails, inspect the written
|
|
42
|
+
`<slug>.plan.json`, then either re-run or relax with `strict=False` via the
|
|
43
|
+
Python API and review the warnings in the brief.
|
|
44
|
+
|
|
45
|
+
Every executable string in the plan (a case's `given`/`when`/`then`, fixture
|
|
46
|
+
bodies) is also screened by an AST safety gate before rendering — imports,
|
|
47
|
+
dangerous builtins/names, dunder reflection, or non-Python raise
|
|
48
|
+
`PlanSafetyError` and write nothing runnable. This is a hard fail in both
|
|
49
|
+
modes and is not relaxed by `strict=False`; it is defense-in-depth, not a
|
|
50
|
+
sandbox, so still review generated tests before running them anywhere with
|
|
51
|
+
secrets or network access.
|
|
52
|
+
|
|
53
|
+
2. For each spec this writes `test_<slug>.py` (red suite),
|
|
54
|
+
`<slug>.plan.json` (the plan), and `BRIEF_<slug>.md` (the building
|
|
55
|
+
instruction with rule/edge and message→tests traceability tables), plus a
|
|
56
|
+
`conftest.py` registering the `bdd_pending` marker.
|
|
57
|
+
|
|
58
|
+
3. **Stop here.** Present the plan and generated tests to the user for
|
|
59
|
+
review. Do not start implementing in the same pass: once the suite is
|
|
60
|
+
treated as the spec, a misread scenario is locked in. Point out anything
|
|
61
|
+
in the plan that looks like invented behavior (cases marked
|
|
62
|
+
`edge_case: true` deserve extra scrutiny).
|
|
63
|
+
|
|
64
|
+
## Phase 2 — implement to green
|
|
65
|
+
|
|
66
|
+
Only after the user approves the tests (or asks you to implement against an
|
|
67
|
+
existing brief):
|
|
68
|
+
|
|
69
|
+
1. Read `BRIEF_<slug>.md`. Implement exactly the API surface it lists —
|
|
70
|
+
module path and signatures verbatim; keep everything else private.
|
|
71
|
+
2. The generated tests are **read-only**. If a test looks wrong or
|
|
72
|
+
unsatisfiable, stop and flag it to the user — never adapt a test to the
|
|
73
|
+
implementation. Regeneration from the .toml spec is the only sanctioned
|
|
74
|
+
way tests change.
|
|
75
|
+
3. Iterate: `pytest tests/generated/test_<slug>.py` until green.
|
|
76
|
+
4. Definition of done is in the brief: the suite passes with zero edits to
|
|
77
|
+
the test file. Run the repo's full lint/type gate afterwards.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dev-checks
|
|
3
|
+
description: Run the pyllym quality gate — ruff lint, ruff format check, mypy type-check, and pytest. Use when the user asks to "run checks", "lint", "typecheck", "run the tests", "is it green?", verify a change is ready to commit, or before opening a PR.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# dev-checks
|
|
7
|
+
|
|
8
|
+
Run the full local quality gate for the **pyllym** package and report results.
|
|
9
|
+
Prefer the project virtualenv (`.venv/bin/*`) so the pinned tool versions are used.
|
|
10
|
+
|
|
11
|
+
## The gate
|
|
12
|
+
|
|
13
|
+
Run these in order. Stop and report on the first failure unless the user asked
|
|
14
|
+
for the whole sweep regardless.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# 1. Lint
|
|
18
|
+
.venv/bin/ruff check src tests
|
|
19
|
+
|
|
20
|
+
# 2. Format (check only — do not auto-format unless asked)
|
|
21
|
+
.venv/bin/ruff format --check src tests
|
|
22
|
+
|
|
23
|
+
# 3. Types
|
|
24
|
+
.venv/bin/mypy src
|
|
25
|
+
|
|
26
|
+
# 4. Tests
|
|
27
|
+
.venv/bin/pytest
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
If `.venv/bin/*` is missing, fall back to bare `ruff` / `mypy` / `pytest`, and
|
|
31
|
+
tell the user the venv wasn't found (they may need `pip install -e ".[dev,db]"`).
|
|
32
|
+
|
|
33
|
+
## Conventions to respect
|
|
34
|
+
|
|
35
|
+
- `ruff` config lives in `pyproject.toml` (`line-length = 100`, `target-version = py313`).
|
|
36
|
+
- Do **not** run `ruff format` (mutating) as part of a check — only `--check`.
|
|
37
|
+
Offer to apply formatting as a separate, explicit step.
|
|
38
|
+
- `mypy` runs against `src` only, not `tests`.
|
|
39
|
+
- Generated BDD suites carry the `bdd_pending` marker and may be expected to
|
|
40
|
+
fail (red) during a build — mention this if pytest reports `bdd_pending`
|
|
41
|
+
failures so they aren't mistaken for regressions.
|
|
42
|
+
|
|
43
|
+
## Reporting
|
|
44
|
+
|
|
45
|
+
Summarize pass/fail per stage. On failure, show the offending output and point
|
|
46
|
+
at the file:line. Don't claim green unless every stage actually passed.
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pyllym-structured-prompting
|
|
3
|
+
description: >-
|
|
4
|
+
Build structured prompting with the async-first pyllym library (Python 3.14):
|
|
5
|
+
structured output via Pydantic schemas, tools/function-calling, system
|
|
6
|
+
instructions, reasoning/thinking controls, streaming, and multimodal input —
|
|
7
|
+
plus how to register new models and add new providers. Use when writing or
|
|
8
|
+
reviewing code that calls pyllym (pyllym.create_chat / embed / paint /
|
|
9
|
+
animate), when
|
|
10
|
+
designing a JSON-schema/Pydantic response contract, when a model id isn't
|
|
11
|
+
found, or when wiring up a new AI provider.
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# pyllym: structured prompting & new models
|
|
15
|
+
|
|
16
|
+
`pyllym` is one async-first Python framework for every major AI provider. This
|
|
17
|
+
skill covers the two things people most often need: **structured prompting**
|
|
18
|
+
(reliable, typed outputs and tool use) and **extending the model/provider set**.
|
|
19
|
+
|
|
20
|
+
Target runtime: **Python 3.14** (3.13+). Everything I/O is `async`.
|
|
21
|
+
|
|
22
|
+
## Setup
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
import pyllym
|
|
26
|
+
|
|
27
|
+
pyllym.configure(lambda c: setattr(c, "openai_api_key", "sk-..."))
|
|
28
|
+
# multiple keys:
|
|
29
|
+
pyllym.configure(lambda c: (
|
|
30
|
+
setattr(c, "anthropic_api_key", "sk-ant-..."),
|
|
31
|
+
setattr(c, "gemini_api_key", "..."),
|
|
32
|
+
))
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Per-call overrides use a `Context` (isolated config copy):
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
ctx = pyllym.context(lambda c: setattr(c, "request_timeout", 30))
|
|
39
|
+
chat = ctx.create_chat(model="claude-sonnet-4-6")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Structured output (typed responses)
|
|
43
|
+
|
|
44
|
+
Prefer a **Pydantic model** — pass the *class* (not an instance) to
|
|
45
|
+
`with_schema`. The provider is asked for JSON matching the schema, and
|
|
46
|
+
`message.content` comes back as a parsed `dict`; validate it into your model.
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from pydantic import BaseModel
|
|
50
|
+
import pyllym
|
|
51
|
+
|
|
52
|
+
class Recipe(BaseModel):
|
|
53
|
+
title: str
|
|
54
|
+
ingredients: list[str]
|
|
55
|
+
minutes: int
|
|
56
|
+
|
|
57
|
+
chat = pyllym.create_chat(model="gpt-5.4").with_schema(Recipe)
|
|
58
|
+
msg = await chat.ask("Give me a quick pancake recipe")
|
|
59
|
+
recipe = Recipe.model_validate(msg.content) # msg.content is a dict
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- `with_schema` also accepts a raw JSON-Schema `dict` or any object exposing
|
|
63
|
+
`to_json_schema()`.
|
|
64
|
+
- Schemas are sent as strict `json_schema` where the provider supports it. If a
|
|
65
|
+
model can't guarantee JSON, `msg.content` may stay a string — guard with
|
|
66
|
+
`isinstance(msg.content, dict)`.
|
|
67
|
+
- Keep schemas flat and name fields descriptively; add field descriptions via
|
|
68
|
+
Pydantic `Field(description=...)` — they reach the model.
|
|
69
|
+
|
|
70
|
+
## Tools (function calling)
|
|
71
|
+
|
|
72
|
+
Subclass `Tool`; the parameter schema is **inferred from `execute`'s
|
|
73
|
+
keyword-only signature** (or declare it explicitly). `execute` may be sync or
|
|
74
|
+
async. `chat.ask` runs the full agentic loop (model → tool → model → answer).
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from pyllym import Tool
|
|
78
|
+
|
|
79
|
+
class Weather(Tool):
|
|
80
|
+
description = "Look up the current weather for a city"
|
|
81
|
+
|
|
82
|
+
async def execute(self, *, city: str, units: str = "celsius") -> str:
|
|
83
|
+
return f"18°{units[0].upper()} and clear in {city}"
|
|
84
|
+
|
|
85
|
+
chat = pyllym.create_chat(model="gpt-5.4").with_tools(Weather)
|
|
86
|
+
answer = await chat.ask("What's the weather in Oslo?")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- Force/limit tool use: `with_tools(Weather, choice="required", calls="one")`
|
|
90
|
+
(`choice` ∈ `auto|none|required|<tool-name>`; `calls` ∈ `many|one`).
|
|
91
|
+
- Run independent tool calls concurrently: `with_tools(A, B, concurrency=True)`
|
|
92
|
+
(uses `asyncio.gather`).
|
|
93
|
+
- Explicit params instead of signature inference — set a raw JSON-schema class
|
|
94
|
+
attribute, or declare `Parameter`s via the `param` classmethod:
|
|
95
|
+
```python
|
|
96
|
+
class Search(Tool):
|
|
97
|
+
description = "Search the KB"
|
|
98
|
+
_params_schema = { # raw JSON schema wins
|
|
99
|
+
"type": "object",
|
|
100
|
+
"properties": {"query": {"type": "string"}},
|
|
101
|
+
"required": ["query"],
|
|
102
|
+
}
|
|
103
|
+
def execute(self, *, query: str): ...
|
|
104
|
+
|
|
105
|
+
class Lookup(Tool):
|
|
106
|
+
description = "Look up a record"
|
|
107
|
+
Lookup.param("record_id", type="string", description="the id", required=True)
|
|
108
|
+
```
|
|
109
|
+
- Return `pyllym.SearchResults(title=..., url=..., text=...)` from a tool to give
|
|
110
|
+
citation-capable providers citable results.
|
|
111
|
+
|
|
112
|
+
## System instructions, reasoning, params
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
chat = (
|
|
116
|
+
pyllym.create_chat(model="claude-sonnet-4-6")
|
|
117
|
+
.with_instructions("You are a terse assistant. Answer in one sentence.")
|
|
118
|
+
.with_thinking(effort="high") # or budget=2048
|
|
119
|
+
.with_temperature(0.2)
|
|
120
|
+
.with_citations()
|
|
121
|
+
.with_params(top_p=0.9) # provider-passthrough
|
|
122
|
+
)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Compose a reusable configuration as an `Agent`:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
from pyllym import Agent
|
|
129
|
+
|
|
130
|
+
class Analyst(Agent):
|
|
131
|
+
chat_model = "gpt-5.4"
|
|
132
|
+
instructions = "You are a rigorous financial analyst."
|
|
133
|
+
tools = [Weather]
|
|
134
|
+
temperature = 0.1
|
|
135
|
+
|
|
136
|
+
chat = Analyst.create_chat()
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Streaming & multimodal
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
async for chunk in chat.stream("Write a haiku about async"):
|
|
143
|
+
print(chunk.content or "", end="", flush=True)
|
|
144
|
+
|
|
145
|
+
await chat.ask("What's in this image?", with_="diagram.png") # url, path, bytes, or file
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Other capabilities
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
emb = await pyllym.embed("hello") # Embedding(vectors=...)
|
|
152
|
+
img = await pyllym.paint("a red panda", provider="fal", model="fal-ai/flux/dev")
|
|
153
|
+
vid = await pyllym.animate("a timelapse sunrise", model="fal-ai/ltx-video-13b-distilled")
|
|
154
|
+
audio = await pyllym.speak("hello", model="gpt-4o-mini-tts")
|
|
155
|
+
text = await pyllym.transcribe("meeting.wav")
|
|
156
|
+
flags = await pyllym.moderate("some text")
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Including new models
|
|
160
|
+
|
|
161
|
+
The bundled registry (`models.json`) powers `pyllym.models.find(...)`. Three ways
|
|
162
|
+
to use a model that isn't in it yet:
|
|
163
|
+
|
|
164
|
+
1. **assume-exists** — pass the id + provider and skip the registry:
|
|
165
|
+
```python
|
|
166
|
+
await pyllym.create_chat(model="deepseek-r2", provider="deepseek",
|
|
167
|
+
assume_model_exists=True).ask("hi")
|
|
168
|
+
```
|
|
169
|
+
Providers whose catalogs live off-registry set `assumes_models_exist=True`,
|
|
170
|
+
so `assume_model_exists` isn't even needed (e.g. `qwen`, `zhipu`, `moonshot`,
|
|
171
|
+
`nvidia`, `fal`).
|
|
172
|
+
2. **refresh the registry** from providers + models.dev, then persist:
|
|
173
|
+
```python
|
|
174
|
+
await pyllym.models.refresh()
|
|
175
|
+
pyllym.models.save_to_json()
|
|
176
|
+
```
|
|
177
|
+
3. Inspect what's available: `pyllym.models.find("gpt-5.4")`,
|
|
178
|
+
`pyllym.models.chat_models()`, `[m.id for m in pyllym.models.all() if m.provider == "gemini"]`.
|
|
179
|
+
|
|
180
|
+
Never hand-edit `models.json`; it's generated data.
|
|
181
|
+
|
|
182
|
+
## Adding a new provider
|
|
183
|
+
|
|
184
|
+
An OpenAI-compatible provider is ~30 lines. Create
|
|
185
|
+
`src/pyllym/providers/<slug>.py`:
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
from __future__ import annotations
|
|
189
|
+
|
|
190
|
+
from ..protocols.chat_completions import ChatCompletions
|
|
191
|
+
from ..provider import Provider
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class Acme(Provider):
|
|
195
|
+
protocols = {"chat_completions": ChatCompletions}
|
|
196
|
+
default_protocol_name = "chat_completions"
|
|
197
|
+
|
|
198
|
+
@property
|
|
199
|
+
def api_base(self) -> str:
|
|
200
|
+
return self.config.acme_api_base or "https://api.acme.ai/v1"
|
|
201
|
+
|
|
202
|
+
@property
|
|
203
|
+
def headers(self) -> dict[str, str]:
|
|
204
|
+
return {"Authorization": f"Bearer {self.config.acme_api_key}"}
|
|
205
|
+
|
|
206
|
+
@classmethod
|
|
207
|
+
def assumes_models_exist(cls) -> bool: # catalog not in models.json
|
|
208
|
+
return True
|
|
209
|
+
|
|
210
|
+
@classmethod
|
|
211
|
+
def configuration_options(cls) -> list[str]:
|
|
212
|
+
return ["acme_api_key", "acme_api_base"]
|
|
213
|
+
|
|
214
|
+
@classmethod
|
|
215
|
+
def configuration_requirements_list(cls) -> list[str]:
|
|
216
|
+
return ["acme_api_key"]
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Then register it in `src/pyllym/__init__.py` (add `("acme", "Acme")` to the
|
|
220
|
+
`registrations` list). Local providers override `is_local`; providers needing a
|
|
221
|
+
different wire format implement their own protocol under `protocols/` (see
|
|
222
|
+
`anthropic.py`, `gemini.py`, `converse.py`, `fal.py`) instead of reusing
|
|
223
|
+
`ChatCompletions`.
|
|
224
|
+
|
|
225
|
+
Add a test with a seeded factory response (`tests/factories.py`) and mount it
|
|
226
|
+
with `respx` — see `tests/test_provider_matrix.py`.
|
|
227
|
+
|
|
228
|
+
## Gotchas
|
|
229
|
+
|
|
230
|
+
- Everything I/O is `async`; `await` `ask`/`embed`/`paint`/`animate`, and
|
|
231
|
+
`async for` over `stream`.
|
|
232
|
+
- The message-building kwarg is `with_=` (trailing underscore — `with` is a
|
|
233
|
+
Python keyword).
|
|
234
|
+
- `msg.content` is a `dict` only when `with_schema` was set and the model
|
|
235
|
+
returned valid JSON; otherwise it's a `str`.
|
|
236
|
+
- Predicates read as `message.is_tool_call()`, `is_tool_result()`,
|
|
237
|
+
`is_stopped()`.
|
|
238
|
+
- Token usage: `msg.input_tokens` / `msg.output_tokens`; cost via `chat.cost` /
|
|
239
|
+
`msg.cost()`.
|
|
240
|
+
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# pyllym provider credentials — copy to .env and fill in what you use.
|
|
2
|
+
# (pyllym does not auto-load .env; read it yourself, e.g. with python-dotenv,
|
|
3
|
+
# then pass values via pyllym.configure.)
|
|
4
|
+
|
|
5
|
+
# OpenAI
|
|
6
|
+
OPENAI_API_KEY=
|
|
7
|
+
OPENAI_ORGANIZATION_ID=
|
|
8
|
+
OPENAI_PROJECT_ID=
|
|
9
|
+
|
|
10
|
+
# Anthropic
|
|
11
|
+
ANTHROPIC_API_KEY=
|
|
12
|
+
|
|
13
|
+
# Google Gemini
|
|
14
|
+
GEMINI_API_KEY=
|
|
15
|
+
|
|
16
|
+
# DeepSeek / Mistral / xAI / Perplexity / OpenRouter
|
|
17
|
+
DEEPSEEK_API_KEY=
|
|
18
|
+
MISTRAL_API_KEY=
|
|
19
|
+
XAI_API_KEY=
|
|
20
|
+
PERPLEXITY_API_KEY=
|
|
21
|
+
OPENROUTER_API_KEY=
|
|
22
|
+
|
|
23
|
+
# Local
|
|
24
|
+
OLLAMA_API_BASE=http://localhost:11434/v1
|
|
25
|
+
GPUSTACK_API_BASE=
|
|
26
|
+
|
|
27
|
+
# Azure OpenAI
|
|
28
|
+
AZURE_API_BASE=
|
|
29
|
+
AZURE_API_KEY=
|
|
30
|
+
|
|
31
|
+
# AWS Bedrock
|
|
32
|
+
BEDROCK_API_KEY=
|
|
33
|
+
BEDROCK_SECRET_KEY=
|
|
34
|
+
BEDROCK_REGION=us-east-1
|
|
35
|
+
BEDROCK_SESSION_TOKEN=
|
|
36
|
+
|
|
37
|
+
# Vertex AI
|
|
38
|
+
VERTEXAI_PROJECT_ID=
|
|
39
|
+
VERTEXAI_LOCATION=us-central1
|
|
40
|
+
VERTEXAI_ACCESS_TOKEN=
|
|
41
|
+
|
|
42
|
+
# NVIDIA NIM / Cerebras / Hugging Face / Databricks (OpenAI-compatible)
|
|
43
|
+
NVIDIA_API_KEY=
|
|
44
|
+
CEREBRAS_API_KEY=
|
|
45
|
+
HUGGINGFACE_API_KEY=
|
|
46
|
+
DATABRICKS_API_BASE=
|
|
47
|
+
DATABRICKS_API_KEY=
|
|
48
|
+
|
|
49
|
+
# Qwen (DashScope) / Zhipu GLM / Moonshot Kimi / Doubao / ERNIE / MiniMax
|
|
50
|
+
QWEN_API_KEY=
|
|
51
|
+
ZHIPU_API_KEY=
|
|
52
|
+
MOONSHOT_API_KEY=
|
|
53
|
+
DOUBAO_API_KEY=
|
|
54
|
+
ERNIE_API_KEY=
|
|
55
|
+
MINIMAX_API_KEY=
|
|
56
|
+
|
|
57
|
+
# fal.ai (image + video generation)
|
|
58
|
+
FAL_API_KEY=
|