verbai 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.
- verbai-0.1.0/LICENSE +201 -0
- verbai-0.1.0/PKG-INFO +441 -0
- verbai-0.1.0/README.md +411 -0
- verbai-0.1.0/pyproject.toml +61 -0
- verbai-0.1.0/setup.cfg +4 -0
- verbai-0.1.0/src/verbai/__init__.py +36 -0
- verbai-0.1.0/src/verbai/__main__.py +26 -0
- verbai-0.1.0/src/verbai/ast_nodes.py +313 -0
- verbai-0.1.0/src/verbai/cli.py +139 -0
- verbai-0.1.0/src/verbai/examples/01_hello.verbai +1 -0
- verbai-0.1.0/src/verbai/examples/02_constants.verbai +6 -0
- verbai-0.1.0/src/verbai/examples/03_variables.verbai +13 -0
- verbai-0.1.0/src/verbai/examples/04_expressions.verbai +8 -0
- verbai-0.1.0/src/verbai/examples/05_types.verbai +11 -0
- verbai-0.1.0/src/verbai/examples/06_conditionals.verbai +14 -0
- verbai-0.1.0/src/verbai/examples/07_loops.verbai +2 -0
- verbai-0.1.0/src/verbai/examples/08_functions.verbai +6 -0
- verbai-0.1.0/src/verbai/examples/09_recursion.verbai +12 -0
- verbai-0.1.0/src/verbai/examples/10_lists.verbai +9 -0
- verbai-0.1.0/src/verbai/examples/11_objects.verbai +11 -0
- verbai-0.1.0/src/verbai/examples/12_errors.verbai +20 -0
- verbai-0.1.0/src/verbai/examples/13_first_inference.verbai +5 -0
- verbai-0.1.0/src/verbai/examples/14_minimax_pong.verbai +6 -0
- verbai-0.1.0/src/verbai/format.py +47 -0
- verbai-0.1.0/src/verbai/interpreter.py +538 -0
- verbai-0.1.0/src/verbai/lexer.py +318 -0
- verbai-0.1.0/src/verbai/parser.py +832 -0
- verbai-0.1.0/src/verbai/providers/__init__.py +97 -0
- verbai-0.1.0/src/verbai/providers/base.py +9 -0
- verbai-0.1.0/src/verbai/providers/minimax.py +139 -0
- verbai-0.1.0/src/verbai/providers/mock.py +63 -0
- verbai-0.1.0/src/verbai/runtime.py +485 -0
- verbai-0.1.0/src/verbai/source.py +98 -0
- verbai-0.1.0/src/verbai/stdlib.py +308 -0
- verbai-0.1.0/src/verbai/symbol_table.py +97 -0
- verbai-0.1.0/src/verbai.egg-info/PKG-INFO +441 -0
- verbai-0.1.0/src/verbai.egg-info/SOURCES.txt +49 -0
- verbai-0.1.0/src/verbai.egg-info/dependency_links.txt +1 -0
- verbai-0.1.0/src/verbai.egg-info/entry_points.txt +2 -0
- verbai-0.1.0/src/verbai.egg-info/requires.txt +12 -0
- verbai-0.1.0/src/verbai.egg-info/top_level.txt +1 -0
- verbai-0.1.0/tests/test_cli.py +127 -0
- verbai-0.1.0/tests/test_examples.py +87 -0
- verbai-0.1.0/tests/test_interpreter.py +207 -0
- verbai-0.1.0/tests/test_lexer.py +217 -0
- verbai-0.1.0/tests/test_minimax_provider.py +197 -0
- verbai-0.1.0/tests/test_parser.py +516 -0
- verbai-0.1.0/tests/test_providers.py +88 -0
- verbai-0.1.0/tests/test_runtime_values.py +106 -0
- verbai-0.1.0/tests/test_stdlib.py +244 -0
- verbai-0.1.0/tests/test_symbol_table.py +74 -0
verbai-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of tracking, managing, or otherwise handling
|
|
59
|
+
the Work, but excludes communication that is conspicuously marked or
|
|
60
|
+
otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file name and extension be included on the same line as the
|
|
186
|
+
copyright notice for ease of identification within third-party
|
|
187
|
+
archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Gerald Enrique Nelson Mc Kenzie
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
verbai-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: verbai
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Haskell-flavored DSL for AI model orchestration.
|
|
5
|
+
Author-email: Gerald Enrique Nelson Mc Kenzie <lordxmen2k@gmail.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/lordxmen2k/verbai
|
|
8
|
+
Project-URL: Repository, https://github.com/lordxmen2k/verbai
|
|
9
|
+
Keywords: dsl,ai,llm,orchestration,haskell
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Software Development :: Interpreters
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Provides-Extra: ollama
|
|
24
|
+
Provides-Extra: openai
|
|
25
|
+
Provides-Extra: anthropic
|
|
26
|
+
Provides-Extra: cloud
|
|
27
|
+
Provides-Extra: local
|
|
28
|
+
Provides-Extra: all
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# verbai
|
|
32
|
+
|
|
33
|
+
> **Visibly Enhanced Reasoning Blocks for AI.**
|
|
34
|
+
> A Haskell-flavored DSL for AI model orchestration.
|
|
35
|
+
|
|
36
|
+
verbai is a scripting language and PyPI package for composing and orchestrating AI model calls — local and cloud, text and multi-modal. It is text-based, has a hybrid syntax (declarative tasks + procedural body), and treats every integration as a pluggable provider: Ollama, OpenAI, Anthropic, Gemini, Mistral, xAI, DeepSeek, Cohere, HuggingFace, OpenRouter, AWS Bedrock, Azure OpenAI, Vertex AI, Groq, Together.ai, Fireworks.ai, Replicate, MiniMax, MCP servers, HTTP APIs, webhooks, WebSockets, and more.
|
|
37
|
+
|
|
38
|
+
## Status
|
|
39
|
+
|
|
40
|
+
🚧 **Pre-alpha.** v0.1 is being built. The full language design spec is at [`docs/specs/2026-10-01-verbai-language-design.md`](https://github.com/lordxmen2k/verbai/blob/main/docs/specs/2026-10-01-verbai-language-design.md). The language core, parser, interpreter, stdlib, and **14 example programs that you can run cold-start** all ship in the package.
|
|
41
|
+
|
|
42
|
+
## Quickstart
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install verbai
|
|
46
|
+
verbai run examples/01_hello.verbai
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
You should see:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
hello, world
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The `examples/` directory comes bundled inside the wheel, so `pip install verbai` is enough — no extra `git clone` needed.
|
|
56
|
+
|
|
57
|
+
## A taste of verbai
|
|
58
|
+
|
|
59
|
+
The smallest possible script:
|
|
60
|
+
|
|
61
|
+
```verbai
|
|
62
|
+
-- hello.verbai
|
|
63
|
+
Print "hello, world"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
A recursive factorial:
|
|
67
|
+
|
|
68
|
+
```verbai
|
|
69
|
+
let factorial n =
|
|
70
|
+
if n <= 1 then
|
|
71
|
+
1
|
|
72
|
+
else
|
|
73
|
+
n * (factorial (n - 1))
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
Print (factorial 10)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
A real model call against MiniMax's hosted M3:
|
|
80
|
+
|
|
81
|
+
```verbai
|
|
82
|
+
do
|
|
83
|
+
reply <- Run { provider = "minimax" ; model = "MiniMax-M3" ; input = "Say hi in 5 words or fewer." }
|
|
84
|
+
Print reply
|
|
85
|
+
end
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## CLI
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
verbai --version # print version
|
|
92
|
+
verbai run <file.verbai> # execute a script
|
|
93
|
+
verbai check <file.verbai> # parse + structurally check, no execution
|
|
94
|
+
verbai fmt <file.verbai> # format to stdout
|
|
95
|
+
verbai fmt <file.verbai> --write # rewrite the file in place
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Exit codes: `0` success, `1` runtime error or missing file, `2` parse error.
|
|
99
|
+
|
|
100
|
+
## Installation
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
pip install verbai # base (Mock provider only)
|
|
104
|
+
pip install verbai[cloud] # + MiniMax (more providers in v0.2)
|
|
105
|
+
pip install verbai[local] # + every local runtime (v0.2)
|
|
106
|
+
pip install verbai[all] # everything
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The provider ABC + registry are stable, so adding a new provider is a single `register_provider(MyProvider())` call.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## The example programs
|
|
114
|
+
|
|
115
|
+
> All 14 example scripts ship inside the installed `examples/` directory. Each one is self-contained — copy-paste the body into a `.verbai` file on your machine and run it.
|
|
116
|
+
|
|
117
|
+
### 01 `01_hello.verbai`
|
|
118
|
+
|
|
119
|
+
```verbai
|
|
120
|
+
Print "hello, world"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Run it:
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
$ verbai run examples/01_hello.verbai
|
|
127
|
+
hello, world
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 02 `02_constants.verbai`
|
|
131
|
+
|
|
132
|
+
```verbai
|
|
133
|
+
let PI = 3.14
|
|
134
|
+
let NAME = "verbai"
|
|
135
|
+
let MAX_TOKENS = 4096
|
|
136
|
+
Print PI
|
|
137
|
+
Print NAME
|
|
138
|
+
Print MAX_TOKENS
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
$ verbai run examples/02_constants.verbai
|
|
143
|
+
3.14
|
|
144
|
+
verbai
|
|
145
|
+
4096
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 03 `03_variables.verbai`
|
|
149
|
+
|
|
150
|
+
```verbai
|
|
151
|
+
-- 03_variables.verbai
|
|
152
|
+
-- `let` at module scope is an immutable binding.
|
|
153
|
+
-- Inside a `do` block, `<-` shadows with a local value.
|
|
154
|
+
|
|
155
|
+
let global = 100
|
|
156
|
+
|
|
157
|
+
do
|
|
158
|
+
local <- 50
|
|
159
|
+
Print (global + local)
|
|
160
|
+
Print local
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
Print global
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
$ verbai run examples/03_variables.verbai
|
|
168
|
+
150
|
|
169
|
+
50
|
|
170
|
+
100
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 04 `04_expressions.verbai`
|
|
174
|
+
|
|
175
|
+
```verbai
|
|
176
|
+
-- 04_expressions.verbai
|
|
177
|
+
Print (1 + 2 * 3)
|
|
178
|
+
Print ((1 + 2) * 3)
|
|
179
|
+
Print (10 - 4)
|
|
180
|
+
Print (10 / 3)
|
|
181
|
+
Print ("Hello, " + "world!")
|
|
182
|
+
Print (5 == 5)
|
|
183
|
+
Print (5 < 10)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
$ verbai run examples/04_expressions.verbai
|
|
188
|
+
7
|
|
189
|
+
9
|
|
190
|
+
6
|
|
191
|
+
3.3333333333333335
|
|
192
|
+
Hello, world!
|
|
193
|
+
True
|
|
194
|
+
True
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
> **Important:** verbai calls are explicit-paren'd. `Print (10 - 4)` is unambiguous; `Print 10 - 4` parses as `Print(10) - 4` and fails at runtime. Wrap binary expressions in parens.
|
|
198
|
+
|
|
199
|
+
### 05 `05_types.verbai`
|
|
200
|
+
|
|
201
|
+
```verbai
|
|
202
|
+
-- 05_types.verbai
|
|
203
|
+
-- Primitive types and how they print.
|
|
204
|
+
|
|
205
|
+
Print 42 -- Int
|
|
206
|
+
Print 3.14 -- Float
|
|
207
|
+
Print "hello" -- Text
|
|
208
|
+
Print True -- Bool
|
|
209
|
+
Print False -- Bool
|
|
210
|
+
Print nil -- Nil
|
|
211
|
+
Print ([1, 2, 3]) -- List of Int
|
|
212
|
+
Print ({ name = "verbai" ; version = 0 }) -- Object
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
$ verbai run examples/05_types.verbai
|
|
217
|
+
42
|
|
218
|
+
3.14
|
|
219
|
+
hello
|
|
220
|
+
True
|
|
221
|
+
False
|
|
222
|
+
Nil
|
|
223
|
+
[1, 2, 3]
|
|
224
|
+
{name = verbai, version = 0}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
> Object literals use **semicolon** between entries; commas are for lists. To pass a list or object as a single argument, wrap it in parens.
|
|
228
|
+
|
|
229
|
+
### 06 `06_conditionals.verbai`
|
|
230
|
+
|
|
231
|
+
```verbai
|
|
232
|
+
-- 06_conditionals.verbai
|
|
233
|
+
let x = 5
|
|
234
|
+
if x > 0 then
|
|
235
|
+
Print "positive"
|
|
236
|
+
else
|
|
237
|
+
Print "non-positive"
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
let y = -3
|
|
241
|
+
if y > 0 then
|
|
242
|
+
Print "positive"
|
|
243
|
+
else
|
|
244
|
+
Print "non-positive"
|
|
245
|
+
end
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
```
|
|
249
|
+
$ verbai run examples/06_conditionals.verbai
|
|
250
|
+
positive
|
|
251
|
+
non-positive
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### 07 `07_loops.verbai`
|
|
255
|
+
|
|
256
|
+
```verbai
|
|
257
|
+
-- 07_loops.verbai
|
|
258
|
+
ForEach [1, 2, 3, 4, 5] (x -> Print x)
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
```
|
|
262
|
+
$ verbai run examples/07_loops.verbai
|
|
263
|
+
1
|
|
264
|
+
2
|
|
265
|
+
3
|
|
266
|
+
4
|
|
267
|
+
5
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### 08 `08_functions.verbai`
|
|
271
|
+
|
|
272
|
+
```verbai
|
|
273
|
+
-- 08_functions.verbai
|
|
274
|
+
let double x = x * 2
|
|
275
|
+
let add3 a b c = a + b + c
|
|
276
|
+
|
|
277
|
+
Print (double 21)
|
|
278
|
+
Print (add3 1 2 3)
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
```
|
|
282
|
+
$ verbai run examples/08_functions.verbai
|
|
283
|
+
42
|
|
284
|
+
6
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### 09 `09_recursion.verbai`
|
|
288
|
+
|
|
289
|
+
```verbai
|
|
290
|
+
-- 09_recursion.verbai
|
|
291
|
+
let factorial n =
|
|
292
|
+
if n <= 1 then
|
|
293
|
+
1
|
|
294
|
+
else
|
|
295
|
+
n * (factorial (n - 1))
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
Print (factorial 5)
|
|
299
|
+
Print (factorial 10)
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
```
|
|
303
|
+
$ verbai run examples/09_recursion.verbai
|
|
304
|
+
120
|
|
305
|
+
3628800
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### 10 `10_lists.verbai`
|
|
309
|
+
|
|
310
|
+
```verbai
|
|
311
|
+
-- 10_lists.verbai
|
|
312
|
+
let xs = [10, 20, 30, 40]
|
|
313
|
+
Print xs
|
|
314
|
+
Print (xs[0])
|
|
315
|
+
Print (xs[2])
|
|
316
|
+
|
|
317
|
+
ForEach xs (x -> Print (x * 2))
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
```
|
|
321
|
+
$ verbai run examples/10_lists.verbai
|
|
322
|
+
[10, 20, 30, 40]
|
|
323
|
+
10
|
|
324
|
+
30
|
|
325
|
+
20
|
|
326
|
+
40
|
|
327
|
+
60
|
|
328
|
+
80
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### 11 `11_objects.verbai`
|
|
332
|
+
|
|
333
|
+
```verbai
|
|
334
|
+
-- 11_objects.verbai
|
|
335
|
+
let config = { host = "api.example.com" ; port = 443 ; retries = 3 }
|
|
336
|
+
Print config.host
|
|
337
|
+
Print config.port
|
|
338
|
+
|
|
339
|
+
do
|
|
340
|
+
msg <- Run { provider = "mock" ; model = "echo" ; input = "ping" }
|
|
341
|
+
Print msg
|
|
342
|
+
end
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
```
|
|
346
|
+
$ verbai run examples/11_objects.verbai
|
|
347
|
+
api.example.com
|
|
348
|
+
443
|
|
349
|
+
echo: 'ping'
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### 12 `12_errors.verbai`
|
|
353
|
+
|
|
354
|
+
```verbai
|
|
355
|
+
-- 12_errors.verbai
|
|
356
|
+
do
|
|
357
|
+
out <- try
|
|
358
|
+
do
|
|
359
|
+
x <- Run { provider = "mock" ; model = "fail-once" ; input = "boom" }
|
|
360
|
+
Print x
|
|
361
|
+
end
|
|
362
|
+
catch err ->
|
|
363
|
+
Print "recovered from error"
|
|
364
|
+
end
|
|
365
|
+
Print out
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
do
|
|
369
|
+
msg <- Run { provider = "mock" ; model = "echo" ; input = "hello" }
|
|
370
|
+
Print msg
|
|
371
|
+
end
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
```
|
|
375
|
+
$ verbai run examples/12_errors.verbai
|
|
376
|
+
fail-once: 'boom'
|
|
377
|
+
Nil
|
|
378
|
+
echo: 'hello'
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
> The `try ... catch err -> ... end` form binds the error to `err` and runs the catch body. Use `_` instead of `err` if you don't need the error value. The `err` binding also works as a kind filter (`catch DivisionByZeroError -> ...`).
|
|
382
|
+
|
|
383
|
+
### 13 `13_first_inference.verbai`
|
|
384
|
+
|
|
385
|
+
```verbai
|
|
386
|
+
-- 13_first_inference.verbai
|
|
387
|
+
do
|
|
388
|
+
result <- Run { provider = "mock" ; model = "echo" ; input = "hi" }
|
|
389
|
+
Print result
|
|
390
|
+
end
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
```
|
|
394
|
+
$ verbai run examples/13_first_inference.verbai
|
|
395
|
+
echo: 'hi'
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### 14 `14_minimax_pong.verbai` *(requires real API key)*
|
|
399
|
+
|
|
400
|
+
```verbai
|
|
401
|
+
-- 14_minimax_pong.verbai
|
|
402
|
+
do
|
|
403
|
+
reply <- Run { provider = "minimax" ; model = "MiniMax-M3" ; input = "Reply with exactly one short sentence." }
|
|
404
|
+
Print reply
|
|
405
|
+
end
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
This one hits the real network:
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
export MINIMAX_API_KEY=sk-cp-...
|
|
412
|
+
verbai run examples/14_minimax_pong.verbai
|
|
413
|
+
unset MINIMAX_API_KEY # unset when you're done
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
> **Disable the API key on your provider dashboard as soon as you're done testing.** The MiniMax provider reads `MINIMAX_API_KEY` from your environment; verbai never stores it.
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
## Running the tests
|
|
421
|
+
|
|
422
|
+
```bash
|
|
423
|
+
pip install -e ".[dev]"
|
|
424
|
+
pytest # 169 passing (real-API examples skipped)
|
|
425
|
+
pytest --cov=verbai --cov-fail-under=85 # coverage gate (≥ 85 %)
|
|
426
|
+
pytest -m real_api # opt-in: runs example 14 against a real MiniMax endpoint
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
## Design philosophy
|
|
430
|
+
|
|
431
|
+
verbai is an **octopus with tentacles**: a small, tight language core that reaches out to anything reachable from the runtime. The core handles language semantics, multi-modal types, error recovery, and capability checks; the tentacles are integrations — AI providers, MCP servers, HTTP APIs, webhooks, WebSockets, local processes, databases, env vars, and the file system. Every tentacle is implemented as a stdlib verb or a first-party provider; everything composes with everything else, in any order, in one script.
|
|
432
|
+
|
|
433
|
+
## What's next
|
|
434
|
+
|
|
435
|
+
- **v0.2:** examples 15–31 from the spec curriculum (multi-modal, MCP, HTTP, webhooks, more providers).
|
|
436
|
+
- **v0.2:** formal type checker (capability checks stay as the v0.1 substitute).
|
|
437
|
+
- **v0.3:** LSP server, syntax highlighting, REPL.
|
|
438
|
+
|
|
439
|
+
## License
|
|
440
|
+
|
|
441
|
+
Apache 2.0. See [LICENSE](LICENSE).
|