gpt-4o-2024-05-13· OpenAI
WildChat-4.8M (AI2)
import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout,…
- User
import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QLineEdit, QTextEdit, QWidget, QComboBox from g4f.client import Client
class ChatApp(QMainWindow): def init(self): super().init()
self.setWindowTitle("Chat with AI") self.setGeometry(100, 100, 600, 400) self.client = Client() self.models = [ "blackbox", "claude-3-haiku", "nemotron-4-340b-instruct", "command-r+", "mixtral-8x7b", "Phi-3-mini-4k-instruct", "Nous-Hermes-2-Mixtral-8x7B-DPO", "CohereForAI/c4ai-command-r-plus", "databricks/dbrx-instruct", "deepseek-coder", "Qwen2-7B-Instruct", "SparkDesk-v1.1", "deepseek-chat", "meta/meta-llama-3-70b-instruct", "meta-llama/Meta-Llama-3-70B-Instruct", "meta-llama/Meta-Llama-3-8B-Instruct", "gpt-4o-mini", "llama-3-8b-instruct", "llama-3-70b-instruct", "llama-3-70b-chat", "llama-3.1-70b-instruct", "llama-3.1-405b-instruct" ] layout = QVBoxLayout() self.model_selector = QComboBox() self.model_selector.addItems(self.models) self.chat_area = QTextEdit() self.chat_area.setReadOnly(True) self.input_area = QLineEdit() self.input_area.setPlaceholderText("Type your message here...") self.input_area.setFixedHeight(80) send_button = QPushButton("Send") send_button.clicked.connect(self.send_message) model_layout = QHBoxLayout() model_layout.addWidget(QLabel("Select Model:")) model_layout.addWidget(self.model_selector) input_layout = QHBoxLayout() input_layout.addWidget(self.input_area) input_layout.addWidget(send_button) layout.addLayout(model_layout) layout.addWidget(self.chat_area) layout.addLayout(input_layout) container = QWidget() container.setLayout(layout) self.setCentralWidget(container) def send_message(self): user_input = self.input_area.text() if not user_input: return self.chat_area.append(f"You: {user_input}") self.input_area.clear() model = self.model_selector.currentText() response = self.client.chat.completions.create( model=model, messages=[{"role": "user", "content": user_input}], ) ai_response = response.choices[0].message.content self.chat_area.append(f"AI: {ai_response}")def main(): app = QApplication(sys.argv) window = ChatApp() window.show() sys.exit(app.exec_())
if name == "main": main()
СДЕЛАЙ ВОЗМОЖНОСТЬ ПИСАТЬ НЕСКОЛЬКО СТРОК, ДОБАВЬ ОЧИСТКУ КОНСОЛИ И ТЕМНЫЙ ФОН, СДЕЛАЙ ВОЗМОЖНОСТЬ ПИСАТЬ НЕСКОЛЬКО СТРОК, ДОБАВЬ ОЧИСТКУ КОНСОЛИ И ТЕМНЫЙ ФОН. УЛУЧШИ КОД!!!!!
- Assistant