|
| 1 | + |
| 2 | +# Command Line Parameters |
| 3 | + |
| 4 | +You can give parameters on the run command or in a config file. The default config file is `cs_init.txt` at the top |
| 5 | +level of CS (if the file exists). Or you can name where the file is on a command line parameter `config=xxx`. |
| 6 | +Config file data are command line parameters, 1 per line, like below: |
| 7 | +``` |
| 8 | +noboot |
| 9 | +port=20 |
| 10 | +``` |
| 11 | +Actual command line parameters have priority over config file values. |
| 12 | + |
| 13 | + |
| 14 | +## Memory options |
| 15 | + |
| 16 | +Chatscript statically allocates its memory and so (barring unusual circumstance) will not |
| 17 | +allocate memory every during its interactions with users. These parameters can control |
| 18 | +those allocations. Done typically in a memory poor environment like a cellphone. |
| 19 | + |
| 20 | +| option | description |
| 21 | +|--------------|----------------------------------------------------------------------- |
| 22 | +|`buffer=50` | how many buffers to allocate for general use (80 is default) |
| 23 | +|`buffer=15x80`| allocate 15 buffers of 80k bytes each (default buffer size is 80k) |
| 24 | + |
| 25 | +Most chat doesn't require huge output and buffers around 20k each will be more than |
| 26 | +enough. 20 buffers is often enough too (depends on recursive issues in your scripts). |
| 27 | + |
| 28 | +If the system runs out of buffers, it will perform emergency allocations to try to get more, |
| 29 | +but in limited memory environments (like phones) it might fail. You are not allowed to |
| 30 | +allocate less than a 20K buffer size. |
| 31 | + |
| 32 | +| option | description |
| 33 | +|--------------|----------------------------------------------------------------------- |
| 34 | +| `dict=n` | limit dictionary to this size entries |
| 35 | +| `text=n` | limit string space to this many bytes |
| 36 | +| `fact=n` | limit fact pool to this number of facts |
| 37 | +| `hash=n` | use this hash size for finding dictionary words (bigger = faster access) |
| 38 | +| `cache=1x50` | allocate a 50K buffer for handling 1 user file at a time. A server might want to cache multiple users at a time. |
| 39 | + |
| 40 | +A default version of ChatScript will allocate much more than it needs, because it doesn't |
| 41 | +know what you might need. |
| 42 | + |
| 43 | +If you want to use the least amount of memory (multiple servers on a machine or running on a mobile device), |
| 44 | +you should look at the USED line on startup and add small amounts to the entries |
| 45 | +(unless your application does unusual things with facts). |
| 46 | + |
| 47 | +If you want to know how much, try doing `:show stats` and then `:source REGRESS/bigregress.txt`. |
| 48 | +This will run your bot against a wide range of input and the stats at the end |
| 49 | +will include the maximum values needed during a volley. To be paranoid, add beyond those valuse. |
| 50 | +Take your max dict value and double it. Same with max fact. Add 10000 to max text. |
| 51 | + |
| 52 | +Just for reference, for our most advanced bot, the actual max values used were: |
| 53 | +max dict: 346 max fact: 689 max text: 38052. |
| 54 | + |
| 55 | +And the maximum rules executed to find an answer to an input sentence was 8426 (not that you |
| 56 | +control or care). Typical rules executed for an input sentence was 500-2000 rules. |
| 57 | +For example, add 1000 to the dict and fact used amounts and 10 (kb) to the string space |
| 58 | +to have enough normal working room. |
| 59 | + |
| 60 | + |
| 61 | +## Output options |
| 62 | + |
| 63 | +| option | description |
| 64 | +|--------------------|----------------------------------------------------------------------------- |
| 65 | +| `output=nnn` | limits output line length for a bot to that amount (forcing crnl as needed). 0 is unlimited. |
| 66 | +| `outputsize=80000` | is the maximum output that can be shipped by a volley from the bot without getting truncated. |
| 67 | +Actually the value is somewhat less, because routines generating partial data for later incorporation into |
| 68 | +the output also use the buffer and need some usually small amount of clearance. You can find out how close |
| 69 | +you have approached the max in a session by typing `:memstats`. If you need to ship a lot of data around, |
| 70 | +you can raise this into the megabyte range and expect CS will continue to function. 80K is the default. |
| 71 | + |
| 72 | +For normal operation, when you change `outputsize` you should also change `logsize` to be at least as much, so that |
| 73 | +the system can do complete logs. You are welcome to set log size lots smaller if you don't care about the log. |
| 74 | + |
| 75 | + |
| 76 | +## File options |
| 77 | + |
| 78 | +| option | description |
| 79 | +|---------------|----------------------------------------------------------------------------- |
| 80 | +|`livedata=xxx` | name relative or absolute path to your own private LIVEDATA folder. Do not add trailing / on this path<br>Recommended is you use `RAWDATA/yourbotfolder/LIVEDATA` to keep all your data in one place. You can have your own live data, yet use ChatScripts default `LIVEDATA/SYSTEM` and `LIVEDATA/ENGLISH` by providing paths to the `system=` and `english=` parameters as well as the `livedata=` parameter |
| 81 | +|`users=xxx` | name relative or absolute path to where you want the USERS folder to be. Do not add trailing `/` |
| 82 | +|`logs=xxx` | name relative or absolute path to where you want the LOGS folder to be. Do not add trailing `/` |
| 83 | +|`userlog` | Store a user-bot log in USERS directory (default) |
| 84 | +|`nouserlog` | Don't store a user-bot log |
| 85 | + |
| 86 | +## Execution options |
| 87 | +| option | description |
| 88 | +|------------------|----------------------------------------------------------------------------- |
| 89 | +|`source=xxxx` | Analogous to the `:source` command. The file is executed |
| 90 | +|`login=xxxx` | The same as you would name when asked for a login, this avoids having to ask for it. Can be `login=george` or `login=george:harry` or whatever | |
| 91 | +|`build0=filename` | runs `:build` on the filename as level0 and exits with 0 on success or 4 on failure | |
| 92 | +|`build1=filename` | runs `:build` on the filename as level1 and exits with 0 on success or 4 on failure.<br>Eg. ChatScript `build0=files0.txt` will rebuild the usual level 0 | |
| 93 | +|`debug=:xxx` | xxx runs the given debug command and then exits. Useful for `:trim`, for example or more specific `:build` commands |
| 94 | +|`param=xxxxx` | data to be passed to your private code |
| 95 | +|`bootcmd=xxx` | runs this command string before CSBOOT is run; use it to trace the boot process |
| 96 | +|`trace` | turn on all tracing. |
| 97 | +|`redo` | see documentation for :redo in [ChatScript Debugging Manual](ChatScript-Debugging-Manual.md) manual |
| 98 | +|`noboot` | Do not run any boot script on engine startup |
| 99 | + |
| 100 | + |
| 101 | +Here few command line parameters usage examples of usual edit/compile developement phase, running ChatScript from a Linux terminal console (standalone mode): |
| 102 | + |
| 103 | +Rebuild _level0_ (compiling system ChatScript files, listed usually in file `files0.txt`): |
| 104 | +``` |
| 105 | +BINARIES/LinuxChatScript64 local build0=files0.txt |
| 106 | +``` |
| 107 | + |
| 108 | +Rebuild _level1_, compiling bot _Mybot_ (files listed in file `filesMybot.txt`), showing build report on screen (stdout): |
| 109 | + |
| 110 | +``` |
| 111 | +BINARIES/LinuxChatScript64 local build1=filesMybot.txt |
| 112 | +``` |
| 113 | + |
| 114 | +Rebuild and run: If building phase is without building errors, you can run the just built _Mybot_ in local mode (interactive console) with user name _Amy_: |
| 115 | + |
| 116 | +``` |
| 117 | +BINARIES/LinuxChatScript64 local login=Amy |
| 118 | +``` |
| 119 | + |
| 120 | +Build bot _Mybot_ and run ChatScript with user _Amy_: |
| 121 | + |
| 122 | +``` |
| 123 | +BINARIES/LinuxChatScript64 local build1=filesMybot.txt && BINARIES/LinuxChatScript64 local login=Amy |
| 124 | +``` |
| 125 | + |
| 126 | + |
| 127 | +## Bot variables |
| 128 | + |
| 129 | +You can create predefined bot variables by simply naming permanent variables on the |
| 130 | +command line, using V to replace $ (since Linux shell scripts don't like $). Eg. |
| 131 | +``` |
| 132 | +ChatScript Vmyvar=fatcat |
| 133 | +``` |
| 134 | +``` |
| 135 | +ChatScript Vmyvar="tony is here" |
| 136 | +``` |
| 137 | +``` |
| 138 | +ChatScript "Vmyvar=tony is here" |
| 139 | +``` |
| 140 | + |
| 141 | +Quoted strings will be stored without the quotes. Bot variables are always reset to their |
| 142 | +original value at each volley, even if you overwrite them during a volley. This can be |
| 143 | +used to provide server-host specific values into a script. |
| 144 | + |
| 145 | + |
| 146 | +## No such bot-specific - nosuchbotrestart=true |
| 147 | + |
| 148 | +If the system does not recognize the bot name requested, it can automatically restart a |
| 149 | +server (on the presumption that something got damaged). If you don't expect no such bot |
| 150 | +to happen, you can enable this restart using `nosuchbotrestart=true`. Default is false. |
| 151 | + |
| 152 | + |
| 153 | +## Time options |
| 154 | +| option | description |
| 155 | +|------------------|----------------------------------------------------------------------------- |
| 156 | +| `Timer=15000` | if a volley lasts more than 15 seconds, abort it and return a timeout message. |
| 157 | +| `Timer=18000x10` |same as above, but more roughly, higher number after the x reduces how frequently it samples time, reducing the cost of sampling |
| 158 | + |
| 159 | +## `:TranslateConcept` Google API Key |
| 160 | +| option | description |
| 161 | +|------------------|----------------------------------------------------------------------------- |
| 162 | +| `apikey=xxxxxx` | is how you provide a google translate api key to `:translateconcept` |
| 163 | + |
| 164 | +# Security |
| 165 | + |
| 166 | +Typically security parameters only are used in a server configuration. |
| 167 | + |
| 168 | +| option | description |
| 169 | +|------------------|----------------------------------------------------------------------------- |
| 170 | +| `sandbox` | If the engine is not allowed to alter the server machine other than through the standard ChatScript directories, you can start it with the parameter `sandbox` which disables Export and System calls. |
| 171 | +| `nodebug` | Users may not issue debug commands (regardless of authorizations). Scripts can still do so. |
| 172 | +|`authorize=""`| bunch of authorizations "". The contents of the string are just like the contents of the authorizations file for the server. Each entry separated from the other by a space. This list is checked first. If it fails to authorize AND there is a file, then the file will be checked also. Otherwise authorization is denied. |
| 173 | +|`encrypt=xxxxx`<br>`decrypt=xxxxx` | These name URLs that accept JSON data to encrypt and decrypt user data. User data is of two forms, topic data and LTM data. LTM data is intended to be more personalized for a user, so if `encrypt` is set, LTM will be encrypted. User topic data is often just execution state of the user and potentially big, so by default it is not encrypted. You can request encryption using `userencrypt` as a command line parameter to encrypt the topic file and `ltmdecrypt` to encrypt the ltm file. |
| 174 | + |
| 175 | +The JSON data sent to the URL given by the parameters looks like this: |
| 176 | +``` |
| 177 | +{"datavalues": {"x": "..."}} |
| 178 | +``` |
| 179 | +where ... is the text to encrypt or decrypt. Data from CS will be filled into the ... and are JSON compatible. |
| 180 | + |
| 181 | + |
| 182 | +# Server Parameters |
| 183 | + |
| 184 | +Either Mac/LINUX or Windows versions accept the following command line args: |
| 185 | + |
| 186 | +| option | description |
| 187 | +|-----------------------|----------------------------------------------------------------------------- |
| 188 | +| `port=xxx` | This tells the system to be a server and to use the given numeric port. You must do this to tell Windows to run as a server. The standard port is 1024 but you can use any port. |
| 189 | +| `local` | The opposite of the port command, this says run the program as a stand-alone system, not as a server. |
| 190 | +| `interface=127.0.0.1` | By default the value is `0.0.0.0` and the system directly uses a port that may be open to the internet. You can set the interface to a different value and it will set the local port of the TCP connection to what you designate. |
| 191 | + |
| 192 | +# User Data |
| 193 | + |
| 194 | +Scripts can direct the system to store individualized data for a user in the user's topic file |
| 195 | +in USERS. It can store user variables (`$xxx`) or facts. Since variables hold only a single |
| 196 | +piece of information a script already controls how many of those there are. But facts can |
| 197 | +be arbitrarily created by a script and there is no natural limit. |
| 198 | +As these all take up room in the user's file, affecting how long it takes to process a volley |
| 199 | +(due to the time it takes to load and write back a topic file), |
| 200 | +you may want to limit how many facts each user can have written. |
| 201 | +This is unrelated to universal facts the system has at its permanent disposal as part of the base system. |
| 202 | + |
| 203 | +`userfacts=n` limits a user file to saving only the n most recently created facts of a user (this does not include facts stored in fact sets). |
| 204 | +Overridden if the user has `$cs_userfactlimit` set to some value |
| 205 | + |
| 206 | +### User Caching |
| 207 | + |
| 208 | +Each user is tracked via their topic file in USERS. The system must load it and write it |
| 209 | +back for each volley and in some cases will become I/O bound as a result (particularly if |
| 210 | +the filesystem is not local). |
| 211 | + |
| 212 | +You can direct the system to keep a cache in memory of recent users, to reduce the I/O volume. |
| 213 | +It will still write out data periodically, but not every volley. |
| 214 | +Of course if you do this and the server crashes, |
| 215 | +writebacks may not have happened and some system rememberance of user interaction will be lost. |
| 216 | + |
| 217 | +Of course if the system crashes, user's may not think it unusually that the chatbot forgot some of what happened. |
| 218 | +By default, the system automatically writes to disk every volley, If you use a different value, |
| 219 | +a user file will never be more out of date than that. |
| 220 | +``` |
| 221 | +cache=20 |
| 222 | +cache=20x1 |
| 223 | +``` |
| 224 | +This specifies how many users can be cached in memory and how big the cache block in |
| 225 | +kb should be for a user. The default block size is `50` (50,000 bytes). |
| 226 | +User files typically are under 20,000 bytes. |
| 227 | + |
| 228 | +If a file is too big for the block, it will just have to write directly to and from the filesystem. |
| 229 | +The default cache count is 1, telling how many users to cache at once, |
| 230 | +but you can explicitly set how many users get cached with the number after the |
| 231 | +"x". If the second number is 0, then no caching is done and users have no data saved. |
| 232 | +They remember nothing from volley to volley. |
| 233 | + |
| 234 | +Do not use caching with fork. The forks will be hiding user data from each other. |
| 235 | + |
| 236 | +``` |
| 237 | +save=n |
| 238 | +``` |
| 239 | +This specifies how many volleys should elapse before a cached user is saved to disk. |
| 240 | +Default is 1. A value of 0 not only causes a user's data to be written out every volley, but |
| 241 | +also causes the user record to be dropped from the cache, so it is read back in every time |
| 242 | +it is needed (handy when running multi-core copies of chatscript off the same port). |
| 243 | + |
| 244 | +Note, if you change the default to a number higher than 1, you should always use `:quit` |
| 245 | +to end a server. Merely killing the process may result in loss of the most recent user activity. |
| 246 | + |
| 247 | +## Logging or Not |
| 248 | + |
| 249 | +In stand-alone mode the system logs what a user says with a bot in the USERS folder. It |
| 250 | +can also do this in server mode. It can also log what the server itself does. But logging |
| 251 | +slows down the system. Particularly if you have an intervening server running and it is |
| 252 | +logging things, you may have no use whatsoever for ChatScript's logging. |
| 253 | + |
| 254 | +``` |
| 255 | +Userlog |
| 256 | +``` |
| 257 | +Store a user-bot log in USERS directory. Stand-alone default if unspecified. |
| 258 | + |
| 259 | +``` |
| 260 | +Nouserlog |
| 261 | +``` |
| 262 | +Don't store a user-bot log. Server default if unspecified. |
| 263 | + |
| 264 | +``` |
| 265 | +Serverlog |
| 266 | +``` |
| 267 | +Write a server log. Server default if unspecified. The server log will be put into the LOGS |
| 268 | +directory under serverlogxxx.txt where xxx is the port. |
| 269 | + |
| 270 | +``` |
| 271 | +Noserverprelog |
| 272 | +``` |
| 273 | +Normally CS writes of a copy of input before server begins work on it to server log. |
| 274 | +Helps see what crashed the server (since if it crashes you get no log entry). This turns it |
| 275 | +off to improve performance. |
| 276 | + |
| 277 | +``` |
| 278 | +Serverctrlz |
| 279 | +``` |
| 280 | +Have server terminate its output with 0x00 0xfe 0xff as a verification the client received |
| 281 | +the entire message, since without sending to server, client cannot be positive the |
| 282 | +connection wasn't broken somewhere and await more input forever. |
| 283 | + |
| 284 | +``` |
| 285 | +Noserverlog |
| 286 | +``` |
| 287 | +Don't write a server log. |
| 288 | + |
| 289 | +``` |
| 290 | +Fork=n |
| 291 | +``` |
| 292 | +If using LINUX EVSERVER, you can request extra copies of ChatScript (to run on each |
| 293 | +core for example). n specifies how many additional copies of ChatScript to launch. |
| 294 | + |
| 295 | +``` |
| 296 | +Serverretry |
| 297 | +``` |
| 298 | +Allows `:retry` to work from a server - don't use this except for testing a single-person |
| 299 | +on a server as it slows down the server. |
| 300 | + |
| 301 | + |
| 302 | + |
| 303 | +## No such bot-specific - nosuchbotrestart=true |
| 304 | + |
| 305 | +If the system does not recognize the bot name requested, it can automatically restart a |
| 306 | +server (on the presumption that something got damaged). If you don't expect no such bot |
| 307 | +to happen, you can enable this restart using `nosuchbotrestart=true`. Default is false. |
| 308 | + |
| 309 | + |
| 310 | +## Testing a server |
| 311 | + |
| 312 | +There are various configurations for having an instance be a client to test a server. |
| 313 | +``` |
| 314 | +client=xxxx:yyyy |
| 315 | +``` |
| 316 | +This says be a client to test a remote server at IP xxxx and port yyyy. You will be able to |
| 317 | +"login" to this client and then send and receive messages with a server. |
| 318 | + |
| 319 | +``` |
| 320 | +client=localhost:yyyy |
| 321 | +``` |
| 322 | +This says be a client to test a local server on port yyyy. Similar to above. |
| 323 | + |
| 324 | +``` |
| 325 | +Load=1 |
| 326 | +``` |
| 327 | +This creates a localhost client that constantly sends messages to a server. Works its way |
| 328 | +through `REGRESS/bigregress.txt` as its input (over 100K messages). Can assign different |
| 329 | +numbers to create different loading clients (e.g., load=10 creates 10 clients). |
| 330 | + |
| 331 | +``` |
| 332 | +Dual |
| 333 | +``` |
| 334 | +Yet another client. But this one feeds the output of the server back as input for the next |
| 335 | +round. There are also command line parameters for controlling memory usage which are not |
| 336 | +specific to being a server. |
0 commit comments