Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jinchat-server
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
aigc-pioneer
jinchat-server
Commits
24324563
提交
24324563
authored
5月 31, 2023
作者:
glide-the
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
适配远程LLM调用
上级
99e9d1d7
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
22 行增加
和
9 行删除
+22
-9
model_config.py
configs/model_config.py
+14
-3
fastchat_openai_llm.py
models/fastchat_openai_llm.py
+2
-2
shared.py
models/shared.py
+4
-1
test_fastchat_openai_llm.py
test/models/test_fastchat_openai_llm.py
+2
-3
没有找到文件。
configs/model_config.py
浏览文件 @
24324563
...
@@ -69,12 +69,23 @@ llm_model_dict = {
...
@@ -69,12 +69,23 @@ llm_model_dict = {
"local_model_path"
:
None
,
"local_model_path"
:
None
,
"provides"
:
"LLamaLLM"
"provides"
:
"LLamaLLM"
},
},
"fast
ChatOpenAI
"
:
{
"fast
-chat-chatglm-6b
"
:
{
"name"
:
"FastChatOpenAI"
,
"name"
:
"FastChatOpenAI"
,
"pretrained_model_name"
:
"FastChatOpenAI"
,
"pretrained_model_name"
:
"FastChatOpenAI"
,
"local_model_path"
:
None
,
"local_model_path"
:
None
,
"provides"
:
"FastChatOpenAILLM"
"provides"
:
"FastChatOpenAILLM"
,
}
"api_base_url"
:
"http://localhost:8000/v1"
,
"model_name"
:
"chatglm-6b"
},
"fast-chat-vicuna-13b-hf"
:
{
"name"
:
"FastChatOpenAI"
,
"pretrained_model_name"
:
"vicuna-13b-hf"
,
"local_model_path"
:
None
,
"provides"
:
"FastChatOpenAILLM"
,
"api_base_url"
:
"http://localhost:8000/v1"
,
"model_name"
:
"vicuna-13b-hf"
},
}
}
# LLM 名称
# LLM 名称
...
...
models/fastchat_openai_llm.py
浏览文件 @
24324563
...
@@ -111,9 +111,9 @@ class FastChatOpenAILLM(RemoteRpcModel, LLM, ABC):
...
@@ -111,9 +111,9 @@ class FastChatOpenAILLM(RemoteRpcModel, LLM, ABC):
messages
=
self
.
build_message_list
(
prompt
)
messages
=
self
.
build_message_list
(
prompt
)
)
)
self
.
history
+=
[[
prompt
,
completion
.
choices
[
0
]
.
message
.
content
]]
history
+=
[[
prompt
,
completion
.
choices
[
0
]
.
message
.
content
]]
answer_result
=
AnswerResult
()
answer_result
=
AnswerResult
()
answer_result
.
history
=
self
.
history
answer_result
.
history
=
history
answer_result
.
llm_output
=
{
"answer"
:
completion
.
choices
[
0
]
.
message
.
content
}
answer_result
.
llm_output
=
{
"answer"
:
completion
.
choices
[
0
]
.
message
.
content
}
yield
answer_result
yield
answer_result
models/shared.py
浏览文件 @
24324563
...
@@ -34,11 +34,14 @@ def loaderLLM(llm_model: str = None, no_remote_model: bool = False, use_ptuning_
...
@@ -34,11 +34,14 @@ def loaderLLM(llm_model: str = None, no_remote_model: bool = False, use_ptuning_
loaderCheckPoint
.
model_path
=
llm_model_info
[
"local_model_path"
]
loaderCheckPoint
.
model_path
=
llm_model_info
[
"local_model_path"
]
if
'FastChat
'
in
loaderCheckPoint
.
model_name
:
if
'FastChat
OpenAILLM'
in
llm_model_info
[
"local_model_path"
]
:
loaderCheckPoint
.
unload_model
()
loaderCheckPoint
.
unload_model
()
else
:
else
:
loaderCheckPoint
.
reload_model
()
loaderCheckPoint
.
reload_model
()
provides_class
=
getattr
(
sys
.
modules
[
'models'
],
llm_model_info
[
'provides'
])
provides_class
=
getattr
(
sys
.
modules
[
'models'
],
llm_model_info
[
'provides'
])
modelInsLLM
=
provides_class
(
checkPoint
=
loaderCheckPoint
)
modelInsLLM
=
provides_class
(
checkPoint
=
loaderCheckPoint
)
if
'FastChatOpenAILLM'
in
llm_model_info
[
"provides"
]:
modelInsLLM
.
set_api_base_url
(
llm_model_info
[
'api_base_url'
])
modelInsLLM
.
call_model_name
(
llm_model_info
[
'model_name'
])
return
modelInsLLM
return
modelInsLLM
test/models/test_fastchat_openai_llm.py
浏览文件 @
24324563
...
@@ -18,14 +18,13 @@ async def dispatch(args: Namespace):
...
@@ -18,14 +18,13 @@ async def dispatch(args: Namespace):
shared
.
loaderCheckPoint
=
LoaderCheckPoint
(
args_dict
)
shared
.
loaderCheckPoint
=
LoaderCheckPoint
(
args_dict
)
llm_model_ins
=
shared
.
loaderLLM
()
llm_model_ins
=
shared
.
loaderLLM
()
llm_model_ins
.
set_api_base_url
(
"http://localhost:8000/v1"
)
llm_model_ins
.
call_model_name
(
"chatglm-6b"
)
history
=
[
history
=
[
(
"which city is this?"
,
"tokyo"
),
(
"which city is this?"
,
"tokyo"
),
(
"why?"
,
"she's japanese"
),
(
"why?"
,
"she's japanese"
),
]
]
for
answer_result
in
llm_model_ins
.
generatorAnswer
(
prompt
=
"
她在做什么
? "
,
history
=
history
,
for
answer_result
in
llm_model_ins
.
generatorAnswer
(
prompt
=
"
你好
? "
,
history
=
history
,
streaming
=
False
):
streaming
=
False
):
resp
=
answer_result
.
llm_output
[
"answer"
]
resp
=
answer_result
.
llm_output
[
"answer"
]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论