question="Does the customer ask for a refund?"
printf '%s' "Please refund my order. It arrived broken." |
thinkthen decide "$question"true
curl -fsSL https://thinkthen.dev/install.sh | shbrew install botassembly/thinkthen/thinkthenSimple functions that give your software judgment. Hand one a message, ask "Does the customer ask for a refund?", and get back yes or no.
question="Does the customer ask for a refund?"
printf '%s' "Please refund my order. It arrived broken." |
thinkthen decide "$question"true
curl -fsSL https://thinkthen.dev/install.sh | shbrew install botassembly/thinkthen/thinkthenimport thinkthen as tt
question = "Does the customer ask for a refund?"
broken = "Please refund my order. It arrived broken."
is_refund = tt.decide(question, broken).value
assert is_refund is Truepip install thinkthenimport pandas as pd
import thinkthen as tt
question = "Does the customer ask for a refund?"
messages = pd.Series([
"Please refund my order. It arrived broken.",
])
is_refund = tt.decide(question, messages).value
assert is_refund.tolist() == [True]pip install thinkthen pandasimport polars as pl
import thinkthen as tt
question = "Does the customer ask for a refund?"
messages = pl.Series([
"Please refund my order. It arrived broken.",
])
is_refund = tt.decide(question, messages).value
assert is_refund.to_list() == [True]pip install thinkthen[polars]library(thinkthen)
question <- "Does the customer ask for a refund?"
broken <- "Please refund my order. It arrived broken."
is_refund <- tt_decide(question, broken)$value
stopifnot(identical(is_refund, TRUE))install.packages("thinkthen", repos = c("https://botassembly.r-universe.dev", "https://cloud.r-project.org"))import assert from "node:assert/strict";
import * as tt from "thinkthen";
const question = "Does the customer ask for a refund?";
const broken = "Please refund my order. It arrived broken.";
const isRefund = (await tt.decide(question, broken)).value;
assert.equal(isRefund, true);npm install thinkthenrequire "thinkthen"
question = "Does the customer ask for a refund?"
broken = "Please refund my order. It arrived broken."
is_refund = ThinkThen.decide(question, broken).value
raise unless is_refund == truegem install thinkthen<?php
declare(strict_types=1);
require __DIR__ . '/thinkthen-php/autoload.php';
$library = __DIR__ . '/thinkthen-c/lib/libthinkthen.so';
$tt = new ThinkThen($library);
$question = 'Does the customer ask for a refund?';
$isRefund = $tt->decide(
$question,
'Please refund my order. It arrived broken.',
)['value']['outcome'];
assert($isRefund === ThinkThen::YES);
$tt->close();composer require botassembly/thinkthenimport 'dart:io';
import 'package:thinkthen_dart/thinkthen_dart.dart';
void main() {
final library = File('thinkthen-c/lib/libthinkthen.so');
final tt = Door(library.absolute.path);
final engine = tt.create();
try {
const question = 'Does the customer ask for a refund?';
final isRefund = tt.decide(
engine,
question,
'Please refund my order. It arrived broken.',
).value.outcome;
assert(isRefund == Outcome.yes);
} finally {
tt.engineFree(engine);
}
}dart pub add thinkthen_dartimport static java.nio.charset.StandardCharsets.UTF_8;
import thinkthen.Door;
import thinkthen.Door.Outcome;
void main() {
try (var tt = new Door()) {
var question =
"Does the customer ask for a refund?";
var text =
"Please refund my order. It arrived broken.";
var isRefund = tt.decide(
question, text.getBytes(UTF_8)).value();
assert Door.outcome(isRefund) == Outcome.YES;
}
}io.github.botassembly:thinkthen-jvm:VERSIONimport thinkthen.Door
import thinkthen.Door.Outcome
fun main() {
Door().use { engine ->
val tt = KotlinFacade(engine)
val question =
"Does the customer ask for a refund?"
val text =
"Please refund my order. It arrived broken."
val isRefund = tt.decide(question, text).value()
check(Door.outcome(isRefund) == Outcome.YES)
}
}io.github.botassembly:thinkthen-jvm:VERSION:kotlinimport scala.concurrent.ExecutionContext.Implicits.global
import scala.util.Using
import thinkthen.Door
import thinkthen.Door.Outcome
@main def decide(): Unit =
Using.resource(Door()) { engine =>
val tt = ScalaFacade(engine)
val question =
"Does the customer ask for a refund?"
val text =
"Please refund my order. It arrived broken."
val isRefund = tt.decide(question, text).value()
assert(Door.outcome(isRefund) == Outcome.YES)
}io.github.botassembly:thinkthen-jvm:VERSION:scalausing System.Diagnostics;
using ThinkThen;
using var tt = Engine.Open();
const string question =
"Does the customer ask for a refund?";
const string text =
"Please refund my order. It arrived broken.";
var isRefund = tt.Decide(question, text).Value;
Trace.Assert(isRefund.OutcomeKind == Outcome.Yes);dotnet add package Botassembly.ThinkThen#include <assert.h>
#include <string.h>
#include <thinkthen.h>
thinkthen_engine *tt = thinkthen_engine_new();
assert(tt);
const char *question =
"Does the customer ask for a refund?";
const char *text =
"Please refund my order. It arrived broken.";
thinkthen_answer is_refund;
int rc = thinkthen_decide(
tt,
question,
text,
strlen(text),
&is_refund
);
assert(rc == THINKTHEN_OK);
assert(is_refund.outcome == THINKTHEN_YES);
thinkthen_engine_free(tt);Keep the #include lines on top. Put the rest inside int main(void) and end it with return 0;.
thinkthen.h + libthinkthen#include <cassert>
#include <thinkthen/door.hpp>
int main() {
auto engine = tt::create();
const char *question =
"Does the customer ask for a refund?";
auto is_refund = tt::decide(
engine,
question,
"Please refund my order. It arrived broken.");
assert(is_refund.value.outcome == tt::Outcome::yes);
}thinkthen-cpp-VERSION-TARGET.tar.gz#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "ThinkThen.h"
int main(void) {
TTClient *client = [TTClient create];
TTFailure failure = {0};
TTDecision is_refund = {0};
char *facts = NULL;
const char *question =
"Does the customer ask for a refund?";
const char *broken =
"Please refund my order. It arrived broken.";
TTErrorKind refund_error =
[client decide:question
text:broken
length:strlen(broken)
deadline:-1
token:nil
answer:&is_refund
facts:&facts
failure:&failure];
assert(refund_error == TTErrorNone);
assert(is_refund.outcome == TTOutcomeYes);
free(facts);
tt_failure_clear(&failure);
[client dealloc];
return 0;
}thinkthen-objective-c-VERSION-TARGET.tar.gzuse thinkthen::{Answer, Engine, Question};
let tt = Engine::from_env()?;
let question = "Does the customer ask for a refund?";
let refund = Question::decide(question)?.cut();
let broken = "Please refund my order. It arrived broken.";
let is_refund = tt.decide(&refund, broken)?.into_value();
assert_eq!(is_refund, Answer::Yes);Put this code inside fn main() -> Result<(), Box<dyn std::error::Error>> and end it with Ok(()). main returns a Result, so ? compiles.
cargo add thinkthenpackage main
import (
"context"
"log"
thinkthen "github.com/botassembly/thinkthen/libraries/go"
)
func main() {
tt, err := thinkthen.New()
if err != nil {
log.Fatal(err)
}
defer tt.Close()
ctx := context.Background()
question := "Does the customer ask for a refund?"
isRefund, err := tt.Decide(
ctx,
question,
"Please refund my order. It arrived broken.",
)
if err != nil {
log.Fatal(err)
}
if isRefund.Value.Outcome != thinkthen.Yes {
log.Fatal("expected yes")
}
}go get github.com/botassembly/thinkthen/libraries/goimport ThinkThen
let tt = try Engine()
let question = "Does the customer ask for a refund?"
let isRefund = try tt.decide(
question,
"Please refund my order. It arrived broken."
)
precondition(isRefund.value.outcome == .yes)
tt.close()thinkthen-swift-VERSION-TARGET.tar.gzconst std = @import("std");
const thinkthen = @import("thinkthen");
pub fn main() !void {
const allocator = std.heap.page_allocator;
var tt = switch (try thinkthen.Engine.init(allocator)) {
.ok => |engine| engine,
.failed => |failure| {
thinkthen.releaseFailure(allocator, failure);
return error.NoEngine;
},
};
defer tt.deinit();
const question = "Does the customer ask for a refund?";
const text =
"Please refund my order. It arrived broken.";
const asked = try tt.decide(question, text, .{});
const is_refund = switch (asked) {
.ok => |answer| answer,
.failed => |failure| {
tt.freeFailure(failure);
return error.Failed;
},
};
defer is_refund.deinit(allocator);
std.debug.assert(is_refund.value.outcome == .yes);
}thinkthen-zig-VERSION-TARGET.tar.gzwith Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Thinkthen; use Thinkthen;
procedure Sample is
Client : Engine;
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.",
Is_Refund,
Facts,
Error);
pragma Assert (Error.Kind = None);
pragma Assert (Is_Refund.Value = Yes);
end Sample;thinkthen-ada-VERSION-TARGET.tar.gzidentification division.
program-id. sample.
environment division.
configuration section.
repository. function all intrinsic.
data division.
working-storage section.
copy "thinkthen.cpy".
01 engine usage pointer.
01 free-engine pic x(24) value "thinkthen_engine_free".
01 question pic x(200)
value "Does the customer ask for a refund?".
01 question-length usage binary-double unsigned.
01 evidence pic x(200)
value "Please refund my order. It arrived broken.".
01 evidence-length usage binary-double unsigned.
01 is-refund.
02 refund-outcome usage binary-long signed.
88 is-refund-yes value 1.
02 filler usage binary-long unsigned.
02 filler usage float-long.
procedure division.
call "thinkthen_engine_new" returning engine
move length(trim(question trailing))
to question-length
move length(trim(evidence trailing))
to evidence-length
call "TT-DECIDE" using engine
question question-length
evidence evidence-length
tt-deadline-ms is-refund tt-facts tt-failure
if not is-refund-yes
stop run returning 1
end-if
call free-engine using by value engine
stop run returning 0.thinkthen-cobol-VERSION-TARGET.tar.gzLOAD './thinkthen.duckdb_extension';
SELECT thinkthen_decide(
'Does the customer ask for a refund?',
'Please refund my order. It arrived broken.'
) AS is_refund;is_refund true
thinkthen-duckdb-VERSION-TARGET.tar.gz.load ./thinkthen
SELECT thinkthen_decide(
'Does the customer ask for a refund?',
'Please refund my order. It arrived broken.'
) AS is_refund;1
thinkthen-sqlite-VERSION-TARGET.tar.gzSELECT thinkthen_decide(
'Does the customer ask for a refund?',
'Please refund my order. It arrived broken.'
) AS is_refund;is_refund ----------- t (1 row)
thinkthen-postgresql16-VERSION-TARGET.tar.gzdecide is an if that understands. filter is a grep that understands. rank is a sort that understands. Every answer rests on the model's probabilities. On decide, a band sends anything between its two sides back as not sure. A person reads those.
10 functions, 1 CLI, 24 bindings.
Beatles Bench asks questions about Beatles songs. A script set the right answer to each scored question ahead of time, from Wikipedia and Wikidata. New to ThinkThen? Start with the tutorial.
On GitHub: github.com/botassembly/thinkthen