https://github.com/yjg30737/pyqt-openai-formatted-response-example
Implementing response of chatGPT(plain text and source) as desktop application with Python
https://github.com/yjg30737/pyqt-openai-formatted-response-example
chatgpt chatgpt-python openai pyqt pyqt-examples pyqt5 pyqt5-desktop-application python python3 qt
Last synced: 6 months ago
JSON representation
Implementing response of chatGPT(plain text and source) as desktop application with Python
- Host: GitHub
- URL: https://github.com/yjg30737/pyqt-openai-formatted-response-example
- Owner: yjg30737
- License: mit
- Created: 2023-06-13T07:48:30.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-14T01:18:50.000Z (over 2 years ago)
- Last Synced: 2024-12-29T08:42:10.094Z (12 months ago)
- Topics: chatgpt, chatgpt-python, openai, pyqt, pyqt-examples, pyqt5, pyqt5-desktop-application, python, python3, qt
- Language: Python
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyqt-openai-formatted-response-example
Implementing response of ChatGPT(plain text and source) as desktop application with Python (PyQt)
This simple app demonstrates how to create a John-like response using PyQt, which includes both plain text and source code.
For instance, consider the following response:
`````
To print "Hello, World!" 10 times in Python, you can use a loop. Here's an example:
```
for _ in range(10):
print("Hello, World!")
```
In this code snippet, the `for` loop iterates 10 times. During each iteration, it executes the `print("Hello, World!")` statement, which will output "Hello, World!" to the console.
``````
This app utilizes a `QLabel` widget for the plain text portion and a `QTextBrowser` widget for the source code section. menu which includes a copy button is attached to the source code section.
check out pyqt-openai as well :)
## Requirements
* PyQt5 >= 5.14
* pyperclip - for "copy" feature
* pygments - to highlight the source
## How to Run
1. git clone ~
2. cd pyqt-openai-formatted-response-example
3. pip install -r requirements.txt
4. cd pyqt_openai_formatted_response_example
5. go to the main.py and give the text you want to give. If you want to include the source in text, you have to wrap it with "```".
```python
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
w = LblWithQTextBrowser()
w.setText(
[YOUR TEXT] # change this part
)
w.show()
sys.exit(app.exec())
```
6. python main.py
## Result

## Note
Please remember that programming language detection by `guess_lexer` by pygments is not quite accurate.