-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a custom venv to the gptd unit file with download, making the footprint smaller and env management way easier. Also, getting closer and closer to plug and play that is good enough for adding to repos. Client is unchanged from 1.1.0, just a bit cleaner.
- Loading branch information
Showing
6 changed files
with
138 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import socket | ||
import os | ||
import threading | ||
import argparse | ||
import sys | ||
|
||
# Path to the Unix domain socket | ||
socket_file_path = "/tmp/gptd.sock" | ||
|
||
def main(): | ||
# Parse command line arguments | ||
parser = argparse.ArgumentParser(description='Flags and arguments for handling connections to gptd') | ||
parser.add_argument('-c', '--closed', help='Start a closed context session') | ||
parser.add_argument('-q', '--quick', action='store_true', help='Close connection immediately. Use with -s for piping, or for testing server availability') | ||
parser.add_argument('-s', '--string', help='Send a string on connecting to server') | ||
args = parser.parse_args() | ||
|
||
# Ensure that the socket file exists | ||
if not os.path.exists(socket_file_path): | ||
print("The server is not running.") | ||
exit(1) | ||
|
||
# Create a socket object | ||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | ||
|
||
def send_data(): | ||
if args.closed: | ||
sock.send("#personal".encode('utf-8')) | ||
|
||
if args.string: | ||
# If a string was passed as a command line argument, send it to the server | ||
sock.sendall(args.string.encode('utf-8')) | ||
|
||
if args.quick: | ||
sock.shutdown(socket.SHUT_WR) | ||
|
||
|
||
else: | ||
while True: | ||
# Get input from the user | ||
message = input() | ||
|
||
# Send the message to the server | ||
sock.sendall(message.encode('utf-8')) | ||
|
||
def receive_data(): | ||
while True: | ||
# Receive the response from the server | ||
data = sock.recv(16) | ||
if data: | ||
print(f"{data.decode('utf-8')}", end='', flush=True) | ||
else: | ||
break | ||
sys.exit(0) # exit after receiving response | ||
|
||
try: | ||
# Connect the socket | ||
sock.connect(socket_file_path) | ||
|
||
# Start threads for sending and receiving data | ||
send_thread = threading.Thread(target=send_data) | ||
receive_thread = threading.Thread(target=receive_data) | ||
send_thread.start() | ||
receive_thread.start() | ||
|
||
# Wait for both threads to finish | ||
send_thread.join() | ||
receive_thread.join() | ||
|
||
finally: | ||
# Close the socket when we're done with it | ||
print("Closing client...") | ||
sock.close() | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
aiohttp==3.8.4 | ||
aiosignal==1.3.1 | ||
annotated-types==0.5.0 | ||
anyio==3.7.0 | ||
async-timeout==4.0.2 | ||
attrs==23.1.0 | ||
certifi==2023.5.7 | ||
charset-normalizer==3.1.0 | ||
exceptiongroup==1.1.1 | ||
fire==0.5.0 | ||
frozenlist==1.3.3 | ||
h11==0.14.0 | ||
httpcore==0.17.2 | ||
httpx==0.24.1 | ||
idna==3.4 | ||
markdown-it-py==3.0.0 | ||
mdurl==0.1.2 | ||
multidict==6.0.4 | ||
openai==0.27.8 | ||
orjson==3.9.1 | ||
pydantic==1.10.7 | ||
pydantic-core==2.0.1 | ||
Pygments==2.15.1 | ||
python-dateutil==2.8.2 | ||
python-dotenv==1.0.0 | ||
requests==2.31.0 | ||
rich==13.4.2 | ||
six==1.16.0 | ||
sniffio==1.3.0 | ||
systemd-python==235 | ||
termcolor==2.3.0 | ||
tqdm==4.65.0 | ||
typing-extensions==4.7.0 | ||
urllib3==2.0.3 | ||
yarl==1.9.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name='gptd-client', | ||
version='0.3', | ||
packages=find_packages(), | ||
entry_points={ | ||
'console_scripts': [ | ||
'gptd-client=gptd_client.client:main', | ||
], | ||
}, | ||
) |