Added missing files.
This commit is contained in:
parent
4768c9d385
commit
57d58df375
23
Makefile
Normal file
23
Makefile
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
default:
|
||||
@echo "Run 'make install' first"
|
||||
@echo "Then run 'make server' or 'make client'"
|
||||
@echo "Then run 'make test'"
|
||||
|
||||
install:
|
||||
python3 -m venv .venv
|
||||
.venv/bin/pip install -r requirements.txt
|
||||
|
||||
server:
|
||||
.venv/bin/python3 server.py
|
||||
|
||||
client:
|
||||
.venv/bin/python3 client.py
|
||||
|
||||
test:
|
||||
.venv/bin/python3 test.py
|
||||
|
||||
uninstall:
|
||||
rm -rf .venv
|
||||
|
||||
.PHONY: install
|
62
README.md
Normal file
62
README.md
Normal file
@ -0,0 +1,62 @@
|
||||
# Project Title
|
||||
|
||||
## Overview
|
||||
This project is a web application consisting of a server and client, along with documentation and test files. The application is designed to demonstrate basic web functionalities and interactions.
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
├── server.py # Main server application
|
||||
├── client.py # Client application for interacting with the server
|
||||
├── test.py # Test scripts for the application
|
||||
├── index.html # Main HTML page for the web application
|
||||
├── documentation.html # Documentation for the project
|
||||
└── Makefile # Build instructions
|
||||
```
|
||||
|
||||
## Installation
|
||||
To set up the project, clone the repository and install the necessary dependencies:
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
$ git clone <repository-url>
|
||||
|
||||
# Navigate into the project directory
|
||||
$ cd <project-directory>
|
||||
|
||||
# Install dependencies (if any)
|
||||
$ pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## Usage
|
||||
To run the server, execute the following command:
|
||||
|
||||
```bash
|
||||
$ python server.py
|
||||
```
|
||||
|
||||
To run the client, execute:
|
||||
|
||||
```bash
|
||||
$ python client.py
|
||||
```
|
||||
|
||||
## Testing
|
||||
To run the tests, use:
|
||||
|
||||
```bash
|
||||
$ python test.py
|
||||
```
|
||||
|
||||
## Documentation
|
||||
For detailed information about the project, refer to the `documentation.html` file.
|
||||
|
||||
## Contributing
|
||||
Contributions are welcome! Please submit a pull request or open an issue for any suggestions or improvements.
|
||||
|
||||
## License
|
||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
||||
|
||||
## Acknowledgments
|
||||
- [Your Name] - for the initial project setup and design.
|
||||
- Any other contributors or resources that helped in the development of this project.
|
90
documentation.html
Normal file
90
documentation.html
Normal file
@ -0,0 +1,90 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Project Documentation</title>
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; line-height: 1.6; }
|
||||
h1, h2, h3 { color: #333; }
|
||||
pre { background: #f4f4f4; padding: 10px; border-left: 3px solid #ccc; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Project Documentation</h1>
|
||||
|
||||
<h2>Overview</h2>
|
||||
<p>This project implements a WebSocket client and server for the Ollama API, allowing users to communicate with an Ollama server. The server is designed to handle multiple concurrent connections and stream responses back to clients.</p>
|
||||
|
||||
<h2>File Structure</h2>
|
||||
<ul>
|
||||
<li><strong>client.py</strong>: The WebSocket client that connects to the Ollama API and handles message sending and receiving.</li>
|
||||
<li><strong>index.html</strong>: The HTML interface for the Ollama Crowd-Funded Server, providing instructions and usage examples.</li>
|
||||
<li><strong>Makefile</strong>: A build script for setting up the project environment, running the server, and executing tests.</li>
|
||||
<li><strong>prompt.txt</strong>: Contains instructions for maintaining code consistency and logging practices.</li>
|
||||
<li><strong>requirements.txt</strong>: Lists the Python dependencies required for the project.</li>
|
||||
<li><strong>server.py</strong>: The WebSocket server that manages connections and forwards messages between clients and the Ollama API.</li>
|
||||
<li><strong>test.py</strong>: Contains tests for the functionality of the client and server.</li>
|
||||
</ul>
|
||||
|
||||
<h2>Client Implementation (<code>client.py</code>)</h2>
|
||||
<p>The client connects to the Ollama API via WebSocket and handles incoming messages. It supports concurrent connections and logs important events.</p>
|
||||
|
||||
<h3>Key Functions</h3>
|
||||
<ul>
|
||||
<li><code>websocket_client(url: str, ollama_url: str)</code>: Connects to the WebSocket server and handles message exchange.</li>
|
||||
<li><code>main(concurrency: int, ollama_url: str)</code>: Initializes multiple WebSocket connections based on the specified concurrency level.</li>
|
||||
<li><code>validate_url(url: str)</code>: Validates the provided URL format.</li>
|
||||
</ul>
|
||||
|
||||
<h2>Server Implementation (<code>server.py</code>)</h2>
|
||||
<p>The server listens for incoming WebSocket connections and manages message forwarding to and from the Ollama API.</p>
|
||||
|
||||
<h3>Key Classes</h3>
|
||||
<ul>
|
||||
<li><code>OllamaServer</code>: Manages individual WebSocket connections and message queues.</li>
|
||||
<li><code>ServerManager</code>: Manages multiple <code>OllamaServer</code> instances and forwards messages between them.</li>
|
||||
</ul>
|
||||
|
||||
<h3>Key Functions</h3>
|
||||
<ul>
|
||||
<li><code>websocket_handler(request)</code>: Handles incoming WebSocket connections and initializes <code>OllamaServer</code>.</li>
|
||||
<li><code>http_handler(request)</code>: Handles HTTP requests and forwards them to the appropriate WebSocket server.</li>
|
||||
</ul>
|
||||
|
||||
<h2>HTML Interface (<code>index.html</code>)</h2>
|
||||
<p>The HTML file provides a user-friendly interface for interacting with the Ollama server. It includes instructions for using the server and a code snippet for the client.</p>
|
||||
|
||||
<h2>Build and Run Instructions (<code>Makefile</code>)</h2>
|
||||
<p>To set up the project, run the following commands:</p>
|
||||
<ol>
|
||||
<li>Install dependencies:
|
||||
<pre>make install</pre>
|
||||
</li>
|
||||
<li>Start the server:
|
||||
<pre>make server</pre>
|
||||
</li>
|
||||
<li>Run the client:
|
||||
<pre>make client</pre>
|
||||
</li>
|
||||
<li>Execute tests:
|
||||
<pre>make test</pre>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<h2>Dependencies (<code>requirements.txt</code>)</h2>
|
||||
<p>The project requires the following Python packages:</p>
|
||||
<ul>
|
||||
<li><code>aiohttp</code>: For asynchronous HTTP and WebSocket handling.</li>
|
||||
</ul>
|
||||
|
||||
<h2>Testing (<code>test.py</code>)</h2>
|
||||
<p>The test file contains unit tests to ensure the functionality of the client and server components.</p>
|
||||
|
||||
<h2>Contribution</h2>
|
||||
<p>Contributions to improve the project are welcome. Please follow the standard practices for submitting issues and pull requests.</p>
|
||||
|
||||
<h2>License</h2>
|
||||
<p>This project is licensed under the MIT License.</p>
|
||||
</body>
|
||||
</html>
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
aiohttp
|
Loading…
Reference in New Issue
Block a user