Ada functions that answer questions about text
A Thinkthen package over the C library, for GNAT. Each call is a procedure with out parameters.
Install
| Channel | Note |
|---|---|
thinkthen-ada-VERSION-TARGET.tar.gz | The package and its GNAT project, from each release. |
thinkthen-c-VERSION-TARGET.tar.gz | The C library it calls, from the same release. |
Set THINKTHEN_API_KEY in the environment.
A first call
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Thinkthen; use Thinkthen;
procedure First_Call is
Client : Engine;
Is_Refund : Decision;
Facts : Unbounded_String;
Error : Failure;
Question : constant String :=
"Does the customer ask for a refund?";
Refund : constant String :=
"{""decide"": """ & Question & """, "
& """threshold"": ""0.2:0.8""}";
begin
Decide
(Client,
Question,
"Please refund my order. It arrived broken.",
Is_Refund,
Facts,
Error);
pragma Assert (Error.Kind = None);
pragma Assert (Is_Refund.Value = Yes);
Decide
(Client,
Refund,
"I want to send this back.",
Is_Refund,
Facts,
Error);
pragma Assert (Error.Kind = None);
pragma Assert (Is_Refund.Value = Not_Sure);
end First_Call;gnatmake -gnat2022 -gnata \
-Ithinkthen-ada/src \
first_call.adb -o first_call \
-largs \
-L thinkthen-c/lib -lthinkthen \
-Wl,-rpath,"$PWD/thinkthen-c/lib"
./first_callNot sure comes back as Not_Sure. Branch on it and send those cases to a person.
Run facts
Decide sets Facts to this call's run facts as JSON text. Member reads one member.
Errors
Decide sets Error. Its Kind runs from Usage to Defect, and None means the call answered.
Settings and recording
Configure takes the settings as JSON. "record" writes a recording to a folder. "replay" answers from that recording with no connection. The Settings page lists every setting.
Jev, Liquid d1 and Ollama from Ada
Ada reads its backend from the environment. Set THINKTHEN_BACKEND to the name below. Set the backend's key variable in the shell, and the same sample asks that backend.
| Backend | Name | Key variable |
|---|---|---|
| TypeSafe Jev | typesafe | TYPESAFE_API_KEY |
| Liquid d1 | liquid | LIQUIDAI_API_KEY, then LIQUID_API_KEY |
| Ollama | ollama | OLLAMA_API_KEY. A local address needs no key. |
export THINKTHEN_BACKEND=typesafe
export TYPESAFE_API_KEY=...export THINKTHEN_BACKEND=liquid
export LIQUIDAI_API_KEY=...export THINKTHEN_BACKEND=ollama
export THINKTHEN_BASE_URL=http://localhost:11535/v1with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Thinkthen; use Thinkthen;
procedure Backends is
Client : Engine;
Broken_Is_Refund : Decision;
Thanks_Is_Refund : Decision;
Facts : Unbounded_String;
Error : Failure;
Question : constant String :=
"Does the customer ask for a refund?";
begin
Decide
(Client,
Question,
"Please refund my order. It arrived broken.",
Broken_Is_Refund,
Facts,
Error);
pragma Assert (Error.Kind = None);
pragma Assert (Broken_Is_Refund.Value = Yes);
Decide
(Client,
Question,
"Thanks for the quick help yesterday!",
Thanks_Is_Refund,
Facts,
Error);
pragma Assert (Error.Kind = None);
pragma Assert (Thanks_Is_Refund.Value = No);
end Backends;gnatmake -gnat2022 -gnata \
-Ithinkthen-ada/src \
backends.adb -o backends \
-largs \
-L thinkthen-c/lib -lthinkthen \
-Wl,-rpath,"$PWD/thinkthen-c/lib"
./backendsThe configuration file's backend names a default backend for every run. The Configuration page shows the file.
OpenAI Decisions API from Ada
OpenAI announced its Decisions API on 2026-09-29 in its DevDay 2026 recap. OpenAI has published no address, schema or price, so ThinkThen cannot call it. The OpenAI Decisions API page says what ThinkThen knows.
What is different in Ada
gprbuild -P thinkthen.gprbuilds the package as a library.pragma Assertruns only under-gnata.
On GitHub: github.com/botassembly/thinkthen