You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And... voila! A simple discord bot that lets you talk to GPT. The models do not have memory of the past requests and so at present, it just works as a relay layer. But we want more from it. We want to have a conversation with it, and not just use it for one-off fact checking. And to have a conversation, both parties need to be able to retain earlier parts of the conversation (at least within reasonable limits). We humans can do that naturally, but how would GPT do that? For this, we would need to do a little extra to make it 'remember'.
172
172
173
-
GPT's chat completion API works by treating whatever you pass in the `messages` field of the request as context. It is by design allowed to pass (an optional) system message and a series of exchanges between the user and the GPT(assistant). You can use this either for few-shot prompting, or you could also use this to pass relevant bits of the conversation history so that GPT has access to past conversation and can reference that information as needed. Below is a sample of what the `messages` field would look like.
173
+
GPT's chat completion API works by treating whatever you pass in the `messages` field of the request as context. It is, by design, allowed to pass (an optional) system message and a series of exchanges between the user and the GPT(assistant). You can use this either for few-shot prompting, or you could also use this to pass relevant bits of the conversation history so that GPT has access to past conversation and can reference that information as needed. Below is a sample of what the `messages` field would look like.
To help the model remember, add every turn of the conversation to the `messages` list field.
191
191
192
-
Something to be cognisant of here is that the request has a limit of 4096 token. If the request is larger than 4096 tokens, it would be rejected. Ensure that your request is always under 4096 tokens. The API response also typically tells you how many tokens were used for the prompt and the completion. But relying only on that to understand your token usage can be expensive. It's recommended to calculate the number of tokens in your request before you send it out. You can use the [tiktoken](https://github.com/openai/tiktoken) library for this.
192
+
Something to be cognisant of here is that the request has a limit of 4096 token. If the request is larger than 4096 tokens, it would be rejected. Ensure that your request is always under 4096 tokens. The API response also typically tells you how many tokens were used for the prompt and the completion. However, relying only on that to understand your token usage can be expensive. It's recommended to calculate the number of tokens in your request before you send it out. You can use the [tiktoken](https://github.com/openai/tiktoken) library for this.
193
193
194
194
And what do we do when we exceed the token limit? There are multiple ways you could approach this
Copy file name to clipboardExpand all lines: content/blog/linux-memory-swap.md
+5-7Lines changed: 5 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,17 +8,14 @@ weight: 1
8
8
---
9
9
10
10
11
-
# Introduction
11
+
## Introduction
12
12
13
13
<pstyle='text-align: justify;'>This blog will help you figure out how to check how much memory is left on your Linux machine. Knowing this will tell you if your server is running low on memory and needs attention, or if everything is fine. Following this, an explanation will be provided regarding the concept of swap and its relevance for the operation of a Linux machine or server.</p>
<pstyle='text-align: justify;'>Htop is a resource monitoring utility, here we can see the amount of resources being used and how much memory is being used htop also shows the number of CPUs, the average CPU usage, and the amount of swap usage</p>
@@ -27,7 +24,7 @@ weight: 1
27
24
28
25
<pstyle='text-align: justify;'>Next, we will explore how to view the amount of memory usage without relying on third-party utilities. This leads us to the first command, the free command. The free command provides information on the amount of free memory available.</p>
29
26
30
-
### Output of ` free ` command
27
+
### Output of ` free ` command
31
28
32
29
```bash
33
30
@@ -40,6 +37,7 @@ weight: 1
40
37
<pstyle='text-align: justify;'>However, these numbers may not be immediately comprehensible. Therefore, we will utilize the -m option with the free command, which presents the memory statistics in megabytes, making them easier to interpret.</p>
41
38
42
39
### Output of ` free -m ` command
40
+
43
41
```bash
44
42
45
43
user@machineHost:~$ free
@@ -61,7 +59,7 @@ weight: 1
61
59
62
60
Now, we'll shift our focus to swap usage.
63
61
64
-
## **What is Swap?**
62
+
## What is Swap?
65
63
66
64
<pstyle='text-align: justify;'>Swap memory, also known as swap space, is a section of a computer's hard disk or SSD that the operating system (OS) uses to store inactive data from Random Access Memory (RAM). Because swap exists on the hard disk, accessing swap memory is slower compared to accessing RAM.
67
65
While swap is something we hope to avoid using, it serves as a safety net for when RAM becomes full. It's debated whether it's okay to run a Linux server or workstation without swap, but having some swap space, even sparingly like 1GB, doesn't heavily impact the hard disk. Additionally, some applications require swap even if there's available memory.</p>
Copy file name to clipboardExpand all lines: content/blog/office-home-lab-internet-failover-setup.md
+12-9Lines changed: 12 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,14 +24,14 @@ We needed a cost-effective way where if the primary connection(which is ACT for
24
24
to the secondary backup connection(Airtel) and restores back to the primary connection once it regains its connectivity. This led to think about failover/multi-WAN
25
25
setup.
26
26
27
-
# Overview
27
+
##Overview
28
28
29
29
- Two ISP connections (primary and secondary)
30
30
- Failover setup (not load balancing)
31
31
- Quick switching time between ISPs
32
32
- Clients should be part of a single network (IPs allocated from a single DHCP server)
@@ -50,7 +50,8 @@ Internet connection for your Office/Home lab.
50
50
> you will need to use a different router or a network switch to create a WAN port. Some routers also come equipped with multiple WAN
51
51
> ports that can be used as well for failover in case one of the connections fails.
52
52
53
-
## How we go about setting up the internet failover
53
+
### How we go about setting up the internet failover
54
+
54
55
The process to set up internet failover may vary depending on our specific setup and needs, but generally,
55
56
we will need to follow these steps:
56
57
@@ -60,12 +61,13 @@ ACT as our primary as I mentioned due to its high bandwidth and Airtel as our se
60
61
3. Configure the secondary internet connection as a backup gateway in your router or switch.
61
62
4. Test the failover by disconnecting the primary internet connection and verifying that the secondary connection is used automatically.
62
63
63
-
## The configurations to manage
64
+
###The configurations to manage
64
65
65
66
We can manage router configurations by login to the router's web-based configuration page. This can typically be done by entering
66
67
the router's IP address (such as `192.168.1.1`) in a web browser. The configurations will vary with the router you have, here we
67
68
will take an overview of the process we need to follow to manage the router's configuration.
68
-
### 1. Configure WAN/LAN as WAN port
69
+
70
+
#### 1. Configure WAN/LAN as a WAN port
69
71
70
72
- Our router had only one WAN port, We need to convert one of its LAN port to a WAN port as we need two internet sources.
71
73
- Once we have accessed the router's configuration page, look for a section on bridging or port forwarding. From here,
@@ -76,7 +78,7 @@ Now this second port (eth2 in our case) can be used as another WAN port.
76
78
77
79
Now that we have two WAN ports/interfaces (eth1 & eth2) ready to act as our internet sources, the next step is to configure DHCP Clients for these ports.
78
80
79
-
### 2. Setup DHCP client
81
+
####2. Setup DHCP client
80
82
81
83
- Plug in the ISP cables to both the WAN interfaces we just configured in the above step.
82
84
- In the network settings, We need to enable the DHCP client and configure the network settings.
@@ -87,7 +89,7 @@ Each ISP has its own DHCP server, the router acts as a DHCP client for each ISP
87
89
to obtain IP address information from each ISP and use that information to route traffic appropriately. This blog is
88
90
written considering dynamic IP assignments only.
89
91
90
-
### 3. Configure routes
92
+
####3. Configure routes
91
93
92
94
- Now we need to configure the routes for our primary and the secondary internet connection, For that find the settings for
93
95
the routing table, which is typically found in the advanced settings or network settings section of the router's configuration page.
@@ -99,7 +101,7 @@ the higher the priority of the connection. For example, if you have two WAN conn
99
101
connection is used whenever possible, and the secondary connection is only used if the primary connection is
100
102
unavailable.
101
103
102
-
### 4. Setting up the DHCP Server
104
+
####4. Setting up the DHCP Server
103
105
104
106
- We need to have uninterrupted connection for all our devices in the office network. Instead of using the ISP’s DHCP servers
105
107
(both will provide different IPs from different pools), we will be setting up our own DHCP server which will be providing IPs
@@ -109,7 +111,7 @@ Till now all the connections are wired, and we need to provide a wireless access
109
111
will be able to connect wireless. The Access Point is connected to one of the LAN ports and since it is part of the
110
112
bridge network, all the devices connected via access point will be assigned the IP from our DHCP server instead of ISPs.
111
113
112
-
### 5. Testing our setup
114
+
####5. Testing our setup
113
115
114
116
- Although there are a lot of tools available to simulate network failures, we chose a simpler approach to test
115
117
the working of our setup.
@@ -120,6 +122,7 @@ see the secondary/ failover connection kick in and the internet traffic flowing
120
122
the primary ISP.
121
123
122
124
## Conclusion
125
+
123
126
In this article, We had an overview on how to go about setting up the office/home lab internet failover connection. We discussed configuring
124
127
WAN interface, setting and configuring the DHCP client and server, and finally we looked at testing our setup.
0 commit comments