pycoze 0.1.33__py3-none-any.whl → 0.1.35__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/agent/chat.py +22 -28
- pycoze/bot/bot.py +5 -13
- {pycoze-0.1.33.dist-info → pycoze-0.1.35.dist-info}/METADATA +1 -1
- {pycoze-0.1.33.dist-info → pycoze-0.1.35.dist-info}/RECORD +7 -7
- {pycoze-0.1.33.dist-info → pycoze-0.1.35.dist-info}/LICENSE +0 -0
- {pycoze-0.1.33.dist-info → pycoze-0.1.35.dist-info}/WHEEL +0 -0
- {pycoze-0.1.33.dist-info → pycoze-0.1.35.dist-info}/top_level.txt +0 -0
pycoze/bot/agent/chat.py
CHANGED
@@ -1,28 +1,22 @@
|
|
1
|
-
import json
|
2
|
-
from langchain_core.messages import
|
3
|
-
|
4
|
-
|
5
|
-
INPUT_MESSAGE = "INPUT_MESSAGE=>"
|
6
|
-
_OUTPUT_MESSAGE = "OUTPUT_MESSAGE=>"
|
7
|
-
_INFOMATION_MESSAGE = "INFOMATION_MESSAGE=>"
|
8
|
-
_LOG = "LOG=>"
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
print(_OUTPUT_MESSAGE + json.dumps({"role": role, "content": content}))
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
else:
|
24
|
-
raise ValueError("Invalid role")
|
25
|
-
return history
|
26
|
-
|
27
|
-
def info(role, content):
|
28
|
-
print(_INFOMATION_MESSAGE + json.dumps({"role": role, "content": content}))
|
1
|
+
import json
|
2
|
+
from langchain_core.messages import AIMessage
|
3
|
+
|
4
|
+
|
5
|
+
INPUT_MESSAGE = "INPUT_MESSAGE=>"
|
6
|
+
_OUTPUT_MESSAGE = "OUTPUT_MESSAGE=>"
|
7
|
+
_INFOMATION_MESSAGE = "INFOMATION_MESSAGE=>"
|
8
|
+
_LOG = "LOG=>"
|
9
|
+
|
10
|
+
|
11
|
+
def log(content, *args, end="\n", **kwargs):
|
12
|
+
print(_LOG + content, *args, end=end, **kwargs)
|
13
|
+
|
14
|
+
|
15
|
+
def output(role, content):
|
16
|
+
assert role == "assistant"
|
17
|
+
print(_OUTPUT_MESSAGE + json.dumps({"role": role, "content": content}))
|
18
|
+
return AIMessage(content=content)
|
19
|
+
|
20
|
+
|
21
|
+
def info(role, content):
|
22
|
+
print(_INFOMATION_MESSAGE + json.dumps({"role": role, "content": content}))
|
pycoze/bot/bot.py
CHANGED
@@ -3,7 +3,7 @@ from langchain_openai import ChatOpenAI
|
|
3
3
|
from .base import import_tools
|
4
4
|
from .agent import run_agent, Runnable, INPUT_MESSAGE, output
|
5
5
|
import asyncio
|
6
|
-
from langchain_core.messages import
|
6
|
+
from langchain_core.messages import HumanMessage
|
7
7
|
from pycoze import utils
|
8
8
|
|
9
9
|
|
@@ -48,20 +48,12 @@ def agent_chat(bot_setting_file, history):
|
|
48
48
|
|
49
49
|
|
50
50
|
def chat(bot_setting_file: str):
|
51
|
+
history = []
|
51
52
|
while True:
|
52
53
|
input_text = input()
|
53
54
|
if not input_text.startswith(INPUT_MESSAGE):
|
54
55
|
raise ValueError("Invalid message")
|
55
|
-
|
56
|
-
history
|
57
|
-
for message in messages:
|
58
|
-
if message["role"] == "assistant":
|
59
|
-
history += [AIMessage(content=message["content"])]
|
60
|
-
elif message["role"] == "user":
|
61
|
-
history += [HumanMessage(content=message["content"])]
|
62
|
-
elif message["role"] == "system":
|
63
|
-
history += [SystemMessage(content=message["content"])]
|
64
|
-
else:
|
65
|
-
raise ValueError("Invalid message")
|
56
|
+
message = json.loads(input_text[len(INPUT_MESSAGE) :])
|
57
|
+
history.append(HumanMessage(message["content"]))
|
66
58
|
result = agent_chat(bot_setting_file, history)
|
67
|
-
output("assistant", result
|
59
|
+
history.append(output("assistant", result))
|
@@ -2,11 +2,11 @@ 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=45HHv9PmUDHfP0pg5zZi23Io7bCZetJSneTZfFaSjow,1838
|
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
|
9
|
-
pycoze/bot/agent/chat.py,sha256=
|
9
|
+
pycoze/bot/agent/chat.py,sha256=kc0qgcrBSXdiMy49JwThZTV-0PAvzAhiUvbI5ILiSnU,571
|
10
10
|
pycoze/bot/agent/agent_types/__init__.py,sha256=W2jTNMLqUMqgCMG0Tw0d8n7WpsbsnIonqaPR-YLegLU,210
|
11
11
|
pycoze/bot/agent/agent_types/openai_func_call_agent.py,sha256=LBCkcPbFHpI9ijrze2X15O-9tXxCbi7IKbJRtrBQjwg,4504
|
12
12
|
pycoze/bot/agent/agent_types/react_agent.py,sha256=AnjHwHXVwLAm77ndglJGi4rQhqDGWaLuUfl46uZVSzM,6749
|
@@ -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.35.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
|
25
|
+
pycoze-0.1.35.dist-info/METADATA,sha256=zNyvESPcN0ZDZrIb8r_b50-l8FgGWVSJ33p5WeshqW8,719
|
26
|
+
pycoze-0.1.35.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
|
27
|
+
pycoze-0.1.35.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
|
28
|
+
pycoze-0.1.35.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|