This commit is contained in:
Михаил Капелько
2024-05-27 22:39:23 +03:00
parent ed7d1cd486
commit c9140d5ed2
11 changed files with 55 additions and 5 deletions

View File

@@ -1,6 +1,8 @@
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include "ctx.h"
#include "llm.h" #include "llm.h"
#include "memory_Context.h" #include "memory_Context.h"
#include "main.h" #include "main.h"

View File

@@ -1,6 +1,8 @@
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include "ctx.h"
#include "llm.h" #include "llm.h"
#include "memory_Context.h" #include "memory_Context.h"
#include "main.h" #include "main.h"

15
v4/ctx.h Normal file
View File

@@ -0,0 +1,15 @@
#include <string>
#include <vector>
#ifndef ctx_HEADER
#define ctx_HEADER
template <class T> class ctx_Controller {
T context;
ctx_Controller(const T &c) {
context = c;
}
};
#endif // ctx_HEADER

View File

@@ -1,6 +1,6 @@
import copy import copy
class Controller: class ctx_Controller:
def __init__(self, c): def __init__(self, c):
self.callbacks = [] self.callbacks = []
self.context = c self.context = c

View File

@@ -1,6 +1,8 @@
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include "ctx.h"
#include "llm.h" #include "llm.h"
#include "memory_Context.h" #include "memory_Context.h"
#include "main.h" #include "main.h"

View File

@@ -1,9 +1,9 @@
from cli import * from cli import *
from cli_test import * from cli_test import *
from ctx import *
from llm_test import * from llm_test import *
from llm_test_Python import * from llm_test_Python import *
from memory_test import * from memory_test import *
from Controller import *
import sys import sys
print(llm_test_Python_copyByValue()) print(llm_test_Python_copyByValue())
@@ -35,7 +35,7 @@ print(cli_test_reportMatchedItems())
print(cli_test_reportMismatchedItems()) print(cli_test_reportMismatchedItems())
print(cli_test_reportVictory()) print(cli_test_reportVictory())
ctrl = Controller(memory_createContext()) ctrl = ctx_Controller(memory_createContext())
ctrl.registerFunctions([ ctrl.registerFunctions([
cli_exit, cli_exit,
cli_goOn, cli_goOn,

View File

@@ -1,6 +1,8 @@
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include "ctx.h"
#include "llm.h" #include "llm.h"
#include "memory_Context.h" #include "memory_Context.h"
#include "main.h" #include "main.h"

View File

@@ -1,5 +1,24 @@
#include "memory_Context.h" #include "memory_Context.h"
template <typename T> T memory_Context::field(const std::string &fieldName) {
if (fieldName == "didLaunch") {
return didLaunch;
}
// TODO
return 0;
}
template <typename T> void memory_Context::setField(const std::string &fieldName, T value) {
if (fieldName == "didLaunch") {
didLaunch = value;
}
// TODO
}
memory_Context memory_createContext() { memory_Context memory_createContext() {
return memory_Context(); return memory_Context();
} }

View File

@@ -1,6 +1,7 @@
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include "ctx.h"
#ifndef memory_Context_HEADER #ifndef memory_Context_HEADER
#define memory_Context_HEADER #define memory_Context_HEADER
@@ -11,6 +12,7 @@ struct memory_Context {
std::string input = ""; std::string input = "";
std::vector<int> hiddenItems; std::vector<int> hiddenItems;
std::vector<int> mismatchedItems; std::vector<int> mismatchedItems;
std::string recentField = "none";
std::string outputGoOn = ""; std::string outputGoOn = "";
std::string outputGreeting = ""; std::string outputGreeting = "";
std::string outputHelp = ""; std::string outputHelp = "";
@@ -20,10 +22,12 @@ struct memory_Context {
std::string outputVictory = ""; std::string outputVictory = "";
std::map<int, int> playfieldItems; std::map<int, int> playfieldItems;
int playfieldSize = 0; int playfieldSize = 0;
std::string recentField = "none";
int selectedId = -1; int selectedId = -1;
std::vector<int> selectedItems; std::vector<int> selectedItems;
bool victory = false; bool victory = false;
template <typename T> T field(const std::string &fieldName);
template <typename T> void setField(const std::string &fieldName, T value);
}; };
memory_Context memory_createContext(); memory_Context memory_createContext();

View File

@@ -1,6 +1,8 @@
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include "ctx.h"
#include "llm.h" #include "llm.h"
#include "memory_Context.h" #include "memory_Context.h"
#include "main.h" #include "main.h"

View File

@@ -1,9 +1,11 @@
from Function import * from Function import *
def includes(): def includes():
return """#include <map> return """
#include <map>
#include <string> #include <string>
#include <vector> #include <vector>
#include "ctx.h"
#include "llm.h" #include "llm.h"
#include "memory_Context.h" #include "memory_Context.h"
#include "main.h" #include "main.h"