agentmark-prompt-core 0.1.0__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.
- agentmark_prompt_core-0.1.0/.gitignore +70 -0
- agentmark_prompt_core-0.1.0/PKG-INFO +97 -0
- agentmark_prompt_core-0.1.0/README.md +67 -0
- agentmark_prompt_core-0.1.0/package.json +11 -0
- agentmark_prompt_core-0.1.0/pyproject.toml +103 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/__init__.py +144 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/adapters/__init__.py +9 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/adapters/base.py +98 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/adapters/default.py +52 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/agentmark.py +242 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/api_loader.py +183 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/eval_registry.py +7 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/loaders.py +159 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/mcp.py +132 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/prompts/__init__.py +17 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/prompts/base.py +267 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/prompts/image.py +28 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/prompts/object.py +82 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/prompts/speech.py +28 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/prompts/text.py +33 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/py.typed +0 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/sampling.py +320 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/schemas.py +203 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/template_engines/__init__.py +31 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/template_engines/instances.py +243 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/template_engines/templatedx.py +290 -0
- agentmark_prompt_core-0.1.0/src/agentmark/prompt_core/types.py +197 -0
- agentmark_prompt_core-0.1.0/tests/conftest.py +47 -0
- agentmark_prompt_core-0.1.0/tests/fixtures/attachments.prompt.mdx.json +80 -0
- agentmark_prompt_core-0.1.0/tests/fixtures/image.prompt.mdx.json +25 -0
- agentmark_prompt_core-0.1.0/tests/fixtures/math.prompt.mdx.json +57 -0
- agentmark_prompt_core-0.1.0/tests/fixtures/speech.prompt.mdx.json +41 -0
- agentmark_prompt_core-0.1.0/tests/fixtures/text.prompt.mdx.json +57 -0
- agentmark_prompt_core-0.1.0/tests/test_agentmark.py +131 -0
- agentmark_prompt_core-0.1.0/tests/test_api_loader.py +679 -0
- agentmark_prompt_core-0.1.0/tests/test_eval_registry.py +82 -0
- agentmark_prompt_core-0.1.0/tests/test_format_with_dataset.py +273 -0
- agentmark_prompt_core-0.1.0/tests/test_integration.py +366 -0
- agentmark_prompt_core-0.1.0/tests/test_mcp.py +154 -0
- agentmark_prompt_core-0.1.0/tests/test_sampling.py +173 -0
- agentmark_prompt_core-0.1.0/tests/test_schemas.py +263 -0
- agentmark_prompt_core-0.1.0/tests/test_template_engine.py +111 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
*.egg-info/
|
|
24
|
+
.installed.cfg
|
|
25
|
+
*.egg
|
|
26
|
+
|
|
27
|
+
# PyInstaller
|
|
28
|
+
*.manifest
|
|
29
|
+
*.spec
|
|
30
|
+
|
|
31
|
+
# Installer logs
|
|
32
|
+
pip-log.txt
|
|
33
|
+
pip-delete-this-directory.txt
|
|
34
|
+
|
|
35
|
+
# Unit test / coverage reports
|
|
36
|
+
htmlcov/
|
|
37
|
+
.tox/
|
|
38
|
+
.nox/
|
|
39
|
+
.coverage
|
|
40
|
+
.coverage.*
|
|
41
|
+
.cache
|
|
42
|
+
nosetests.xml
|
|
43
|
+
coverage.xml
|
|
44
|
+
*.cover
|
|
45
|
+
*.py,cover
|
|
46
|
+
.hypothesis/
|
|
47
|
+
.pytest_cache/
|
|
48
|
+
|
|
49
|
+
# Environments
|
|
50
|
+
.env
|
|
51
|
+
.venv
|
|
52
|
+
env/
|
|
53
|
+
venv/
|
|
54
|
+
ENV/
|
|
55
|
+
env.bak/
|
|
56
|
+
venv.bak/
|
|
57
|
+
|
|
58
|
+
# mypy
|
|
59
|
+
.mypy_cache/
|
|
60
|
+
.dmypy.json
|
|
61
|
+
dmypy.json
|
|
62
|
+
|
|
63
|
+
# Ruff
|
|
64
|
+
.ruff_cache/
|
|
65
|
+
|
|
66
|
+
# IDE
|
|
67
|
+
.idea/
|
|
68
|
+
.vscode/
|
|
69
|
+
*.swp
|
|
70
|
+
*.swo
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentmark-prompt-core
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python prompt-core package for AgentMark - high-level runtime for working with AgentMark prompts
|
|
5
|
+
Project-URL: Homepage, https://github.com/agentmark/agentmark
|
|
6
|
+
Project-URL: Documentation, https://github.com/agentmark/agentmark#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/agentmark/agentmark
|
|
8
|
+
Author: AgentMark Team
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
Keywords: agentmark,ai,llm,mdx,prompt
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Requires-Dist: httpx>=0.27
|
|
21
|
+
Requires-Dist: pydantic>=2.0
|
|
22
|
+
Requires-Dist: pyyaml>=6.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: mypy>=1.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: ruff>=0.8.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: types-pyyaml>=6.0; extra == 'dev'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# AgentMark Prompt Core (Python)
|
|
32
|
+
|
|
33
|
+
Python implementation of the AgentMark prompt-core package. This package provides the high-level runtime for working with AgentMark prompts.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install agentmark-prompt-core
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
This package transforms pre-parsed MDX AST trees. The AST is typically obtained by:
|
|
44
|
+
- Parsing MDX with the TypeScript `@agentmark-ai/templatedx` package
|
|
45
|
+
- Loading a pre-parsed AST from a JSON file
|
|
46
|
+
- Receiving an AST from the AgentMark runtime
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import asyncio
|
|
50
|
+
import json
|
|
51
|
+
from agentmark.prompt_core import create_agentmark, DefaultAdapter
|
|
52
|
+
|
|
53
|
+
async def main():
|
|
54
|
+
# Create an AgentMark instance with the default adapter
|
|
55
|
+
agentmark = create_agentmark(adapter=DefaultAdapter())
|
|
56
|
+
|
|
57
|
+
# Load a pre-parsed MDX AST (from TypeScript parser or JSON file)
|
|
58
|
+
with open("math.prompt.mdx.json") as f:
|
|
59
|
+
ast = json.load(f)
|
|
60
|
+
|
|
61
|
+
# Load and format a text prompt
|
|
62
|
+
prompt = await agentmark.load_text_prompt(ast)
|
|
63
|
+
result = await prompt.format(props={"userMessage": "What is 2+2?"})
|
|
64
|
+
|
|
65
|
+
print(result)
|
|
66
|
+
|
|
67
|
+
asyncio.run(main())
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Features
|
|
71
|
+
|
|
72
|
+
- **Prompt Types**: Text, Object, Image, and Speech prompts
|
|
73
|
+
- **Message Extraction**: System, User, and Assistant message roles
|
|
74
|
+
- **Attachments**: Image and file attachments in User messages
|
|
75
|
+
- **Schema Validation**: Pydantic-based validation matching TypeScript Zod schemas
|
|
76
|
+
- **Adapters**: Extensible adapter interface for different LLM providers
|
|
77
|
+
- **Eval Registry**: Registry for evaluation functions
|
|
78
|
+
|
|
79
|
+
## Development
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Install dev dependencies
|
|
83
|
+
pip install -e ".[dev]"
|
|
84
|
+
|
|
85
|
+
# Run tests
|
|
86
|
+
pytest
|
|
87
|
+
|
|
88
|
+
# Run linting
|
|
89
|
+
ruff check src tests
|
|
90
|
+
|
|
91
|
+
# Run type checking
|
|
92
|
+
mypy src/agentmark --strict
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
MIT
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# AgentMark Prompt Core (Python)
|
|
2
|
+
|
|
3
|
+
Python implementation of the AgentMark prompt-core package. This package provides the high-level runtime for working with AgentMark prompts.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install agentmark-prompt-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
This package transforms pre-parsed MDX AST trees. The AST is typically obtained by:
|
|
14
|
+
- Parsing MDX with the TypeScript `@agentmark-ai/templatedx` package
|
|
15
|
+
- Loading a pre-parsed AST from a JSON file
|
|
16
|
+
- Receiving an AST from the AgentMark runtime
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
import asyncio
|
|
20
|
+
import json
|
|
21
|
+
from agentmark.prompt_core import create_agentmark, DefaultAdapter
|
|
22
|
+
|
|
23
|
+
async def main():
|
|
24
|
+
# Create an AgentMark instance with the default adapter
|
|
25
|
+
agentmark = create_agentmark(adapter=DefaultAdapter())
|
|
26
|
+
|
|
27
|
+
# Load a pre-parsed MDX AST (from TypeScript parser or JSON file)
|
|
28
|
+
with open("math.prompt.mdx.json") as f:
|
|
29
|
+
ast = json.load(f)
|
|
30
|
+
|
|
31
|
+
# Load and format a text prompt
|
|
32
|
+
prompt = await agentmark.load_text_prompt(ast)
|
|
33
|
+
result = await prompt.format(props={"userMessage": "What is 2+2?"})
|
|
34
|
+
|
|
35
|
+
print(result)
|
|
36
|
+
|
|
37
|
+
asyncio.run(main())
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- **Prompt Types**: Text, Object, Image, and Speech prompts
|
|
43
|
+
- **Message Extraction**: System, User, and Assistant message roles
|
|
44
|
+
- **Attachments**: Image and file attachments in User messages
|
|
45
|
+
- **Schema Validation**: Pydantic-based validation matching TypeScript Zod schemas
|
|
46
|
+
- **Adapters**: Extensible adapter interface for different LLM providers
|
|
47
|
+
- **Eval Registry**: Registry for evaluation functions
|
|
48
|
+
|
|
49
|
+
## Development
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Install dev dependencies
|
|
53
|
+
pip install -e ".[dev]"
|
|
54
|
+
|
|
55
|
+
# Run tests
|
|
56
|
+
pytest
|
|
57
|
+
|
|
58
|
+
# Run linting
|
|
59
|
+
ruff check src tests
|
|
60
|
+
|
|
61
|
+
# Run type checking
|
|
62
|
+
mypy src/agentmark --strict
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
MIT
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentmark-ai/prompt-core-python",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"postinstall": "node ../../scripts/setup-python-venv.js -e ../templatedx-python -e \".[dev]\"",
|
|
7
|
+
"test": "node ../../scripts/run-venv.js pytest tests/",
|
|
8
|
+
"lint": "node ../../scripts/run-venv.js ruff check src/ tests/ && node ../../scripts/run-venv.js mypy src --strict",
|
|
9
|
+
"lint:fix": "node ../../scripts/run-venv.js ruff check --fix src/ tests/"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "agentmark-prompt-core"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python prompt-core package for AgentMark - high-level runtime for working with AgentMark prompts"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.12"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "AgentMark Team" }
|
|
14
|
+
]
|
|
15
|
+
keywords = ["agentmark", "prompt", "llm", "ai", "mdx"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
24
|
+
"Typing :: Typed",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"httpx>=0.27",
|
|
28
|
+
"pydantic>=2.0",
|
|
29
|
+
"pyyaml>=6.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
dev = [
|
|
34
|
+
"pytest>=7.0",
|
|
35
|
+
"pytest-asyncio>=0.21",
|
|
36
|
+
"ruff>=0.8.0",
|
|
37
|
+
"mypy>=1.0",
|
|
38
|
+
"types-PyYAML>=6.0",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://github.com/agentmark/agentmark"
|
|
43
|
+
Documentation = "https://github.com/agentmark/agentmark#readme"
|
|
44
|
+
Repository = "https://github.com/agentmark/agentmark"
|
|
45
|
+
|
|
46
|
+
[tool.hatch.build.targets.wheel]
|
|
47
|
+
packages = ["src/agentmark"]
|
|
48
|
+
|
|
49
|
+
[tool.ruff]
|
|
50
|
+
target-version = "py312"
|
|
51
|
+
line-length = 100
|
|
52
|
+
|
|
53
|
+
[tool.ruff.lint]
|
|
54
|
+
select = [
|
|
55
|
+
"E", # pycodestyle errors
|
|
56
|
+
"W", # pycodestyle warnings
|
|
57
|
+
"F", # Pyflakes
|
|
58
|
+
"I", # isort
|
|
59
|
+
"B", # flake8-bugbear
|
|
60
|
+
"C4", # flake8-comprehensions
|
|
61
|
+
"UP", # pyupgrade
|
|
62
|
+
"ARG", # flake8-unused-arguments
|
|
63
|
+
"SIM", # flake8-simplify
|
|
64
|
+
]
|
|
65
|
+
ignore = [
|
|
66
|
+
"E501", # line too long (handled by formatter)
|
|
67
|
+
"B008", # do not perform function calls in argument defaults
|
|
68
|
+
"B905", # zip without explicit strict parameter
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
[tool.ruff.lint.isort]
|
|
72
|
+
known-first-party = ["agentmark", "templatedx"]
|
|
73
|
+
|
|
74
|
+
[tool.ruff.lint.per-file-ignores]
|
|
75
|
+
"tests/**/*.py" = ["ARG001", "ARG002", "ARG005"] # Allow unused args in test mocks/fixtures
|
|
76
|
+
|
|
77
|
+
[tool.mypy]
|
|
78
|
+
python_version = "3.12"
|
|
79
|
+
strict = true
|
|
80
|
+
warn_return_any = true
|
|
81
|
+
warn_unused_configs = true
|
|
82
|
+
disallow_untyped_defs = true
|
|
83
|
+
disallow_incomplete_defs = true
|
|
84
|
+
check_untyped_defs = true
|
|
85
|
+
disallow_untyped_decorators = true
|
|
86
|
+
no_implicit_optional = true
|
|
87
|
+
warn_redundant_casts = true
|
|
88
|
+
warn_unused_ignores = true
|
|
89
|
+
warn_no_return = true
|
|
90
|
+
follow_imports = "normal"
|
|
91
|
+
ignore_missing_imports = false
|
|
92
|
+
|
|
93
|
+
[[tool.mypy.overrides]]
|
|
94
|
+
module = "yaml"
|
|
95
|
+
ignore_missing_imports = true
|
|
96
|
+
|
|
97
|
+
[tool.pytest.ini_options]
|
|
98
|
+
asyncio_mode = "auto"
|
|
99
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
100
|
+
testpaths = ["tests"]
|
|
101
|
+
python_files = ["test_*.py"]
|
|
102
|
+
python_functions = ["test_*"]
|
|
103
|
+
addopts = "-v --tb=short"
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"""AgentMark Prompt Core - Python implementation."""
|
|
2
|
+
|
|
3
|
+
from .adapters import Adapter, DefaultAdapter
|
|
4
|
+
from .agentmark import AgentMark, create_agentmark
|
|
5
|
+
from .eval_registry import EvalRegistry
|
|
6
|
+
from .api_loader import ApiDatasetReader, ApiDatasetStream, ApiLoader
|
|
7
|
+
from .loaders import FileDatasetReader, FileDatasetStream, FileLoader
|
|
8
|
+
from .mcp import (
|
|
9
|
+
McpServerConfig,
|
|
10
|
+
McpServers,
|
|
11
|
+
McpStdioServerConfig,
|
|
12
|
+
McpUrlServerConfig,
|
|
13
|
+
NormalizedTool,
|
|
14
|
+
interpolate_env_in_object,
|
|
15
|
+
normalize_tools_list,
|
|
16
|
+
parse_mcp_uri,
|
|
17
|
+
)
|
|
18
|
+
from .prompts import (
|
|
19
|
+
BasePrompt,
|
|
20
|
+
ImagePrompt,
|
|
21
|
+
ObjectPrompt,
|
|
22
|
+
SimpleDatasetReader,
|
|
23
|
+
SimpleDatasetStream,
|
|
24
|
+
SpeechPrompt,
|
|
25
|
+
TextPrompt,
|
|
26
|
+
)
|
|
27
|
+
from .schemas import (
|
|
28
|
+
AgentmarkConfigSchema,
|
|
29
|
+
ImageConfigSchema,
|
|
30
|
+
ImageSettingsSchema,
|
|
31
|
+
ObjectConfigSchema,
|
|
32
|
+
ObjectSettingsSchema,
|
|
33
|
+
SpeechConfigSchema,
|
|
34
|
+
SpeechSettingsSchema,
|
|
35
|
+
TestSettingsSchema,
|
|
36
|
+
TextConfigSchema,
|
|
37
|
+
TextSettingsSchema,
|
|
38
|
+
)
|
|
39
|
+
from .template_engines import TemplateDXTemplateEngine, get_front_matter
|
|
40
|
+
from .types import (
|
|
41
|
+
AdaptOptions,
|
|
42
|
+
ChatMessage,
|
|
43
|
+
ContentPart,
|
|
44
|
+
DatasetErrorChunk,
|
|
45
|
+
DatasetItem,
|
|
46
|
+
DatasetReader,
|
|
47
|
+
DatasetStream,
|
|
48
|
+
DatasetStreamChunk,
|
|
49
|
+
EvalFunction,
|
|
50
|
+
EvalParams,
|
|
51
|
+
EvalResult,
|
|
52
|
+
FilePart,
|
|
53
|
+
FormatWithDatasetOptions,
|
|
54
|
+
ImagePart,
|
|
55
|
+
JSONObject,
|
|
56
|
+
JSONPrimitive,
|
|
57
|
+
JSONValue,
|
|
58
|
+
Loader,
|
|
59
|
+
PromptKind,
|
|
60
|
+
PromptMetadata,
|
|
61
|
+
RichChatMessage,
|
|
62
|
+
TelemetryOptions,
|
|
63
|
+
TemplateEngine,
|
|
64
|
+
TestSettings,
|
|
65
|
+
TextPart,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
__all__ = [
|
|
69
|
+
# Main classes
|
|
70
|
+
"AgentMark",
|
|
71
|
+
"create_agentmark",
|
|
72
|
+
# Adapters
|
|
73
|
+
"Adapter",
|
|
74
|
+
"DefaultAdapter",
|
|
75
|
+
# Prompts
|
|
76
|
+
"BasePrompt",
|
|
77
|
+
"TextPrompt",
|
|
78
|
+
"ObjectPrompt",
|
|
79
|
+
"ImagePrompt",
|
|
80
|
+
"SpeechPrompt",
|
|
81
|
+
"SimpleDatasetStream",
|
|
82
|
+
"SimpleDatasetReader",
|
|
83
|
+
# Registries
|
|
84
|
+
"EvalRegistry",
|
|
85
|
+
# Loaders
|
|
86
|
+
"ApiLoader",
|
|
87
|
+
"ApiDatasetStream",
|
|
88
|
+
"ApiDatasetReader",
|
|
89
|
+
"FileLoader",
|
|
90
|
+
"FileDatasetStream",
|
|
91
|
+
"FileDatasetReader",
|
|
92
|
+
# Template engines
|
|
93
|
+
"TemplateDXTemplateEngine",
|
|
94
|
+
"get_front_matter",
|
|
95
|
+
# Schemas
|
|
96
|
+
"TextConfigSchema",
|
|
97
|
+
"ObjectConfigSchema",
|
|
98
|
+
"ImageConfigSchema",
|
|
99
|
+
"SpeechConfigSchema",
|
|
100
|
+
"AgentmarkConfigSchema",
|
|
101
|
+
"TextSettingsSchema",
|
|
102
|
+
"ObjectSettingsSchema",
|
|
103
|
+
"ImageSettingsSchema",
|
|
104
|
+
"SpeechSettingsSchema",
|
|
105
|
+
"TestSettingsSchema",
|
|
106
|
+
# Types
|
|
107
|
+
"JSONPrimitive",
|
|
108
|
+
"JSONValue",
|
|
109
|
+
"JSONObject",
|
|
110
|
+
"PromptKind",
|
|
111
|
+
"TextPart",
|
|
112
|
+
"ImagePart",
|
|
113
|
+
"FilePart",
|
|
114
|
+
"ContentPart",
|
|
115
|
+
"ChatMessage",
|
|
116
|
+
"RichChatMessage",
|
|
117
|
+
"TelemetryOptions",
|
|
118
|
+
"AdaptOptions",
|
|
119
|
+
"PromptMetadata",
|
|
120
|
+
"EvalParams",
|
|
121
|
+
"EvalResult",
|
|
122
|
+
"EvalFunction",
|
|
123
|
+
"TestSettings",
|
|
124
|
+
"Loader",
|
|
125
|
+
"TemplateEngine",
|
|
126
|
+
# Dataset types
|
|
127
|
+
"DatasetItem",
|
|
128
|
+
"DatasetStreamChunk",
|
|
129
|
+
"DatasetErrorChunk",
|
|
130
|
+
"FormatWithDatasetOptions",
|
|
131
|
+
"DatasetReader",
|
|
132
|
+
"DatasetStream",
|
|
133
|
+
# MCP utilities
|
|
134
|
+
"parse_mcp_uri",
|
|
135
|
+
"interpolate_env_in_object",
|
|
136
|
+
"normalize_tools_list",
|
|
137
|
+
"McpUrlServerConfig",
|
|
138
|
+
"McpStdioServerConfig",
|
|
139
|
+
"McpServerConfig",
|
|
140
|
+
"McpServers",
|
|
141
|
+
"NormalizedTool",
|
|
142
|
+
]
|
|
143
|
+
|
|
144
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""Adapter protocol definition.
|
|
2
|
+
|
|
3
|
+
prompt-core passes compiled Pydantic config schemas directly to adapters,
|
|
4
|
+
matching the TypeScript pattern where compiled objects are passed as-is.
|
|
5
|
+
Each adapter handles its own serialization if needed.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import Any, Protocol
|
|
9
|
+
|
|
10
|
+
from ..schemas import (
|
|
11
|
+
ImageConfigSchema,
|
|
12
|
+
ObjectConfigSchema,
|
|
13
|
+
SpeechConfigSchema,
|
|
14
|
+
TextConfigSchema,
|
|
15
|
+
)
|
|
16
|
+
from ..types import AdaptOptions, PromptMetadata
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Adapter(Protocol):
|
|
20
|
+
"""Protocol defining the adapter interface for LLM providers.
|
|
21
|
+
|
|
22
|
+
Config parameters are Pydantic schema objects compiled by the template
|
|
23
|
+
engine. Adapters that need dict access should call config.model_dump()
|
|
24
|
+
internally.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def name(self) -> str:
|
|
29
|
+
"""Adapter name identifier."""
|
|
30
|
+
...
|
|
31
|
+
|
|
32
|
+
def adapt_text(
|
|
33
|
+
self,
|
|
34
|
+
config: TextConfigSchema,
|
|
35
|
+
options: AdaptOptions,
|
|
36
|
+
metadata: PromptMetadata,
|
|
37
|
+
) -> Any:
|
|
38
|
+
"""Adapt a text prompt config for the provider.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
config: Text prompt configuration (Pydantic model).
|
|
42
|
+
options: Adapter options
|
|
43
|
+
metadata: Prompt metadata
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
Provider-specific format
|
|
47
|
+
"""
|
|
48
|
+
...
|
|
49
|
+
|
|
50
|
+
def adapt_object(
|
|
51
|
+
self,
|
|
52
|
+
config: ObjectConfigSchema,
|
|
53
|
+
options: AdaptOptions,
|
|
54
|
+
metadata: PromptMetadata,
|
|
55
|
+
) -> Any:
|
|
56
|
+
"""Adapt an object prompt config for the provider.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
config: Object prompt configuration (Pydantic model).
|
|
60
|
+
options: Adapter options
|
|
61
|
+
metadata: Prompt metadata
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
Provider-specific format
|
|
65
|
+
"""
|
|
66
|
+
...
|
|
67
|
+
|
|
68
|
+
def adapt_image(
|
|
69
|
+
self,
|
|
70
|
+
config: ImageConfigSchema,
|
|
71
|
+
options: AdaptOptions,
|
|
72
|
+
) -> Any:
|
|
73
|
+
"""Adapt an image prompt config for the provider.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
config: Image prompt configuration (Pydantic model).
|
|
77
|
+
options: Adapter options
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
Provider-specific format
|
|
81
|
+
"""
|
|
82
|
+
...
|
|
83
|
+
|
|
84
|
+
def adapt_speech(
|
|
85
|
+
self,
|
|
86
|
+
config: SpeechConfigSchema,
|
|
87
|
+
options: AdaptOptions,
|
|
88
|
+
) -> Any:
|
|
89
|
+
"""Adapt a speech prompt config for the provider.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
config: Speech prompt configuration (Pydantic model).
|
|
93
|
+
options: Adapter options
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
Provider-specific format
|
|
97
|
+
"""
|
|
98
|
+
...
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Default passthrough adapter."""
|
|
2
|
+
|
|
3
|
+
from ..schemas import (
|
|
4
|
+
ImageConfigSchema,
|
|
5
|
+
ObjectConfigSchema,
|
|
6
|
+
SpeechConfigSchema,
|
|
7
|
+
TextConfigSchema,
|
|
8
|
+
)
|
|
9
|
+
from ..types import AdaptOptions, PromptMetadata
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class DefaultAdapter:
|
|
13
|
+
"""Default passthrough adapter that returns configs unchanged."""
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def name(self) -> str:
|
|
17
|
+
"""Adapter name identifier."""
|
|
18
|
+
return "default"
|
|
19
|
+
|
|
20
|
+
def adapt_text(
|
|
21
|
+
self,
|
|
22
|
+
config: TextConfigSchema,
|
|
23
|
+
_options: AdaptOptions,
|
|
24
|
+
_metadata: PromptMetadata,
|
|
25
|
+
) -> TextConfigSchema:
|
|
26
|
+
"""Return text config unchanged."""
|
|
27
|
+
return config
|
|
28
|
+
|
|
29
|
+
def adapt_object(
|
|
30
|
+
self,
|
|
31
|
+
config: ObjectConfigSchema,
|
|
32
|
+
_options: AdaptOptions,
|
|
33
|
+
_metadata: PromptMetadata,
|
|
34
|
+
) -> ObjectConfigSchema:
|
|
35
|
+
"""Return object config unchanged."""
|
|
36
|
+
return config
|
|
37
|
+
|
|
38
|
+
def adapt_image(
|
|
39
|
+
self,
|
|
40
|
+
config: ImageConfigSchema,
|
|
41
|
+
_options: AdaptOptions,
|
|
42
|
+
) -> ImageConfigSchema:
|
|
43
|
+
"""Return image config unchanged."""
|
|
44
|
+
return config
|
|
45
|
+
|
|
46
|
+
def adapt_speech(
|
|
47
|
+
self,
|
|
48
|
+
config: SpeechConfigSchema,
|
|
49
|
+
_options: AdaptOptions,
|
|
50
|
+
) -> SpeechConfigSchema:
|
|
51
|
+
"""Return speech config unchanged."""
|
|
52
|
+
return config
|