# 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 file 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=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."
Raw data
{
"_id": null,
"home_page": null,
"name": "socktalk",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "chat server, chat client, AI chatbot, chatGPT, OPENAI API, socket programming, select.select(), multi-user chat, real-time communication, Python chat application",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/84/8d/02bf3351715d70cd90b262c086b91928d969c9d00b9d7ccf58303ffa8719/socktalk-0.2.3.tar.gz",
"platform": null,
"description": "# socktalk - A Robust Socket-based AI Chat Server and Multi-user Chat Client\n\n**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.\n\n## Features\n- **Multi-User Support**: Manages multiple connections simultaneously to support multi-user interactions.\n- **Efficient Message Handling**: Uses non-blocking sockets and `select.select()` for real-time, concurrent message processing.\n- **AI Integration**: Augments multi-user chat with AI-driven responses, configurable for different operational modes.\n- **Standardized Protocol**: Implements a simple message protocol with fixed-length headers to streamline communication.\n- **Versatile Client Options**: Offers both a sophisticated graphical user interface and a lightweight terminal-based client.\n\nFor further details, visit the [GitHub repository for socktalk](https://github.com/mdkmk/socktalk/tree/main).\n## Installation\n\n### From GitHub\nTo install \"socktalk\" from GitHub:\n1. Clone the repository:\n ```bash\n git clone https://github.com/mdkmk/socktalk\n cd socktalk\n2. Install the package:\n ```bash\n python setup.py install\n\n### Using pip\n- To install using pip directly from PyPI:\n ```bash\n pip install socktalk\n\n## Usage - Run different components of \"socktalk\" using the following commands:\nSet up the .env file in your working directory to configure AI behaviors and server/client settings without using command-line flags.\nAlternatively, you can use command-line flags to override .env file or default settings.\n### **AI-enhanced chat server:**\n```bash\nsocktalk --ai\n```\nWith flag override:\n```bash\nsocktalk --ai --openai_api_key=YOUR_OPENAI_API_KEY_HERE --ai_mode2_active=False --ai_mode1_interval=3\n```\n---\n### **Chat server without AI integration:**\n```bash\nsocktalk --server\n```\nWith flag override:\n```bash\nsocktalk --server --server_ip=127.0.0.1 --server_port=1234\n```\n---\n### **GUI-enabled multi-user chat client:**\n```bash\nsocktalk --client\n```\nWith flag override:\n```bash\nsocktalk --client --server_ip=127.0.0.1 --server_port=1234\n```\n---\n### **Terminal-based chat client:**\n```bash\nsocktalk --terminal\n```\nWith flag override:\n```bash\nsocktalk --terminal --server_ip=127.0.0.1 --server_port=1234\n```\n---\n## AI Chatbot Configuration\n### AI Client Modes:\n1. Respond every N lines: The AI reads the conversation and responds after every N lines.\n2. Respond every N seconds: The AI generates new content at specified intervals.\n\n### Example .env File Configuration\n Below is an example .env file. Update the OpenAI chatgpt API key and ensure you have at least $5 credit on your OpenAI account.\n A valid OPENAI_API_KEY is required for AI functionality. The AI client has two modes which can be toggled on or off.\n AI response intervals, model, and content prompt are configurable. Full chat history can be sent to the API for context.\n If the remaining .env variables are not specified or called as a flag, defaults in the example below will be used.\n\n OPENAI_API_KEY=YOUR_OPENAI_API_KEY_HERE\n SERVER_IP=127.0.0.1\n SERVER_PORT=1234\n SEND_FULL_CHAT_HISTORY=True\n AI_MODE1_ACTIVE=True\n AI_MODE1_INTERVAL=1\n AI_MODE1_MODEL=gpt-3.5-turbo\n AI_MODE2_ACTIVE=True\n AI_MODE2_INTERVAL=60\n AI_MODE2_MODEL=gpt-3.5-turbo\n 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.\"\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Socket-based AI chat server and multi-user chat client",
"version": "0.2.3",
"project_urls": {
"Source": "https://github.com/mdkmk/socktalk"
},
"split_keywords": [
"chat server",
" chat client",
" ai chatbot",
" chatgpt",
" openai api",
" socket programming",
" select.select()",
" multi-user chat",
" real-time communication",
" python chat application"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6fb9fadc2b80384a2abc768736eb2b8501b7d9808316dc695456c58fe05f4497",
"md5": "e4a7697a9c037cfd02290a69b079f646",
"sha256": "44fcfe5d0471c8ff5fba6958df84b728f62557ba6700c3df4fb81dcee78bc2c9"
},
"downloads": -1,
"filename": "socktalk-0.2.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e4a7697a9c037cfd02290a69b079f646",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 16931,
"upload_time": "2024-04-17T21:56:56",
"upload_time_iso_8601": "2024-04-17T21:56:56.490247Z",
"url": "https://files.pythonhosted.org/packages/6f/b9/fadc2b80384a2abc768736eb2b8501b7d9808316dc695456c58fe05f4497/socktalk-0.2.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "848d02bf3351715d70cd90b262c086b91928d969c9d00b9d7ccf58303ffa8719",
"md5": "fa83006a1032ea4ce9b9dac734658d90",
"sha256": "2b24d68d82ac121fd587ccdf2f7af5b64f904d6427709771caf1c3ee375bbb74"
},
"downloads": -1,
"filename": "socktalk-0.2.3.tar.gz",
"has_sig": false,
"md5_digest": "fa83006a1032ea4ce9b9dac734658d90",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 15567,
"upload_time": "2024-04-17T21:56:58",
"upload_time_iso_8601": "2024-04-17T21:56:58.539887Z",
"url": "https://files.pythonhosted.org/packages/84/8d/02bf3351715d70cd90b262c086b91928d969c9d00b9d7ccf58303ffa8719/socktalk-0.2.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-17 21:56:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mdkmk",
"github_project": "socktalk",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "socktalk"
}