[世界是个炒菜班子] 自己部署免费GPT-4,https://ai-pro.org/

鲁树人测试失败了,大哭

4 个赞

牛逼

1 个赞

这真是厉害了

1 个赞

宕机倒计时

1 个赞

这么离谱。key都不用,。。

1 个赞

我要搞它!

1 个赞

明天就跑路了

1 个赞

世界是个巨大的草菜盘子

1 个赞

这下真的是草台班子了

1 个赞

太牛

Mark

import requests
import tkinter as tk
from tkinter import scrolledtext
from threading import Thread


# Define the function to interact with the local API server
def query_local_api(message, url="https://multillm.ai-pro.org/api/openai-completion"):
    headers = {'Content-Type': 'application/json'}
    data = {
        "model": "gpt-4-turbo",
        "messages": [
            {"role": "user", "content": message}
        ],
        "stream": True
    }
    try:
        response = requests.post(url, json=data, headers=headers)
        return response.json()['choices'][0]['message'][
            'content'] if response.status_code == 200 else "Error in response."
    except Exception as e:
        return f"Error: {str(e)}"


# Define the function that will handle sending queries and updating the GUI
def send_query():
    user_input = user_input_entry.get("1.0", tk.END).strip()
    if user_input:
        conversation_history.config(state=tk.NORMAL)
        conversation_history.insert(tk.END, f"You: {user_input}\n")
        conversation_history.config(state=tk.DISABLED)
        user_input_entry.delete("1.0", tk.END)

        # Run the query in a separate thread to keep the GUI responsive
        Thread(target=lambda: fetch_response(user_input)).start()


def fetch_response(user_input):
    response = query_local_api(user_input)
    conversation_history.config(state=tk.NORMAL)
    conversation_history.insert(tk.END, f"AI: {response}\n")
    conversation_history.config(state=tk.DISABLED)


def copy_query(root, conversation_history):
    conversation_history = conversation_history.get("1.0", tk.END).strip()
    # 使用windows api 复制到剪贴板
    root.clipboard_clear()
    root.clipboard_append(conversation_history)
    root.update()
    print("复制成功")


# Set up the GUI using tkinter
def setup_gui():
    root = tk.Tk()
    root.title("Local OpenAI Chat")

    global user_input_entry, conversation_history

    # Text box for user input
    user_input_entry = tk.Text(root, height=3, width=50)
    user_input_entry.pack(pady=10)

    # Button to send message
    send_button = tk.Button(root, text="Send", command=send_query)
    send_button.pack(pady=5)
    send_button = tk.Button(root, text="copy", command=lambda: copy_query(root, conversation_history))
    send_button.pack(pady=5)

    # Scrolled text area for conversation history
    conversation_history = scrolledtext.ScrolledText(root, state=tk.DISABLED, height=15, width=50)
    conversation_history.pack(pady=10)

    root.mainloop()


# Call the function to set up the GUI
setup_gui()  # Uncomment this line to run the GUI

谢谢楼主,发现用的chat-web 网页不能用, 简单让他自己写了c自己的gui, python代码

6 个赞

这么强, 感谢!

笑死

太好了 :+1:

确实是这个,传入gpt-4-turbo-2024-04-09 出来的结果 “content”: “knowledge cut off” 不一样哈

2 个赞

优秀

1 个赞

感谢分享

1 个赞

测试成功

2 个赞