start: v5
This commit is contained in:
86
v5/_old/ctx_test.cpp
Normal file
86
v5/_old/ctx_test.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "ctx.h"
|
||||
#include "llm.h"
|
||||
#include "memory_Context.h"
|
||||
#include "main.h"
|
||||
|
||||
std::string ctx_test_Controller_executeFunctions_set(
|
||||
) {
|
||||
auto c = memory_createContext();
|
||||
auto ctrl = ctx_Controller(c);
|
||||
// Disable automatic invocation of executeFunctions.
|
||||
ctrl.isProcessingQueue = true;
|
||||
ctrl.set("input", "123");
|
||||
ctrl.registerFunction(__processInput);
|
||||
// Apply 'input'.
|
||||
ctrl.executeFunctions();
|
||||
// Apply 'outputHelp'.
|
||||
ctrl.executeFunctions();
|
||||
if (
|
||||
c.input == "123" &&
|
||||
c.outputHelp == "Checked"
|
||||
) {
|
||||
return "OK: ctx_Controller_executeFunctions_set";
|
||||
}
|
||||
return "ERR: ctx_Controller_executeFunctions_set";
|
||||
}
|
||||
|
||||
std::string ctx_test_Controller_processQueue(
|
||||
) {
|
||||
auto c = memory_createContext();
|
||||
auto ctrl = ctx_Controller(c);
|
||||
ctrl.registerFunction(__processInput);
|
||||
ctrl.set("input", "abc");;
|
||||
if (
|
||||
c.input == "abc" &&
|
||||
c.outputHelp == "Checked"
|
||||
) {
|
||||
return "OK: ctx_Controller_processQueue";
|
||||
}
|
||||
return "ERR: ctx_Controller_processQueue";
|
||||
}
|
||||
|
||||
std::string ctx_test_memoryContext_field(
|
||||
) {
|
||||
auto c = memory_createContext();
|
||||
c.input = "abc";
|
||||
if (
|
||||
c.field("input") == "abc"
|
||||
) {
|
||||
return "OK: ctx_memoryContext_field";
|
||||
}
|
||||
return "ERR: ctx_memoryContext_field";
|
||||
}
|
||||
|
||||
std::string ctx_test_memoryContext_setField(
|
||||
) {
|
||||
auto c = memory_createContext();
|
||||
c.input = "abc";
|
||||
c.setField("input", "123");
|
||||
if (
|
||||
c.field("input") == "123"
|
||||
) {
|
||||
return "OK: ctx_memoryContext_setField";
|
||||
}
|
||||
return "ERR: ctx_memoryContext_setField";
|
||||
}
|
||||
|
||||
// Auxiliary functions.
|
||||
|
||||
memory_Context __processInput(
|
||||
memory_Context c
|
||||
) {
|
||||
if (
|
||||
c.recentField == "input"
|
||||
) {
|
||||
c.outputHelp = "Checked";
|
||||
c.recentField = "outputHelp";
|
||||
return c;
|
||||
}
|
||||
c.recentField = "none";
|
||||
return c;
|
||||
}
|
||||
|
||||
81
v5/_old/ctx_test.py
Normal file
81
v5/_old/ctx_test.py
Normal file
@@ -0,0 +1,81 @@
|
||||
from ctx import *
|
||||
from memory import *
|
||||
from memory_Context import *
|
||||
|
||||
def ctx_test_Controller_executeFunctions_set(
|
||||
) -> str:
|
||||
c = memory_createContext()
|
||||
ctrl = ctx_Controller(c)
|
||||
# Disable automatic invocation of executeFunctions.
|
||||
ctrl.isProcessingQueue = True
|
||||
ctrl.set("input", "123")
|
||||
ctrl.registerFunction(__processInput)
|
||||
# Apply 'input'.
|
||||
ctrl.executeFunctions()
|
||||
# Apply 'outputHelp'.
|
||||
ctrl.executeFunctions()
|
||||
if (
|
||||
c.input == "123" and
|
||||
c.outputHelp == "Checked"
|
||||
):
|
||||
return "OK: ctx_Controller_executeFunctions_set"
|
||||
#}
|
||||
return "ERR: ctx_Controller_executeFunctions_set"
|
||||
#}
|
||||
|
||||
def ctx_test_Controller_processQueue(
|
||||
) -> str:
|
||||
c = memory_createContext()
|
||||
ctrl = ctx_Controller(c)
|
||||
ctrl.registerFunction(__processInput)
|
||||
ctrl.set("input", "abc");
|
||||
if (
|
||||
c.input == "abc" and
|
||||
c.outputHelp == "Checked"
|
||||
):
|
||||
return "OK: ctx_Controller_processQueue"
|
||||
#}
|
||||
return "ERR: ctx_Controller_processQueue"
|
||||
#}
|
||||
|
||||
def ctx_test_memoryContext_field(
|
||||
) -> str:
|
||||
c = memory_createContext()
|
||||
c.input = "abc"
|
||||
if (
|
||||
c.field("input") == "abc"
|
||||
):
|
||||
return "OK: ctx_memoryContext_field"
|
||||
#}
|
||||
return "ERR: ctx_memoryContext_field"
|
||||
#}
|
||||
|
||||
def ctx_test_memoryContext_setField(
|
||||
) -> str:
|
||||
c = memory_createContext()
|
||||
c.input = "abc"
|
||||
c.setField("input", "123")
|
||||
if (
|
||||
c.field("input") == "123"
|
||||
):
|
||||
return "OK: ctx_memoryContext_setField"
|
||||
#}
|
||||
return "ERR: ctx_memoryContext_setField"
|
||||
#}
|
||||
|
||||
# Auxiliary functions.
|
||||
|
||||
@llm_by_value
|
||||
def __processInput(
|
||||
c: memory_Context
|
||||
) -> memory_Context:
|
||||
if (
|
||||
c.recentField == "input"
|
||||
):
|
||||
c.outputHelp = "Checked"
|
||||
c.recentField = "outputHelp"
|
||||
return c
|
||||
#}
|
||||
c.recentField = "none"
|
||||
return c
|
||||
#}
|
||||
53
v5/_old/ctx_test_Python.py
Normal file
53
v5/_old/ctx_test_Python.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from ctx import *
|
||||
from memory import *
|
||||
from memory_Context import *
|
||||
|
||||
def ctx_test_Python_Controller_registerFieldCallback_match(
|
||||
) -> str:
|
||||
c = memory_createContext()
|
||||
ctrl = ctx_Controller(c)
|
||||
c.input = "123"
|
||||
c.recentField = "input"
|
||||
globals()["__callbackInput"] = ""
|
||||
ctrl.registerFieldCallback("input", __setCallbackInput)
|
||||
ctrl.reportContext()
|
||||
val = globals()["__callbackInput"]
|
||||
if (
|
||||
c.input == globals()["__callbackInput"]
|
||||
):
|
||||
return "OK: ctx_Python_Controller_registerFieldCallback_match"
|
||||
#}
|
||||
return f"ERR: ctx_Python_Controller_registerFieldCallback_match"
|
||||
#}
|
||||
|
||||
def ctx_test_Python_Controller_registerFieldCallback_mismatch(
|
||||
) -> str:
|
||||
c = memory_createContext()
|
||||
ctrl = ctx_Controller(c)
|
||||
c.input = "123"
|
||||
c.outputHelp = "you"
|
||||
c.recentField = "outputHelp"
|
||||
globals()["__callbackInput"] = ""
|
||||
ctrl.registerFieldCallback("input", __setCallbackInput)
|
||||
ctrl.reportContext()
|
||||
val = globals()["__callbackInput"]
|
||||
if (
|
||||
globals()["__callbackInput"] == ""
|
||||
):
|
||||
return "OK: ctx_Python_Controller_registerFieldCallback_mismatch"
|
||||
#}
|
||||
return f"ERR: ctx_Python_Controller_registerFieldCallback_mismatch"
|
||||
#}
|
||||
|
||||
# Auxiliary.
|
||||
|
||||
__callbackInput = ""
|
||||
|
||||
@llm_by_value
|
||||
def __setCallbackInput(c):
|
||||
if (
|
||||
c.recentField == "input"
|
||||
):
|
||||
globals()["__callbackInput"] = c.input
|
||||
#}
|
||||
#}
|
||||
Reference in New Issue
Block a user