Skip to content

Commit

Permalink
@cxx/* conversation* -> assistant*,
Browse files Browse the repository at this point in the history
  `Conversation*` -> `Assistant*`,
  `IGNORE_PAST_CONVERSATIONS` -> `IGNORE_PAST_MESSAGES`
  `disinfection*` -> `virusFix*`,
  `Disinfection*` -> `VirusFix*`,

`cxx/ConversationCns.*xx` -> `cxx/AssistantCns.*xx`

@posts/VirusAnalysis.md /* Matches this */
@posts/CnsCompress.md /* Matches this */

This commit is just English fixes,
but as common files are renamed, it is a serious issue,
The English problem (names signalled almost the opposite of what stuff
was) were such that figured it is worth to rename files
to fix this.
  • Loading branch information
SwuduSusuwu committed Jun 27, 2024
1 parent d3eb745 commit 2204ed7
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 113 deletions.
40 changes: 20 additions & 20 deletions cxx/ConversationCns.cxx → cxx/AssistantCns.cxx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/* Dual licenses: choose "Creative Commons" or "Apache 2" (allows all uses) */
#ifndef INCLUDES_cxx_ConversationCns_cxx
#define INCLUDES_cxx_ConversationCns_cxx
#ifndef INCLUDES_cxx_AssistantCns_cxx
#define INCLUDES_cxx_AssistantCns_cxx
#include "ClassCns.hxx" /* Cns, CnsMode, execvex */
#include "ClassPortableExecutable.hxx" /* FilePath FileBytecode */
#include "ClassResultList.hxx" /* ResultList listMaxSize listHasValue explodeToList ResultListBytecode */
#include "ClassSha2.hxx" /* Sha2 */
#include "ConversationCns.hxx" /* conversationParseUrls conversationParseQuestion conversationParseResponses */
#include "AssistantCns.hxx" /* assistantParseUrls assistantParseQuestion assistantParseResponses */
#include <cassert> /* assert */
#include <iostream> /* std::cin std::cout */
#include <string> /* std::string */
#include <tuple> /* std::tuple */
#include <vector> /* std::vector */
/* (Work-in-progress) conversation bots with artificial CNS. */
/* (Work-in-progress) assistant bots with artificial CNS. */
namespace Susuwu {
const bool conversationCnsTestsThrows() {
const bool assistantCnsTestsThrows() {
ResultList questionsOrNull {
.bytecodes { /* UTF-8 */
ResultListBytecode("2^16"),
Expand All @@ -31,10 +31,10 @@ const bool conversationCnsTestsThrows() {
}
};
questionsResponsesFromHosts(questionsOrNull, responsesOrNull);
produceConversationCns(questionsOrNull, responsesOrNull, conversationCns);
produceAssistantCns(questionsOrNull, responsesOrNull, assistantCns);
return true;
}
void produceConversationCns(const ResultList &questionsOrNull, const ResultList &responsesOrNull, Cns &cns) {
void produceAssistantCns(const ResultList &questionsOrNull, const ResultList &responsesOrNull, Cns &cns) {
std::vector<const std::tuple<const ResultListBytecode, const ResultListBytecode>> inputsToOutputs;
cns.setInputMode(cnsModeString);
cns.setOutputMode(cnsModeString);
Expand All @@ -59,13 +59,13 @@ void questionsResponsesFromHosts(ResultList &questionsOrNull, ResultList &respon
}
}
void questionsResponsesFromXhtml(ResultList &questionsOrNull, ResultList &responsesOrNull, const FilePath &localXhtml) {
auto noRobots = conversationParseUrls("robots.txt");
auto question = conversationParseQuestion(localXhtml);
auto noRobots = assistantParseUrls("robots.txt");
auto question = assistantParseQuestion(localXhtml);
if(!question.empty()) {
auto questionSha2 = Sha2(question);
if(!listHasValue(questionsOrNull.hashes, questionSha2)) {
questionsOrNull.hashes.insert(questionSha2);
auto responses = conversationParseResponses(localXhtml);
auto responses = assistantParseResponses(localXhtml);
for(const auto &response : responses) {
auto questionSha2 = Sha2(question);
auto responseSha2 = Sha2(response);
Expand All @@ -78,7 +78,7 @@ void questionsResponsesFromXhtml(ResultList &questionsOrNull, ResultList &respon
}
}
}
auto urls = conversationParseUrls(localXhtml);
auto urls = assistantParseUrls(localXhtml);
for(const auto &url : urls) {
if(!listHasValue(questionsOrNull.signatures, url) && !listHasValue(noRobots, url)) {
execvex("wget '" + url + "' -O" + localXhtml);
Expand All @@ -91,7 +91,7 @@ void questionsResponsesFromXhtml(ResultList &questionsOrNull, ResultList &respon
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#endif /* BOOST_VERSION */
const std::vector<FilePath> conversationParseUrls(const FilePath &localXhtml) {
const std::vector<FilePath> assistantParseUrls(const FilePath &localXhtml) {
const std::vector<FilePath> urls;
#ifdef BOOST_VERSION
boost::property_tree::ptree pt;
Expand All @@ -104,18 +104,18 @@ const std::vector<FilePath> conversationParseUrls(const FilePath &localXhtml) {
#endif /* else !BOOST_VERSION */
return urls;
}
const FileBytecode conversationParseQuestion(const FilePath &localXhtml) {} /* TODO */
const std::vector<FileBytecode> conversationParseResponses(const FilePath &localXhtml) {} /* TODO */
const FileBytecode assistantParseQuestion(const FilePath &localXhtml) {} /* TODO */
const std::vector<FileBytecode> assistantParseResponses(const FilePath &localXhtml) {} /* TODO */

const std::string conversationCnsProcess(const Cns &cns, const FileBytecode &bytecode) {
const std::string assistantCnsProcess(const Cns &cns, const FileBytecode &bytecode) {
return cns.processToString(bytecode);
}

void conversationCnsLoopProcess(const Cns &cns) {
void assistantCnsLoopProcess(const Cns &cns) {
std::string bytecode, previous;
int nthResponse = 0;
while(std::cin >> bytecode) {
#ifdef IGNORE_PAST_CONVERSATIONS
#ifdef IGNORE_PAST_MESSAGES
std::vector<std::string> responses = explodeToList(cns.processToString(bytecode), "<delimiterSeparatesMultiplePossibleResponses>");
if(bytecode == previous && responses.size() > 1 + nthResponse) {
++nthResponse; /* Similar to "suggestions" for next questions, but just uses previous question to give new responses */
Expand All @@ -132,16 +132,16 @@ void conversationCnsLoopProcess(const Cns &cns) {
} else {
nthResponse = 0;
}
#endif /* IGNORE_PAST_CONVERSATIONS */
#endif /* IGNORE_PAST_MESSAGES */
std::cout << responses.at(nthResponse);
previous = bytecode;
bytecode += '\n'; /* delimiter separates (and uses) multiple inputs */
}
}

/* To process fast (lag less,) use flags which auto-vectorizes/auto-parallelizes; To do `produceConversationCns` fast, use TensorFlow's `MapReduce`;
/* To process fast (lag less,) use flags which auto-vectorizes/auto-parallelizes; To do `produceAssistantCns` fast, use TensorFlow's `MapReduce`;
* https://swudususuwu.substack.com/p/howto-run-devices-phones-laptops
*/
}; /* namespace Susuwu */
#endif /* ndef INCLUDES_cxx_ConversationCns_cxx */
#endif /* ndef INCLUDES_cxx_AssistantCns_cxx */

44 changes: 22 additions & 22 deletions cxx/ConversationCns.hxx → cxx/AssistantCns.hxx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
/* Dual licenses: choose "Creative Commons" or "Apache 2" (allows all uses) */
#pragma once
#ifndef INCLUDES_cxx_ConversationCns_hxx
#define INCLUDES_cxx_ConversationCns_hxx
#ifndef INCLUDES_cxx_AssistantCns_hxx
#define INCLUDES_cxx_AssistantCns_hxx
#include "ClassCns.hxx" /* Cns CnsMode */
#include "ClassPortableExecutable.hxx" /* FilePath FileBytecode */
#include "ClassResultList.hxx" /* ResultList */
#include <string> /* std::string */
#include <vector> /* std::vector */
/* (Work-in-progress) conversation bots with artificial CNS ("HSOM" (the simple Python artificial CNS) is enough to do this), which should have results almost as complex as "ChatGPT 4.0" (or as "Claude-3 Opus"); */
/* (Work-in-progress) assistant bots with artificial CNS ("HSOM" (the simple Python artificial CNS) is enough to do this), which should have results almost as complex as "ChatGPT 4.0" (or as "Claude-3 Opus"); */
namespace Susuwu {
static Cns conversationCns;
static Cns assistantCns;

/* if (with example inputs) these functions (`questionsResponsesFromHosts()` `produceConversationCns()`) pass, `return true;`
/* if (with example inputs) these functions (`questionsResponsesFromHosts()` `produceAssistantCns()`) pass, `return true;`
* @throw std::bad_alloc
* @throw std::logic_error
* @pre @code conversationCns.hasImplementation() @endcode */
const bool conversationCnsTestsThrows();
static const bool conversationCnsTests() { try{ return conversationCnsTestsThrows(); } catch(...) { return false; }}
static std::vector<FilePath> conversationDefaultHosts = {
* @pre @code assistantCns.hasImplementation() @endcode */
const bool assistantCnsTestsThrows();
static const bool assistantCnsTests() { try{ return assistantCnsTestsThrows(); } catch(...) { return false; }}
static std::vector<FilePath> assistantDefaultHosts = {
/* Universal Resources Locators of hosts which `questionsResponsesFromHosts()` uses
* Wikipedia is a special case; has compressed downloads of databases ( https://wikipedia.org/wiki/Wikipedia:Database_download )
* Github is a special case; has compressed downloads of repositories ( https://docs.github.com/en/get-started/start-your-journey/downloading-files-from-github )
Expand All @@ -28,33 +28,33 @@ static std::vector<FilePath> conversationDefaultHosts = {
};

/* @throw std::bad_alloc
* @post If no question, `0 == questionsOrNull.bytecodes[x].size()` (new conversation synthesis).
* @post If no question, `0 == questionsOrNull.bytecodes[x].size()` (new message synthesis).
* If no responses, `0 == responsesOrNull.bytecodes[x].size()` (ignore).
* `questionsOrNull.signatures[x] = Universal Resource Locator`
* @code Sha2(ResultList.bytecodes[x]) == ResultList.hashes[x] @endcode */
void questionsResponsesFromHosts(ResultList &questionsOrNull, ResultList &responsesOrNull, const std::vector<FilePath> &hosts = conversationDefaultHosts);
void questionsResponsesFromHosts(ResultList &questionsOrNull, ResultList &responsesOrNull, const std::vector<FilePath> &hosts = assistantDefaultHosts);
void questionsResponsesFromXhtml(ResultList &questionsOrNull, ResultList &responsesOrNull, const FilePath &localXhtml = "index.xhtml");
const std::vector<FilePath> conversationParseUrls(const FilePath &localXhtml = "index.xhtml"); /* TODO: for XML/XHTML could just use [ https://www.boost.io/libraries/regex/ https://github.com/boostorg/regex ] or [ https://www.boost.org/doc/libs/1_85_0/doc/html/property_tree/parsers.html#property_tree.parsers.xml_parser https://github.com/boostorg/property_tree/blob/develop/doc/xml_parser.qbk ] */
const FileBytecode conversationParseQuestion(const FilePath &localXhtml = "index.xhtml"); /* TODO: regex or XML parser */
const std::vector<FileBytecode> conversationParseResponses(const FilePath &localXhtml = "index.xhtml"); /* TODO: regex or XML parser */
const std::vector<FilePath> assistantParseUrls(const FilePath &localXhtml = "index.xhtml"); /* TODO: for XML/XHTML could just use [ https://www.boost.io/libraries/regex/ https://github.com/boostorg/regex ] or [ https://www.boost.org/doc/libs/1_85_0/doc/html/property_tree/parsers.html#property_tree.parsers.xml_parser https://github.com/boostorg/property_tree/blob/develop/doc/xml_parser.qbk ] */
const FileBytecode assistantParseQuestion(const FilePath &localXhtml = "index.xhtml"); /* TODO: regex or XML parser */
const std::vector<FileBytecode> assistantParseResponses(const FilePath &localXhtml = "index.xhtml"); /* TODO: regex or XML parser */

/* @pre `questionsOrNull` maps to `responsesOrNull`,
* `0 == questionsOrNull.bytecodes[x].size()` for new conversation synthesis (empty question has responses),
* `0 == questionsOrNull.bytecodes[x].size()` for new assistant synthesis (empty question has responses),
* `0 == responsesOrNull.bytecodes[x].size()` if should not respond (question does not have answers).
* @post Can use `conversationCnsProcess(cns, text)` @code cns.isInitialized() @endcode */
void produceConversationCns(const ResultList &questionsOrNull, const ResultList &responsesOrNull, Cns &cns);
* @post Can use `assistantCnsProcess(cns, text)` @code cns.isInitialized() @endcode */
void produceAssistantCns(const ResultList &questionsOrNull, const ResultList &responsesOrNull, Cns &cns);

/* All clients use is these 2 functions */
/* `return cns.processStringToString(bytecodes);`
* @pre @code cns.isInitialized() @encode */
const std::string conversationCnsProcess(const Cns &cns, const std::string &bytecode);
/* `while(std::cin >> questions) { std::cout << conversationCnsProcess(questions); }` but more complex
const std::string assistantCnsProcess(const Cns &cns, const std::string &bytecode);
/* `while(std::cin >> questions) { std::cout << assistantCnsProcess(questions); }` but more complex
* @pre @code cns.isInitialized() @encode */
void conversationCnsLoopProcess(const Cns &cns);
void assistantCnsLoopProcess(const Cns &cns);


/* Related to this:
* To process fast (lag less,) use flags which auto-vectorizes/auto-parallelizes; To do `produceConversationCns` fast, use TensorFlow's `MapReduce`;
* To process fast (lag less,) use flags which auto-vectorizes/auto-parallelizes; To do `produceAssistantCns` fast, use TensorFlow's `MapReduce`;
* https://swudususuwu.substack.com/p/howto-run-devices-phones-laptops
*
* Alternative CNS's;
Expand All @@ -71,5 +71,5 @@ void conversationCnsLoopProcess(const Cns &cns);
* https://swudususuwu.substack.com/p/destructive-unreversible-upload-of
*/
}; /* namespace Susuwu */
#endif /* ndef INCLUDES_cxx_ConversationCns_hxx */
#endif /* ndef INCLUDES_cxx_AssistantCns_hxx */

6 changes: 3 additions & 3 deletions cxx/VirusAnalysis.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const bool virusAnalysisTestsThrows() {
};
produceAbortListSignatures(passList, abortList);
produceAnalysisCns(passOrNull, abortOrNull, ResultList(), analysisCns);
produceDisinfectionCns(passOrNull, abortOrNull, disinfectionCns);
produceVirusFixCns(passOrNull, abortOrNull, virusFixCns);
/* callbackHook("exec", */ [](const PortableExecutable &file) { /* TODO: OS-specific "hook"/"callback" for `exec()`/app-launches */
switch(virusAnalysis(file)) {
case virusAnalysisPass:
Expand Down Expand Up @@ -208,7 +208,7 @@ const VirusAnalysisResult cnsAnalysis(const PortableExecutable &file, const Resu
return cnsAnalysis_(file, fileHash);
}

void produceDisinfectionCns(const ResultList &passOrNull, const ResultList &abortOrNull, Cns &cns /* = disinfectionCns */) {
void produceVirusFixCns(const ResultList &passOrNull, const ResultList &abortOrNull, Cns &cns /* = virusFixCns */) {
std::vector<const std::tuple<const FileBytecode, const FileBytecode>> inputsToOutputs;
cns.setInputMode(cnsModeString);
cns.setOutputMode(cnsModeString);
Expand All @@ -224,7 +224,7 @@ void produceDisinfectionCns(const ResultList &passOrNull, const ResultList &abor
cns.setupSynapses(inputsToOutputs);
}

const FileBytecode cnsDisinfection(const PortableExecutable &file, const Cns &cns /* = disinfectionCns */) {
const FileBytecode cnsVirusFix(const PortableExecutable &file, const Cns &cns /* = virusFixCns */) {
return cns.processToString(file.bytecode);
}

Expand Down
24 changes: 12 additions & 12 deletions cxx/VirusAnalysis.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ typedef enum VirusAnalysisResult : char {
} VirusAnalysisResult; /* if(virusAnalysisAbort != VirusAnalysisResult) {static_assert(true == static_cast<bool>(VirusAnalysisResult));} */

static ResultList passList, abortList; /* hosts produce, clients initialize shared clones of this from disk */
static Cns analysisCns, disinfectionCns; /* hosts produce, clients initialize shared clones of this from disk */
static Cns analysisCns, virusFixCns; /* hosts produce, clients initialize shared clones of this from disk */

/* `return (produceAbortListSignatures(EXAMPLES) && produceAnalysisCns(EXAMPLES) && produceDisinfectionCns(EXAMPLES));`
* @pre @code analysisCns.hasImplementation() && disinfectionCns.hasImplementation() @endcode */
/* `return (produceAbortListSignatures(EXAMPLES) && produceAnalysisCns(EXAMPLES) && produceVirusFixCns(EXAMPLES));`
* @pre @code analysisCns.hasImplementation() && virusFixCns.hasImplementation() @endcode */
const bool virusAnalysisTestsThrows();
static const bool virusAnalysisTests() {try {return virusAnalysisTestsThrows();} catch(...) {return false;}}

Expand Down Expand Up @@ -54,8 +54,8 @@ static std::vector<std::string> stracePotentialDangers = {"write(*)"};
const VirusAnalysisResult straceOutputsAnalysis(const FilePath &straceOutput); /* TODO: regex */

/* Analysis CNS */
/* To train (setup synapses) the CNS, is slow plus requires access to huge file databases,
but the synapses use small resources (allow clients to do fast analysis.)
/* Setup analysis CNS; is slow to produce (requires access to huge file databases);
but once produced, uses few resources (allow clients to do fast analysis.)
* @pre @code cns.hasImplementation() && pass.bytecodes.size() && abort.bytecodes.size() @endcode
* @post @code cns.isInitialized() @endcode */
void produceAnalysisCns(const ResultList &pass, const ResultList &abort,
Expand All @@ -77,26 +77,26 @@ static std::vector<typeof(VirusAnalysisFun)> virusAnalyses = {hashAnalysis, sign
const VirusAnalysisResult virusAnalysis(const PortableExecutable &file); /* auto hash = Sha2(file.bytecode); for(VirusAnalysisFun analysis : virusAnalyses) {analysis(file, hash);} */
static const VirusAnalysisResult submitSampleToHosts(const PortableExecutable &file) {return virusAnalysisRequiresReview;} /* TODO: requires compatible hosts to upload to */

/* Setup disinfection CNS, uses more resources than `produceAnalysisCns()` */
/* `abortOrNull` should map to `passOrNull` (`ResultList` is composed of `std::tuple`s, because just `produceDisinfectionCns()` requires this),
/* Setup virus fix CMS, uses more resources than `produceAnalysisCns()` */
/* `abortOrNull` should map to `passOrNull` (`ResultList` is composed of `std::tuple`s, because just `produceVirusFixCns()` requires this),
* with `abortOrNull->bytecodes[x] = NULL` (or "\0") for new SW synthesis,
* and `passOrNull->bytecodes[x] = NULL` (or "\0") if infected and CNS can not cleanse this.
* @pre @code cns.hasImplementation() @endcode
* @post @code cns.isInitialized() @encode
*/
void produceDisinfectionCns(
void produceVirusFixCns(
const ResultList &passOrNull, /* Expects `resultList->bytecodes[x] = NULL` if does not pass */
const ResultList &abortOrNull, /* Expects `resultList->bytecodes[x] = NULL` if does pass */
Cns &cns = disinfectionCns
Cns &cns = virusFixCns
);

/* Uses more resources than `cnsAnalysis()`, can undo infection from bytecodes (restore to fresh SW)
* @pre @code cns.isInitialized() @endcode */
const std::string cnsDisinfection(const PortableExecutable &file, const Cns &cns = disinfectionCns);
const std::string cnsVirusFix(const PortableExecutable &file, const Cns &cns = virusFixCns);

/* Related to this:
* `cnsDisinfection` is close to conversation bots (such as "ChatGPT 4.0" or "Claude-3 Opus",) "HSOM" (the simple Python artificial CNS) is enough to do this;
* #include "ConversationCns.cxx"
* `cnsVirusFix` is close to assistants (such as "ChatGPT 4.0" or "Claude-3 Opus",) "HSOM" (the simple Python artificial CNS) is enough to do this;
* #include "AssistantCns.cxx"
*
* To process fast (lag less,) use flags which auto-vectorizes/auto-parallelizes; To do `produceConversationCns` fast, use TensorFlow's `MapReduce`;
* https://swudususuwu.substack.com/p/howto-run-devices-phones-laptops
Expand Down
6 changes: 3 additions & 3 deletions cxx/main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef INCLUDES_cxx_main_cxx
#define INCLUDES_cxx_main_cxx
#include "ClassCns.hxx" /* execves execvex */
#include "ConversationCns.hxx" /* conversationCnsTestsThrows */
#include "AssistantCns.hxx" /* assistantCnsTestsThrows */
#include "Macros.hxx" /* ASSUME EXPECTS ENSURES NOEXCEPT NORETURN */
#include "VirusAnalysis.hxx" /* virusAnalysisTestsThrows */
#include <cstdlib> /* exit EXIT_SUCCESS */
Expand All @@ -27,8 +27,8 @@ int testHarnesses() EXPECTS(true) ENSURES(true) {
} else {
std::cout << "error" << std::endl;
}
std::cout << "conversationCnsTestsThrows(): " << std::flush;
if(conversationCnsTestsThrows()) {
std::cout << "assistantCnsTestsThrows(): " << std::flush;
if(assistantCnsTestsThrows()) {
std::cout << "pass" << std::endl;
} else {
std::cout << "error" << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ $CXX -c ${sSRC}/ClassSha2.cxx
$CXX -c ${sSRC}/ClassResultList.cxx
$CXX -c ${sSRC}/ClassCns.cxx
$CXX -c ${sSRC}/VirusAnalysis.cxx
$CXX -c ${sSRC}/ConversationCns.cxx
$CXX -c ${sSRC}/AssistantCns.cxx
$CXX -c ${sSRC}/main.cxx
$CXX sha1.o sha224-256.o sha384-512.o ClassSha2.o ClassResultList.o ClassCns.o VirusAnalysis.o ConversationCns.o main.o
$CXX sha1.o sha224-256.o sha384-512.o ClassSha2.o ClassResultList.o ClassCns.o VirusAnalysis.o AssistantCns.o main.o
set +x

Loading

0 comments on commit 2204ed7

Please sign in to comment.