Metadata-Version: 2.1
Name: socktalk
Version: 0.2.2
Summary: Socket-based AI chat server and multi-user chat client
Project-URL: Source, https://github.com/mdkmk/socktalk
Keywords: chat server,chat client,AI chatbot,chatGPT,OPENAI API,socket programming,select.select(),multi-user chat,real-time communication,Python chat application
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: annotated-types==0.6.0
Requires-Dist: anyio==4.3.0
Requires-Dist: certifi==2024.2.2
Requires-Dist: distro==1.9.0
Requires-Dist: exceptiongroup==1.2.0
Requires-Dist: h11==0.14.0
Requires-Dist: httpcore==1.0.5
Requires-Dist: httpx==0.27.0
Requires-Dist: idna==3.7
Requires-Dist: openai==1.14.2
Requires-Dist: pydantic==2.6.4
Requires-Dist: pydantic_core==2.16.3
Requires-Dist: PyQt5==5.15.10
Requires-Dist: PyQt5-Qt5==5.15.2
Requires-Dist: PyQt5-sip==12.13.0
Requires-Dist: sniffio==1.3.1
Requires-Dist: tqdm==4.66.2
Requires-Dist: typing_extensions==4.11.0

# socktalk - A Robust Socket-based AI Chat Server and Multi-user Chat Client

**socktalk** is a chat server and client developed using Python's socket programming. It affords real-time, multi-user interactions and integrates with OpenAI's GPT models to offer an AI-driven chatting experience.

## Features
- **Multi-User Support**: Manages multiple connections simultaneously to support multi-user interactions.
- **Efficient Message Handling**: Uses non-blocking sockets and `select.select()` for real-time, concurrent message processing.
- **AI Integration**: Augments multi-user chat with AI-driven responses, configurable for different operational modes.
- **Standardized Protocol**: Implements a simple message protocol with fixed-length headers to streamline communication.
- **Versatile Client Options**: Offers both a sophisticated graphical user interface and a lightweight terminal-based client.

For further details, visit the [GitHub repository for socktalk](https://github.com/mdkmk/socktalk/tree/main).
## Installation

### From GitHub
To install "socktalk" from GitHub:
1. Clone the repository:
   ```bash
   git clone https://github.com/mdkmk/socktalk
   cd socktalk
2. Install the package:
    ```bash
    python setup.py install

### Using pip
- To install using pip directly from PyPI:
    ```bash
    pip install socktalk

## Usage - Run different components of "socktalk" using the following commands:
Set up the .env file in your working directory to configure AI behaviors and server/client settings without using command-line flags.
Alternatively, you can use command-line flags to override .env or default settings.
### **AI-enhanced chat server:**
```bash
socktalk --ai
```
With flag override:
```bash
socktalk --ai --openai_api_key=YOUR_OPENAI_API_KEY_HERE --ai_mode2_active=False --ai_mode1_interval=3
```
---
### **Chat server without AI integration:**
```bash
socktalk --server
```
With flag override:
```bash
socktalk --server --server_ip=127.0.0.1 --server_port=1234
```
---
### **GUI-enabled multi-user chat client:**
```bash
socktalk --client
```
With flag override:
```bash
socktalk --client --server_ip=127.0.0.1 --server_port=1234
```
---
### **Terminal-based chat client:**
```bash
socktalk --terminal
```
With flag override:
```bash
socktalk --terminal --server_ip=127.0.0.1 --server_port=1234
```
---
## AI Chatbot Configuration
### AI Client Modes:
1. Respond every N lines: The AI reads the conversation and responds after every N lines.
2. Respond every N seconds: The AI generates new content at specified intervals.

### Example .env File Configuration
 Below is an example .env file. Update the OpenAI chatgpt API key and ensure you have at least $5 credit on your OpenAI account.
 A valid OPENAI_API_KEY is required for AI functionality. The AI client has two modes which can be toggled on or off.
 AI response intervals, model, and content prompt are configurable. Full chat history can be sent to the API for context.
 If the remaining .env variables are not specified or called as a flag, defaults in the example below will be used.

    OPENAI_API_KEY=YOUR_OPENAI_API_KEY_HERE
    SERVER_IP_ADDRESS=127.0.0.1
    SERVER_PORT=1234
    SEND_FULL_CHAT_HISTORY=True
    AI_MODE1_ACTIVE=True
    AI_MODE1_INTERVAL=1
    AI_MODE1_MODEL=gpt-3.5-turbo
    AI_MODE2_ACTIVE=True
    AI_MODE2_INTERVAL=60
    AI_MODE2_MODEL=gpt-3.5-turbo
    AI_MODE2_CONTENT="Say something interesting from a random Wikipedia page and start your response with 'Did you know', but don't mention the source."


