-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAssistantCns.hxx
79 lines (71 loc) · 4.93 KB
/
AssistantCns.hxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* (C) 2024 Swudu Susuwu, dual licenses: choose [GPLv2](./LICENSE_GPLv2) or [Apache 2](./LICENSE), allows all uses. */
#pragma once
#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 "ClassSys.hxx" /* templateCatchAll */
#include "Macros.hxx" /* SUSUWU_NOEXCEPT SUSUWU_UNIT_TESTS */
#include <iostream> /* std::cout */
#include <ostream> /* std::ostream */
#include <string> /* std::string */
#include <vector> /* std::vector */
/* (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 {
extern Cns assistantCns;
extern std::string assistantCnsResponseDelimiter;
#if SUSUWU_UNIT_TESTS
/* if (with example inputs) these functions (`assistantCnsDownloadHosts()` `produceAssistantCns()`) pass, `return true;`
* @throw std::bad_alloc
* @throw std::logic_error
* @pre @code !assistantCns.isPureVirtual() @endcode */
const bool assistantCnsTests();
static const bool assistantCnsTestsNoexcept() SUSUWU_NOEXCEPT {return templateCatchAll(assistantCnsTests, "assistantCnsTests()");}
#endif /* SUSUWU_UNIT_TESTS */
/* Universal Resources Locators of hosts which `assistantCnsDownloadHosts()` 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 )
*/
extern std::vector<FilePath> assistantCnsDefaultHosts;
/* @throw std::bad_alloc
* @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 assistantCnsDownloadHosts(ResultList &questionsOrNull, ResultList &responsesOrNull, const std::vector<FilePath> &hosts = assistantCnsDefaultHosts);
void assistantCnsProcessXhtml(ResultList &questionsOrNull, ResultList &responsesOrNull, const FilePath &localXhtml = "index.xhtml");
const std::vector<FilePath> assistantCnsProcessUrls(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 assistantCnsProcessQuestion(const FilePath &localXhtml = "index.xhtml"); /* TODO: regex or XML parser */
const std::vector<FileBytecode> assistantCnsProcessResponses(const FilePath &localXhtml = "index.xhtml"); /* TODO: regex or XML parser */
/* @pre `questionsOrNull` maps to `responsesOrNull`,
* `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 `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 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 assistantCnsLoopProcess(const Cns &cns, std::ostream &os = std::cout);
/* Related to this:
* 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;
* https://swudususuwu.substack.com/p/albatross-performs-lots-of-neural
*
* Autonomous robots (includes responses to replies from lots of forums);
* https://swudususuwu.substack.com/p/program-general-purpose-robots-autonomous
*
* Simple examples of CNS as virus analysis;
* https://swudususuwu.substack.com/p/howto-produce-better-virus-scanners
*
* Due to understanding of human's consciousness, could undo problems of overpopulation and food shortages, if lots of us become uploads of consciousness (as opposed to below article of how to move whole CNS to robots);
* https://swudususuwu.substack.com/p/want-this-physical-form-gone-so-wont
* https://swudususuwu.substack.com/p/destructive-unreversible-upload-of
*/
}; /* namespace Susuwu */
#endif /* ndef INCLUDES_cxx_AssistantCns_hxx */