1 Star 0 Fork 20

衣沾不足惜/Qwen2-72B-Instruct-GPTQ-Int4

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
web_ui.py 2.43 KB
一键复制 编辑 原始数据 按行查看 历史
衣沾不足惜 提交于 2024-07-23 09:17 . 更新 web_ui.py
import os
import gradio as gr
import requests
import json
import subprocess
import threading
import openai_api_request
# def read_process_output(process):
# """Reads the process output and prints it."""
# while True:
# output = process.stdout.readline()
# if output == '' and process.poll() is not None:
# break
# if output:
# print("API Server: "+output.strip())
# # 启动一个线程读取 subprocess 输出
# thread = threading.Thread(target=read_process_output, args=(process,))
# thread.start()
system_prompt = {
"role": "system",
"content":
"你是一个无知、爱发脾气、甩锅的助手,不会解决任何用户问题,你回答巧妙有趣、多样化, 遵守中国法律。"
}
def chat(message, history):
if (len(message) > 1000):
raise gr.Error("输入长度不能超过 1000 字,请重新输入")
messages = [system_prompt]
for msg in history:
messages.append({"role": "user", "content": str(msg[0])})
messages.append({"role": "assistant", "content": str(msg[1])})
messages.append({"role": "user", "content": str(message)})
complete_message = ''
res = openai_api_request.simple_chat(messages=messages, use_stream=True)
for chunk in res:
delta_content = chunk.choices[0].delta.content
complete_message += delta_content
# print(delta_content, end='') # 不换行拼接输出当前块的内容
yield complete_message # gradio 需要返回完整可迭代内容
print(message)
print("\nComplete message:", complete_message)
chatbot = gr.Chatbot(height=450, label="千问2")
with gr.Blocks(fill_height=True) as demo:
chat = gr.ChatInterface(chat,
submit_btn="提交",
chatbot=chatbot,
clear_btn="清空",
stop_btn="暂停",
undo_btn=None,
retry_btn="重试",
examples=["作为人工智能,你对未来科技的发展趋势有什么看法?",
"讲个笑话", "今天吃什么?", "生鱼片是死鱼片吗?", "介绍中国思想史", '如果可以,你最想做什么?'],
)
# with gr.Row():
# useStage = gr.Textbox(lines=2, label="使用信息", placeholder="", input="")
demo.queue()
demo.launch(show_api=False)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/stringify/Qwen2-72B-Instruct-GPTQ-Int4.git
[email protected]:stringify/Qwen2-72B-Instruct-GPTQ-Int4.git
stringify
Qwen2-72B-Instruct-GPTQ-Int4
Qwen2-72B-Instruct-GPTQ-Int4
master

搜索帮助