pycoze 0.1.31__py3-none-any.whl → 0.1.33__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.
- pycoze/bot/bot.py +22 -20
- {pycoze-0.1.31.dist-info → pycoze-0.1.33.dist-info}/METADATA +1 -1
- {pycoze-0.1.31.dist-info → pycoze-0.1.33.dist-info}/RECORD +6 -6
- {pycoze-0.1.31.dist-info → pycoze-0.1.33.dist-info}/LICENSE +0 -0
- {pycoze-0.1.31.dist-info → pycoze-0.1.33.dist-info}/WHEEL +0 -0
- {pycoze-0.1.31.dist-info → pycoze-0.1.33.dist-info}/top_level.txt +0 -0
pycoze/bot/bot.py
CHANGED
@@ -26,31 +26,33 @@ def load_tools(bot_setting_file: str):
|
|
26
26
|
return tools
|
27
27
|
|
28
28
|
|
29
|
-
def
|
29
|
+
def agent_chat(bot_setting_file, history):
|
30
|
+
role_setting = load_role_setting(bot_setting_file)
|
31
|
+
tools = load_tools(bot_setting_file)
|
32
|
+
with open(llm_file, "r", encoding="utf-8") as f:
|
33
|
+
cfg = json.load(f)
|
34
|
+
chat = ChatOpenAI(
|
35
|
+
api_key=cfg["apiKey"],
|
36
|
+
base_url=cfg["baseURL"],
|
37
|
+
model=cfg["model"],
|
38
|
+
temperature=role_setting["temperature"],
|
39
|
+
)
|
40
|
+
|
41
|
+
agent = Runnable(
|
42
|
+
agent_execution_mode="FuncCall", # 'FuncCall' or 'ReAct',大模型支持FuncCall的话就用FuncCall
|
43
|
+
tools=tools,
|
44
|
+
llm=chat,
|
45
|
+
assistant_message=role_setting["prompt"],
|
46
|
+
)
|
47
|
+
return asyncio.run(run_agent(agent, history))
|
48
|
+
|
30
49
|
|
50
|
+
def chat(bot_setting_file: str):
|
31
51
|
while True:
|
32
52
|
input_text = input()
|
33
|
-
role_setting = load_role_setting(bot_setting_file)
|
34
|
-
tools = load_tools(bot_setting_file)
|
35
53
|
if not input_text.startswith(INPUT_MESSAGE):
|
36
54
|
raise ValueError("Invalid message")
|
37
55
|
messages = json.loads(input_text[len(INPUT_MESSAGE) :])
|
38
|
-
|
39
|
-
with open(llm_file, "r", encoding="utf-8") as f:
|
40
|
-
cfg = json.load(f)
|
41
|
-
chat = ChatOpenAI(
|
42
|
-
api_key=cfg["apiKey"],
|
43
|
-
base_url=cfg["baseURL"],
|
44
|
-
model=cfg["model"],
|
45
|
-
temperature=role_setting["temperature"],
|
46
|
-
)
|
47
|
-
|
48
|
-
agent = Runnable(
|
49
|
-
agent_execution_mode="FuncCall", # 'FuncCall' or 'ReAct',大模型支持FuncCall的话就用FuncCall
|
50
|
-
tools=tools,
|
51
|
-
llm=chat,
|
52
|
-
assistant_message=role_setting["prompt"],
|
53
|
-
)
|
54
56
|
history = []
|
55
57
|
for message in messages:
|
56
58
|
if message["role"] == "assistant":
|
@@ -61,5 +63,5 @@ def chat(bot_setting_file: str):
|
|
61
63
|
history += [SystemMessage(content=message["content"])]
|
62
64
|
else:
|
63
65
|
raise ValueError("Invalid message")
|
64
|
-
result =
|
66
|
+
result = agent_chat(bot_setting_file, history)
|
65
67
|
output("assistant", result, history)
|
@@ -2,7 +2,7 @@ pycoze/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
pycoze/module.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
pycoze/bot/__init__.py,sha256=pciDtfcIXda7iFt9uI5Fpm0JKpGBhdXHmJv4966WTVU,21
|
4
4
|
pycoze/bot/base.py,sha256=GWYDVGGtiCpk6gv-163cAbDid_IsnMe5jTj7eZUMJQU,2679
|
5
|
-
pycoze/bot/bot.py,sha256=
|
5
|
+
pycoze/bot/bot.py,sha256=y-VRF8F75tdoYDPIkSca1jcQYgWJIw-_67koSGgo68g,2253
|
6
6
|
pycoze/bot/agent/__init__.py,sha256=IaYqQCJ3uBor92JdOxI_EY4HtYOHgej8lijr3UrN1Vc,161
|
7
7
|
pycoze/bot/agent/agent.py,sha256=vDbTCorUL6Eh2Az4uzwGsLa3Hp4EPcOkq62JpQXt8-s,3435
|
8
8
|
pycoze/bot/agent/assistant.py,sha256=QLeWaPi415P9jruYOm8qcIbC94cXXAhJYmLTkyC9NTQ,1267
|
@@ -21,8 +21,8 @@ pycoze/ui/ui_def.py,sha256=CNFYH8NC-WYmbceIPpxsRr9H6O006pMKukx7U-BOE1Q,3744
|
|
21
21
|
pycoze/utils/__init__.py,sha256=KExBkotf23dr2NfTEouWke5nJB1q2IuDXgHrmuyd95k,73
|
22
22
|
pycoze/utils/arg.py,sha256=rRujm1zKc0XlnNlpIJ6JAAaFiTzDGmL_RliIpSc5OD8,724
|
23
23
|
pycoze/utils/text_or_file.py,sha256=gpxZVWt2DW6YiEg_MnMuwg36VNf3TX383QD_1oZNB0Y,551
|
24
|
-
pycoze-0.1.
|
25
|
-
pycoze-0.1.
|
26
|
-
pycoze-0.1.
|
27
|
-
pycoze-0.1.
|
28
|
-
pycoze-0.1.
|
24
|
+
pycoze-0.1.33.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
|
25
|
+
pycoze-0.1.33.dist-info/METADATA,sha256=eZ3PUpQoFCtWtNaVjXlJdhNo1u6PKoA9LVdaWhHtzYE,719
|
26
|
+
pycoze-0.1.33.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
|
27
|
+
pycoze-0.1.33.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
|
28
|
+
pycoze-0.1.33.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|