-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsocialagi.py
71 lines (54 loc) · 1.74 KB
/
socialagi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""This is what I did first to use the open-source socialagi lib"""
import javascript
#from pydantic import BaseModel, ConfigDict
socialagi = javascript.require('socialagi')
js_socialagi = javascript.require('./js_socialagi/main.mjs')
ChatMessageRoleEnum = socialagi.ChatMessageRoleEnum
CortexStep = socialagi.CortexStep
externalDialog = socialagi.externalDialog
internalMonologue = socialagi.internalMonologue
createMessage = js_socialagi.createMessage
def chat():
"""porting examples/metacognition.ts"""
print(socialagi)
print("* -- *")
print(js_socialagi)
#note: it should work to generate these types from the ts interfaces using
#https://pypi.org/project/ts2python/
# class ChatMessage(BaseModel):
# role: str #ChatMessageRoleEnum
# content: str
# #model_config = ConfigDict(arbitrary_types_allowed=True)
#this leads to error about unexpected param ffid ending up in the GPT request, due to the bridge
initial_memory = [
# ChatMessage(
# role=ChatMessageRoleEnum.System,
# content="Hi"
# )
createMessage(
ChatMessageRoleEnum.System,
"Hi"
)
]
dialog = CortexStep("BotName");
dialog = dialog.withMemory(initial_memory);
#print(dialog)
says = dialog.next(externalDialog());
print(says)
if __name__ == '__main__':
chat()
"""
ooh this works, we get:
CortexStep {
memories: [
{ role: 'system', content: 'Hi' },
{
role: 'assistant',
content: 'BotName said: "Hello! How can I assist you today?"'
}
],
lastValue: 'Hello! How can I assist you today?',
entityName: 'BotName',
(...)
"""
#intermediate_thought_process = ["pondered how she feels", "wondered about intention"];