hjxdl 0.2.1__py3-none-any.whl → 0.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hdl/_version.py +2 -2
- hdl/utils/llm/chat_uitest.py +56 -0
- {hjxdl-0.2.1.dist-info → hjxdl-0.2.3.dist-info}/METADATA +1 -2
- {hjxdl-0.2.1.dist-info → hjxdl-0.2.3.dist-info}/RECORD +6 -5
- {hjxdl-0.2.1.dist-info → hjxdl-0.2.3.dist-info}/WHEEL +1 -1
- {hjxdl-0.2.1.dist-info → hjxdl-0.2.3.dist-info}/top_level.txt +0 -0
hdl/_version.py
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
import argparse
|
2
|
+
import gradio as gr
|
3
|
+
from .chat import OpenAI_M
|
4
|
+
|
5
|
+
# 定义流式输出的生成函数
|
6
|
+
def chat_with_llm(user_input, chat_history=[]):
|
7
|
+
chat_history.append(("User: " + user_input, "Bot: ")) # 初始先追加用户消息
|
8
|
+
yield "", chat_history, chat_history # 返回用户消息
|
9
|
+
|
10
|
+
bot_message = "" # Bot 消息初始化为空
|
11
|
+
resp = llm.stream(
|
12
|
+
"你的身份是芯途异构(ICTrek)的人工智能小助手,由芯途异构公司研发,请回答如下问题:\n"
|
13
|
+
+ user_input
|
14
|
+
) # 获取流式响应
|
15
|
+
|
16
|
+
for chunk in resp:
|
17
|
+
bot_message += chunk # 累加流式输出
|
18
|
+
chat_history[-1] = ("User: " + user_input, "Bot: " + bot_message)
|
19
|
+
yield "", chat_history, chat_history # 每次输出更新后的聊天记录
|
20
|
+
|
21
|
+
# 构建 Gradio 界面
|
22
|
+
def create_demo():
|
23
|
+
with gr.Blocks() as demo:
|
24
|
+
chat_history = gr.State([]) # 存储聊天历史
|
25
|
+
output = gr.Chatbot(label="Chat History") # 聊天记录在页面顶端
|
26
|
+
|
27
|
+
with gr.Row(): # 用户输入框在页面底端
|
28
|
+
chatbox = gr.Textbox(
|
29
|
+
label="Your Message", placeholder="Type your message here...", show_label=False
|
30
|
+
)
|
31
|
+
send_button = gr.Button("Send")
|
32
|
+
|
33
|
+
# 绑定发送消息的交互
|
34
|
+
send_button.click(chat_with_llm, [chatbox, chat_history], [chatbox, output, chat_history], queue=True)
|
35
|
+
chatbox.submit(chat_with_llm, [chatbox, chat_history], [chatbox, output, chat_history], queue=True) # 支持回车发送
|
36
|
+
|
37
|
+
return demo
|
38
|
+
|
39
|
+
if __name__ == "__main__":
|
40
|
+
# 使用 argparse 处理命令行参数
|
41
|
+
parser = argparse.ArgumentParser(description="Gradio LLM Chatbot")
|
42
|
+
parser.add_argument("--host", type=str, default="0.0.0.0", help="The host to launch the app on.")
|
43
|
+
parser.add_argument("--port", type=int, default=10077, help="The port to launch the app on.")
|
44
|
+
parser.add_argument("--llm_host", type=str, default="127.0.0.1", help="The LLM server IP.")
|
45
|
+
parser.add_argument("--llm_port", type=int, default=22277, help="The LLM server port.")
|
46
|
+
args = parser.parse_args()
|
47
|
+
|
48
|
+
# 初始化连接到 LLM 服务器的接口,使用传入的 host 和 port
|
49
|
+
llm = OpenAI_M(
|
50
|
+
server_ip=args.llm_host,
|
51
|
+
server_port=args.llm_port
|
52
|
+
)
|
53
|
+
|
54
|
+
# 启动 Gradio 应用
|
55
|
+
demo = create_demo()
|
56
|
+
demo.launch(server_name=args.host, server_port=args.port)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: hjxdl
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.3
|
4
4
|
Summary: A collection of functions for Jupyter notebooks
|
5
5
|
Home-page: https://github.com/huluxiaohuowa/hdl
|
6
6
|
Author: Jianxing Hu
|
@@ -14,7 +14,6 @@ Requires-Dist: beautifulsoup4
|
|
14
14
|
Requires-Dist: openai
|
15
15
|
Requires-Dist: tqdm
|
16
16
|
Requires-Dist: geopy
|
17
|
-
Requires-Dist: timezonefinder
|
18
17
|
Requires-Dist: pytz
|
19
18
|
Requires-Dist: duckduckgo-search[lxml]
|
20
19
|
Requires-Dist: opencv-python
|
@@ -1,5 +1,5 @@
|
|
1
1
|
hdl/__init__.py,sha256=GffnD0jLJdhkd-vo989v40N90sQbofkayRBwxc6TVhQ,72
|
2
|
-
hdl/_version.py,sha256=
|
2
|
+
hdl/_version.py,sha256=AaQEeqeDwmZAHoPuwg2C0ulADePbIYLSFanZzt0cytQ,411
|
3
3
|
hdl/args/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
hdl/args/loss_args.py,sha256=s7YzSdd7IjD24rZvvOrxLLFqMZQb9YylxKeyelSdrTk,70
|
5
5
|
hdl/controllers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -128,6 +128,7 @@ hdl/utils/general/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
|
|
128
128
|
hdl/utils/general/glob.py,sha256=8-RCnt6L297wMIfn34ZAMCsGCZUjHG3MGglGZI1cX0g,491
|
129
129
|
hdl/utils/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
130
130
|
hdl/utils/llm/chat.py,sha256=OzyY9xACOOocx9zZigtq9YAPvHtDUo8v2fvf1Tyjg_U,14891
|
131
|
+
hdl/utils/llm/chat_uitest.py,sha256=gQjYsQYHHz7xy5_4_Y9g4ODZPjeSYIr48WbkPbVr8tA,2391
|
131
132
|
hdl/utils/llm/embs.py,sha256=Tf0FOYrOFZp7qQpEPiSCXzlgyHH0X9HVTUtsup74a9E,7174
|
132
133
|
hdl/utils/llm/extract.py,sha256=2sK_WJzmYIc8iuWaM9DA6Nw3_6q1O4lJ5pKpcZo-bBA,6512
|
133
134
|
hdl/utils/llm/llama_chat.py,sha256=watcHGOaz-bv3x-yDucYlGk5f8FiqfFhwWogrl334fk,4387
|
@@ -136,7 +137,7 @@ hdl/utils/schedulers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
|
|
136
137
|
hdl/utils/schedulers/norm_lr.py,sha256=bDwCmdEK-WkgxQMFBiMuchv8Mm7C0-GZJ6usm-PQk14,4461
|
137
138
|
hdl/utils/weather/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
138
139
|
hdl/utils/weather/weather.py,sha256=k11o6wM15kF8b9NMlEfrg68ak-SfSYLN3nOOflFUv-I,4381
|
139
|
-
hjxdl-0.2.
|
140
|
-
hjxdl-0.2.
|
141
|
-
hjxdl-0.2.
|
142
|
-
hjxdl-0.2.
|
140
|
+
hjxdl-0.2.3.dist-info/METADATA,sha256=EkavEs6S0A096boAcS3Yo7r59zcblifx_S-VjYETnFg,835
|
141
|
+
hjxdl-0.2.3.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
142
|
+
hjxdl-0.2.3.dist-info/top_level.txt,sha256=-kxwTM5JPhylp06z3zAVO3w6_h7wtBfBo2zgM6YZoTk,4
|
143
|
+
hjxdl-0.2.3.dist-info/RECORD,,
|
File without changes
|