https://github.com/stephanfward/openai-server-client-chat
Simplified example demonstrating how to use gRPC in Python to create a client-server application where a Python script interacts with the GPT-4 language model hosted on a server
https://github.com/stephanfward/openai-server-client-chat
chatgpt chatgpt-api gprc python
Last synced: about 1 year ago
JSON representation
Simplified example demonstrating how to use gRPC in Python to create a client-server application where a Python script interacts with the GPT-4 language model hosted on a server
- Host: GitHub
- URL: https://github.com/stephanfward/openai-server-client-chat
- Owner: StephanFWard
- License: apache-2.0
- Created: 2024-02-24T13:17:54.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-24T13:22:06.000Z (over 2 years ago)
- Last Synced: 2024-02-24T14:28:37.130Z (over 2 years ago)
- Topics: chatgpt, chatgpt-api, gprc, python
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# openAI-server-client-chat
Simplified example demonstrating how to use gRPC in Python to create a client-server application where a Python script interacts with the GPT-4 language model hosted on a server
This example demonstrates a basic client-server interaction using gRPC in Python, where the server uses the GPT-4 language model to generate responses to input text received from the client. You can extend it further by handling multiple concurrent requests, implementing error handling, and integrating with real-world applications.
Clone the repository:
git clone https://github.com/your-username/openAI-server-client-chat.git
Install the necessary dependencies:
pip install -r requirements.txt
Set up your OpenAI API key:
Sign up for an account on the OpenAI platform and obtain an API key.
Set your API key as an environment variable:
'''export OPENAI_API_KEY="your-api-key'''
Start the server by running:
python server.py.
In another terminal window, run:
python client.py.
You should see the client sending input text to the server, and the server responding with text generated by the GPT-4 model.