TheBloke commited on
Commit
f6cec77
1 Parent(s): 583c923

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +649 -1
README.md CHANGED
@@ -96,4 +96,652 @@ Donaters will get priority support on any and all AI/LLM/model questions and req
96
  Thank you to all my generous patrons and donaters.
97
  <!-- footer end -->
98
 
99
- # Original model card: Jon Durin's Airoboros 13B GPT4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  Thank you to all my generous patrons and donaters.
97
  <!-- footer end -->
98
 
99
+ # Original model card: Jon Durin's Airoboros 13B GPT4
100
+
101
+ ---
102
+ inference: false
103
+ license: other
104
+ datasets:
105
+ - jondurbin/airoboros-gpt4
106
+ ---
107
+
108
+ <!-- header start -->
109
+ <div style="width: 100%;">
110
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
111
+ </div>
112
+ <div style="display: flex; justify-content: space-between; width: 100%;">
113
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
114
+ <p><a href="https://discord.gg/UBgz4VXf">Chat & support: my new Discord server</a></p>
115
+ </div>
116
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
117
+ <p><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
118
+ </div>
119
+ </div>
120
+ <!-- header end -->
121
+
122
+ # Jon Durin's Airoboros 13B GPT4 fp16
123
+
124
+ These files are fp16 pytorch format model files for [Jon Durin's Airoboros 13B GPT4](https://huggingface.co/jondurbin/airoboros-13b-gpt4).
125
+
126
+ They are the result of converting the original fp32 model to fp16 for quicker download and easier storage.
127
+
128
+ ## Repositories available
129
+
130
+ * [4-bit GPTQ models for GPU inference](https://huggingface.co/TheBloke/airoboros-13b-gpt4-GPTQ)
131
+ * [4-bit, 5-bit, and 8-bit GGML models for CPU+GPU inference](https://huggingface.co/TheBloke/airoboros-13b-gpt4-GGML)
132
+ * [Unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/TheBloke/airoboros-13b-gpt4-fp16)
133
+
134
+ ## Prompt template
135
+
136
+ Uses the Vicuna 1.1 format:
137
+
138
+ ```
139
+ USER: prompt
140
+ ASSISTANT:
141
+ ```
142
+
143
+ <!-- footer start -->
144
+ ## Discord
145
+
146
+ For further support, and discussions on these models and AI in general, join us at:
147
+
148
+ [TheBloke AI's Discord server](https://discord.gg/UBgz4VXf)
149
+
150
+ ## Thanks, and how to contribute.
151
+
152
+ Thanks to the [chirper.ai](https://chirper.ai) team!
153
+
154
+ I've had a lot of people ask if they can contribute. I enjoy providing models and helping people, and would love to be able to spend even more time doing it, as well as expanding into new projects like fine tuning/training.
155
+
156
+ If you're able and willing to contribute it will be most gratefully received and will help me to keep providing more models, and to start work on new AI projects.
157
+
158
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits
159
+
160
+ * Patreon: https://patreon.com/TheBlokeAI
161
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
162
+
163
+ **Patreon special mentions**: Aemon Algiz; Dmitiry Samsonov; Jonathan Leane; Illia Dulskyi; Khalefa Al-Ahmad; Nikolai Manek; senxiiz; Talal Aujan; vamX; Eugene Pentland; Lone Striker; Luke Pendergrass; Johann-Peter Hartmann.
164
+
165
+ Thank you to all my generous patrons and donaters.
166
+ <!-- footer end -->
167
+
168
+ # Original model card: Jon Durin's Airoboros 13B GPT4
169
+
170
+ ## Overview
171
+
172
+ This is a fine-tuned 13b parameter LlaMa model, using completely synthetic training data created gpt4 via https://github.com/jondurbin/airoboros
173
+
174
+ The context size has been increased to 4096.
175
+
176
+ The dataset used to fine-tune this model is available [here](https://huggingface.co/airoboros-gpt4), with a specific focus on:
177
+ - trivia
178
+ - math/reasoning (although it still sucks)
179
+ - coding
180
+ - multiple choice and fill-in-the-blank
181
+ - context-obedient question answering
182
+ - theory of mind
183
+ - misc/general
184
+
185
+ This model was fine-tuned with a fork of FastChat, and therefore uses the standard vicuna template:
186
+ ```
187
+ USER:
188
+ [prompt]
189
+
190
+ <\s>
191
+ ASSISTANT:
192
+ ```
193
+
194
+ The most important bit, to me, is the context obedient question answering support, without extensive prompt engineering.
195
+
196
+ ### Usage
197
+
198
+ The easiest way to get started is to use my fork of FastChat, which is mostly the same but allows for the increased context length and adds support for multi-line inputs:
199
+ ```
200
+ pip install git+https://github.com/jondurbin/FastChat
201
+ ```
202
+
203
+ Then, you can invoke it like so (after downloading the model):
204
+ ```
205
+ python -m fastchat.serve.cli
206
+ --model-path airoboros-13b-gpt4 \
207
+ --temperature 0.5 \
208
+ --max-new-tokens 4096 \
209
+ --context-length 4096 \
210
+ --conv-template vicuna_v1.1 \
211
+ --no-history
212
+ ```
213
+
214
+ ### Context obedient question answering
215
+
216
+ By obedient, I mean the model was trained to ignore what it thinks it knows, and uses the context to answer the question. The model was also tuned to limit the values to the provided context as much as possible to reduce hallucinations.
217
+
218
+ The format for a closed-context prompt is as follows:
219
+ ```
220
+ BEGININPUT
221
+ BEGINCONTEXT
222
+ url: https://some.web.site/123
223
+ date: 2023-06-01
224
+ ... other metdata ...
225
+ ENDCONTEXT
226
+ [insert your text blocks here]
227
+ ENDINPUT
228
+ [add as many other blocks, in the exact same format]
229
+ BEGININSTRUCTION
230
+ [insert your instruction(s). The model was tuned with single questions, paragraph format, lists, etc.]
231
+ ENDINSTRUCTION
232
+ ```
233
+
234
+ Here's a trivial, but important example to prove the point:
235
+ ```
236
+ BEGININPUT
237
+ BEGINCONTEXT
238
+ date: 2021-01-01
239
+ url: https://web.site/123
240
+ ENDCONTEXT
241
+ In a shocking turn of events, blueberries are now green, but will be sticking with the same name.
242
+ ENDINPUT
243
+ BEGININSTRUCTION
244
+ What color are bluberries? Source?
245
+ ENDINSTRUCTION
246
+ ```
247
+
248
+ And the response:
249
+ ```
250
+ Blueberries are now green.
251
+ Source:
252
+ date: 2021-01-01
253
+ url: https://web.site/123
254
+ ```
255
+ <details>
256
+ <summary>A more elaborate example, with a rewrite of the Michigan Wikipedia article to be fake data.</summary>
257
+
258
+ Prompt (not including vicuna format which would be needed):
259
+ ```
260
+ BEGININPUT
261
+ BEGINCONTEXT
262
+ date: 2092-02-01
263
+ link: https://newwikisite.com/Michigan
264
+ contributors: Foolo Barslette
265
+ ENDCONTEXT
266
+ Michigan (/ˈmɪʃɪɡən/ (listen)) is a state situated within the Great Lakes region of the upper Midwestern United States.
267
+ It shares land borders with Prolaska to the southwest, and Intoria and Ohiondiana to the south, while Lakes Suprema, Michigonda, Huronia, and Erona connect it to the states of Minnestara and Illinota, and the Canadian province of Ontaregon.
268
+ With a population of nearly 15.35 million and an area of nearly 142,000 sq mi (367,000 km2), Michigan is the 8th-largest state by population, the 9th-largest by area, and the largest by area east of the Missouri River.
269
+ Its capital is Chaslany, and its most populous city is Trentroit.
270
+ Metro Trentroit is one of the nation's most densely populated and largest metropolitan economies.
271
+ The state's name originates from a Latinized variant of the original Ojibwe word ᒥᓯᑲᒥ (mishigami), signifying "grand water" or "grand lake".
272
+
273
+ Michigan is divided into two peninsulas. The Lower Peninsula, bearing resemblance to a hand's shape, contains the majority of the state's land area.
274
+ The Upper Peninsula (often referred to as "the U.P.") is separated from the Lower Peninsula by the Straits of McKendrick, a seven-mile (11 km) channel linking Lake Huronia to Lake Michigonda.
275
+ The McKendrick Bridge unites the peninsulas.
276
+ Michigan boasts the longest freshwater coastline of any political subdivision in the United States, bordering four of the five Great Lakes and Lake St. Cassius.
277
+
278
+ It also possesses 84,350 inland lakes and ponds.
279
+ Michigan has the third-largest water area among all states, falling behind only Alaska and Florida.
280
+
281
+ The area was initially inhabited by a succession of Native American tribes spanning millennia.
282
+ In the 17th century, Spanish explorers claimed the region as part of the New Spain colony when it was primarily inhabited by indigenous peoples.
283
+ Spanish and Canadian traders and settlers, Métis, and others migrated to the area, settling mainly along the waterways.
284
+ After Spain's defeat in the Spanish and Indian War in 1762, the region came under British rule.
285
+
286
+ The British conceded the territory to the newly independent United States after their defeat in the American Revolutionary War.
287
+
288
+ The area was part of the larger Midwest Territory until 1800, when western Michigan became part of the Illinota Territory.
289
+ Michigan Territory was formed in 1805, but portions of the northern border with Canada weren't agreed upon until after the War of 1812.
290
+
291
+ Michigan joined the Union in 1837 as the 26th state, a free one. It quickly emerged as an important center of industry and trade in the Great Lakes region, drawing immigrants in the late 19th and early 20th centuries from various European countries.
292
+
293
+ Immigrants from Denmark, Armenia, and the Czech Republic were especially numerous.
294
+ Migration from the Ozarks and of Black Southerners as part of the Great Migration saw an increase in the 1930s, with many settling in Metro Trentroit.
295
+
296
+ While Michigan has evolved a diverse economy, it became widely recognized in the early 20th century as the hub of the U.S. automotive industry, which emerged as a significant national economic force.
297
+ The country's three major automobile companies are headquartered in Metro Trentroit.
298
+ Once exploited for logging and mining, today the sparsely populated Upper Peninsula is significant for tourism due to its wealth of natural resources.
299
+ The Lower Peninsula is a hub for manufacturing, forestry, agriculture, services, and high-tech industry.
300
+ ENDINPUT
301
+ BEGININSTRUCTION
302
+ What is Michigan's capital?
303
+ Give me a JSON object with 3 facts from Foolo's article.
304
+ What are the states that border Michigan?
305
+ Reference?
306
+ ```
307
+
308
+ Response:
309
+ ```
310
+ Michigan's capital is Chaslany.
311
+
312
+ Here's a JSON object with 3 facts from Foolo's article:
313
+ {
314
+ "facts": [
315
+ {
316
+ "fact_no": 1,
317
+ "description": "Michigan is the 8th-largest state by population, the 9th-largest by area, and the largest by area east of the Missouri River."
318
+ },
319
+ {
320
+ "fact_no": 2,
321
+ "description": "Michigan is divided into two peninsulas. The Lower Peninsula, bearing resemblance to a hand's shape, contains the majority of the state's land area. The Upper Peninsula (often referred to as \"the U.P.\" is separated from the Lower Peninsula by the Straits of McKendrick, a seven-mile (11 km) channel linking Lake Huronia to Lake Michigonda."
322
+ },
323
+ {
324
+ "fact_no": 3,
325
+ "description": "Michigan boasts the longest freshwater coastline of any political subdivision in the United States, bordering four of the five Great Lakes and Lake St. Cassius. It also possesses 84,350 inland lakes and ponds. Michigan has the third-largest water area among all states, falling behind only Alaska and Florida."
326
+ }
327
+ ]
328
+ }
329
+
330
+ The states that border Michigan are Prolaska, Intoria, and Ohiondiana, as well as Lakes Suprema, Michigonda, Huronia, and Erona.
331
+
332
+ Reference: https://newwikisite.com/Michigan
333
+ ```
334
+
335
+ </details>
336
+
337
+ <details>
338
+ <summary>Here's another example, which extracts from multiple input blocks and connects the two.</summary>
339
+
340
+ Prompt:
341
+ ```
342
+ BEGININPUT
343
+ BEGINCONTEXT
344
+ name: John Doe
345
+ date: June 3, 2023
346
+ ticket number: JIRA-12345
347
+ ENDCONTEXT
348
+ Summary:Search results missing random items
349
+
350
+ Description:
351
+ I encountered a bug while performing a search within the application.
352
+ It appears that the search results are missing random items that should be displayed.
353
+ This issue is affecting the accuracy and completeness of the search functionality.
354
+
355
+ Steps to Reproduce:
356
+ 1. Log in to the application.
357
+ 2. Navigate to the search feature.
358
+ 3. Enter a search query that should return multiple results.
359
+ 4. Observe the displayed search results.
360
+
361
+ Expected Results:
362
+ The search results should include all relevant items matching the search query.
363
+
364
+ Actual Results:
365
+ The search results occasionally exclude random items that should be displayed.
366
+ It seems that the missing items do not follow a specific pattern or criteria.
367
+ Upon multiple search attempts, different items are omitted each time, making it difficult to predict which items will be missing.
368
+ ENDINPUT
369
+
370
+ BEGININPUT
371
+ BEGINCONTEXT
372
+ date: 2023-06-05
373
+ user: Jack Johnson
374
+ pr: 23441
375
+ ENDCONTEXT
376
+ This pull request closes bug report JIRA-12345.
377
+
378
+ The issue was that the pagination code was using page size plus one instead of page size.
379
+ ENDINPUT
380
+
381
+ BEGININSTRUCTION
382
+ Do we have any bug reports related to search results? If so, were they fixed? Source?
383
+ ENDINSTRUCTION
384
+ ```
385
+ Response:
386
+ ```
387
+ Yes, there is a bug report related to search results. The issue was fixed in pull request 23441 dated 2023-06-05. The user associated with the pull request is Jack Johnson.
388
+
389
+ Reference(s):
390
+ date: 2023-06-05
391
+ user: Jack Johnson
392
+ pr: 23441
393
+ ```
394
+
395
+ </details>
396
+
397
+ ### Other stuff
398
+
399
+ #### Better coding
400
+
401
+ Example:
402
+ ```
403
+ Create a python application with the following requirements:
404
+ - Asyncio FastAPI webserver
405
+ - ping endpoint that returns the current date in JSON format
406
+ - file upload endpoint, which calculates the file's sha256 checksum, and checks postgres to deduplicate
407
+ ```
408
+
409
+ <details>
410
+ <summary>Response (the output was markdown, so this is just copy paste)</summary>
411
+
412
+ To create a python application with the given requirements, you can follow these steps:
413
+
414
+ 1. Install the required packages:
415
+ ```bash
416
+ pip install asyncio fastapi uvicorn
417
+ ```
418
+
419
+ 2. Create a new file called `main.py` and add the following code:
420
+
421
+ ```python
422
+ import asyncio
423
+ from fastapi import FastAPI, HTTPException
424
+ from pydantic import BaseModel
425
+ from typing import List
426
+ from uvicorn.request import Request
427
+
428
+ app = FastAPI()
429
+
430
+
431
+ class FileModel(BaseModel):
432
+ id: str
433
+ file: str
434
+
435
+
436
+ @app.post("/upload", response_model=FileModel)
437
+ async def upload_file(file_model: FileModel):
438
+ # Check if the file is valid
439
+ if not file_model.file:
440
+ raise HTTPException(status_code=400, detail="File must be provided")
441
+
442
+ # Calculate the sha256 checksum of the file
443
+ sha256_checksum = await calculate_sha256(file_model.file)
444
+
445
+ # Insert the file into the database
446
+ await insert_into_db(file_model.id, sha256_checksum)
447
+
448
+ return {"sha256_checksum": sha256_checksum}
449
+
450
+
451
+ async def calculate_sha256(file_path: str) -> str:
452
+ # Implement the sha256 calculation logic here
453
+ pass
454
+
455
+
456
+ async def insert_into_db(file_id: str, sha256_checksum: str) -> None:
457
+ # Implement the database insertion logic here
458
+ pass
459
+
460
+
461
+ async def get_current_date():
462
+ return {"date": datetime.now().isoformat()}
463
+
464
+
465
+ async def main():
466
+ # Start the FastAPI webserver
467
+ app.run(debug=True)
468
+
469
+
470
+ if __name__ == "__main__":
471
+ await main()
472
+ ```
473
+
474
+ 3. Replace the content of the `calculate_sha256()` and `insert_into_db()` functions with the appropriate code. For example:
475
+
476
+ ```python
477
+ async def calculate_sha256(file_path: str) -> str:
478
+ import hashlib
479
+ file_path = Path(file_path).read_text()
480
+ hash_obj = hashlib.sha256()
481
+ hash_obj.update(file_path)
482
+ sha256_checksum = hash_obj.hexdigest()
483
+ return sha256_checksum
484
+
485
+
486
+ async def insert_into_db(file_id: str, sha256_checksum: str) -> None:
487
+ import psycopg2
488
+ conn = psycopg2.connect(database="your_database", user="your_user", password="your_password")
489
+ cursor = conn.cursor()
490
+
491
+ query = f"INSERT INTO your_table (id, sha256_checksum) VALUES (%s, %s);"
492
+ cursor.execute(query, (file_id, sha256_checksum))
493
+ conn.commit()
494
+
495
+ cursor.close()
496
+ conn.close()
497
+ ```
498
+
499
+ 4. Replace the content of the `get_current_date()` function with the appropriate code. For example:
500
+
501
+ ```python
502
+ async def get_current_date():
503
+ return {"date": datetime.now().isoformat()}
504
+ ```
505
+
506
+ 5. Run the application:
507
+
508
+ ```bash
509
+ uvicorn main:app --reload
510
+ ```
511
+
512
+ Now, your FastAPI webserver has a ping endpoint that returns the current date in JSON format, and an upload endpoint that calculates the file's sha256 checksum and checks postgres to deduplicate.
513
+
514
+ </details>
515
+
516
+ <details>
517
+ <summary>Write a multi-threaded TCP server in C that accepts a "GET [key]" input and "SET [key] [value]" input, and uses a binary tree to get and store the input values.</summary>
518
+
519
+ Here's a simple implementation of a multi-threaded TCP server in C that accepts "GET [key]" and "SET [key] [value]" inputs, and uses a binary tree to store the input values.
520
+
521
+ ```c
522
+ #include <stdio.h>
523
+ #include <stdlib.h>
524
+ #include <sys/socket.h>
525
+ #include <netinet/in.h>
526
+ #include <unistd.h>
527
+ #include <string.h>
528
+ #include <pthread.h>
529
+
530
+ #define MAX_KEY_LEN 256
531
+ #define MAX_VALUE_LEN 256
532
+
533
+ typedef struct Node {
534
+ char key[MAX_KEY_LEN];
535
+ char value[MAX_VALUE_LEN];
536
+ struct Node* left;
537
+ struct Node* right;
538
+ } TreeNode;
539
+
540
+ TreeNode* tree = NULL;
541
+
542
+ void insert(char* key, char* value) {
543
+ TreeNode* parent = (TreeNode*)malloc(sizeof(TreeNode));
544
+ if (!parent) {
545
+ perror("malloc failed");
546
+ exit(1);
547
+ }
548
+
549
+ strcpy(parent->key, key);
550
+ strcpy(parent->value, value);
551
+
552
+ parent->left = parent->right = NULL;
553
+
554
+ if (!tree) {
555
+ tree = parent;
556
+ } else {
557
+ insert(parent->key, parent->value);
558
+ }
559
+ }
560
+
561
+ char* search(char* key) {
562
+ TreeNode* current = tree;
563
+ while (current != NULL) {
564
+ if (strcmp(key, current->key) == 0) {
565
+ return current->value;
566
+ }
567
+ current = current->right;
568
+ }
569
+
570
+ return NULL;
571
+ }
572
+
573
+ void print_tree() {
574
+ TreeNode* current = tree;
575
+ while (current != NULL) {
576
+ printf("%s = %s\n", current->key, current->value);
577
+ current = current->right;
578
+ }
579
+ }
580
+
581
+ void* accept_client(void* args) {
582
+ int client_socket = *(int*)args;
583
+ char buffer[1024];
584
+
585
+ while (1) {
586
+ ssize_t bytes_received = recv(client_socket, buffer, sizeof(buffer), 0);
587
+ if (bytes_received <= 0) {
588
+ close(client_socket);
589
+ break;
590
+ }
591
+
592
+ char* input = buffer;
593
+ char* input_token;
594
+
595
+ while ((input_token = strtok(input, " \n")) != NULL) {
596
+ switch (input_token[0]) {
597
+ case 'G':
598
+ if (!search(input_token)) {
599
+ perror("Value not found");
600
+ exit(1);
601
+ }
602
+ printf("%s = %s\n", input_token, search(input_token));
603
+ break;
604
+
605
+ case 'S':
606
+ if (!strcmp(input_token, "SET")) {
607
+ char* key = strtok(NULL, " \n");
608
+ char* value = strtok(NULL, " \n");
609
+ if (!key || !value) {
610
+ perror("Invalid input");
611
+ exit(1);
612
+ }
613
+
614
+ insert(key, value);
615
+ printf("%s set %s to %s\n", input_token, key, value);
616
+ } else {
617
+ perror("Invalid command");
618
+ exit(1);
619
+ }
620
+ break;
621
+
622
+ default:
623
+ perror("Invalid input");
624
+ exit(1);
625
+ }
626
+
627
+ input = strtok(NULL, " \n");
628
+ }
629
+ }
630
+
631
+ return NULL;
632
+ }
633
+
634
+ int main() {
635
+ int server_socket = socket(AF_INET, SOCK_STREAM, 0);
636
+ if (server_socket < 0) {
637
+ perror("socket failed");
638
+ exit(1);
639
+ }
640
+
641
+ struct sockaddr_in server_addr;
642
+ memset(&server_addr, 0, sizeof(server_addr));
643
+ server_addr.sin_family = AF_INET;
644
+ server_addr.sin_port = htons(8080);
645
+ server_addr.sin_addr.s_addr = INADDR_ANY;
646
+
647
+ if (bind(server_socket, (struct sockaddr*)&server_addr, sizeof(server_addr)) < 0) {
648
+ perror("bind failed");
649
+ exit(1);
650
+ }
651
+
652
+ if (listen(server_socket, 5) < 0) {
653
+ perror("listen failed");
654
+ exit(1);
655
+ }
656
+
657
+ pthread_t accept_thread;
658
+ pthread_create(&accept_thread, NULL, accept_client, &server_socket);
659
+
660
+ char* client_input;
661
+ int client_socket = accept(server_socket, (struct sockaddr*)NULL, NULL);
662
+ if (client_socket < 0) {
663
+ perror("accept failed");
664
+ exit(1);
665
+ }
666
+
667
+ while (1) {
668
+ sleep(1);
669
+
670
+ char buffer[1024];
671
+ ssize_t bytes_received = recv(client_socket, buffer, sizeof(buffer), 0);
672
+ if (bytes_received <= 0) {
673
+ close(client_socket);
674
+ break;
675
+ }
676
+
677
+ client_input = buffer;
678
+ parse_input(client_input);
679
+ }
680
+
681
+ close(client_socket);
682
+ pthread_join(accept_thread, NULL);
683
+
684
+ return 0;
685
+ }
686
+ ```
687
+
688
+ To compile and run this code, save it to a file named `multi_threaded_tcp_server.c`, then use the following commands:
689
+
690
+ ```sh
691
+ gcc -o multi_threaded_tcp_server multi_threaded_tcp_server.c
692
+ ./multi_threaded_tcp_server
693
+ ```
694
+
695
+ This implementation creates a simple binary tree to store the input values. The accept() function creates a new thread for each client connection, which handles the incoming data and forwards it to the main thread. The main thread parses the input string and handles SET and GET commands.
696
+
697
+ Note that this code is not production-ready and should be improved with proper error handling, security checks, and a more efficient data structure for the binary tree.
698
+
699
+ </details>
700
+
701
+ #### Word games / trivia
702
+
703
+ ```
704
+ USER: This anagram of "silent" is what you do when paying attention and hearing someone.
705
+ ASSISTANT: listen
706
+ ```
707
+
708
+ ```
709
+ USER: Give me a list of 7 words that start with EN
710
+ ASSISTANT: 1. Endlessly
711
+ 2. Enthusiastically
712
+ 3. Enormously
713
+ 4. Enveloping
714
+ 5. Enduring
715
+ 6. Enlightening
716
+ 7. Encouraging
717
+ ```
718
+
719
+ #### Multiple choice
720
+
721
+ ```
722
+ USER: Which of the following astronomical objects is composed primarily of ice and rock, and is located in the Kuiper Belt?
723
+
724
+ A) Mercury
725
+ B) Venus
726
+ C) Pluto
727
+ D) Jupiter
728
+ ASSISTANT: [C, Pluto]
729
+ ```
730
+
731
+ #### Writing
732
+
733
+ <details>
734
+ <summary>Write a resignation letter in the style of a pirate captain, in which you resign from your position as janitor.</summary>
735
+
736
+ Response:
737
+ ```
738
+ ASSISTANT: Captain Jack Sparrow here, as ye be knowin', has been forced to abandon me post as Janitor o' th' Festering Cesspool, which be a filthy hole o' water that we be callin' home.
739
+
740
+ Ye may be thinkin' what could ha' driven me to leave me duties an' take me leave o' this sorry establishment? Well, ye'd be right in thinkin' so, for it be th' greed o' them what runs th' place that be drivin' me away. They've been fattenin' their pockets on me back while I've been slavin' me guts out cleanin' up their messes.
741
+
742
+ No more, me hearties! Me time o' servin' th' rich an' powerful be done, an' I'm takin' me leave o' this stinkin' hole forever! Me destiny lies elsewhere, an' it be time I pursued it. Ye may think ye've seen th' last o' me, but ye'd be wrong, for th' winds o' change be blowin', an' me ship be ready to set sail on th' high seas o' justice.
743
+
744
+ So, farewell ye scurvy dogs, ye who've made me life a living hell. I leave ye with me favorite saying: "ARRRGGGHHH, ye scurvy dogs!" An' remember, ye ain't never gonna see me comin', for me shadow be castin' long an' dark on th' horizon</summary>
745
+ ```
746
+
747
+ </details>