更新了与chatglm3的通信

This commit is contained in:
ChenXL97 2023-11-08 10:26:22 +08:00
parent 3aaab6c308
commit 3aa386c5c3
12 changed files with 972 additions and 4 deletions

View File

@ -0,0 +1,15 @@
digraph pastafarianism {
ordering=out;
graph [fontname="times-roman"];
node [fontname="times-roman"];
edge [fontname="times-roman"];
selector_4aUN4FAA [fillcolor=cyan, fontcolor=black, fontsize=9, label=selector_4aUN4FAA, shape=octagon, style=filled];
sequence_BNun8ZFM [fillcolor=orange, fontcolor=black, fontsize=9, label=sequence_BNun8ZFM, shape=box, style=filled];
selector_4aUN4FAA -> sequence_BNun8ZFM;
Chatting [fillcolor=gray, fontcolor=black, fontsize=9, label=Chatting, shape=ellipse, style=filled];
sequence_BNun8ZFM -> Chatting;
DealChat [fillcolor=gray, fontcolor=black, fontsize=9, label=DealChat, shape=ellipse, style=filled];
sequence_BNun8ZFM -> DealChat;
"At(Coffee,Table)" [fillcolor=gray, fontcolor=black, fontsize=9, label="At(Coffee,Table)", shape=ellipse, style=filled];
selector_4aUN4FAA -> "At(Coffee,Table)";
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 9.0.0 (20230911.1827)
-->
<!-- Title: pastafarianism Pages: 1 -->
<svg width="233pt" height="188pt"
viewBox="0.00 0.00 232.96 188.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 184)">
<title>pastafarianism</title>
<polygon fill="white" stroke="none" points="-4,4 -4,-184 228.96,-184 228.96,4 -4,4"/>
<!-- selector_4aUN4FAA -->
<g id="node1" class="node">
<title>selector_4aUN4FAA</title>
<polygon fill="cyan" stroke="black" points="181.38,-154.54 181.38,-169.46 146.4,-180 96.92,-180 61.94,-169.46 61.94,-154.54 96.92,-144 146.4,-144 181.38,-154.54"/>
<text text-anchor="middle" x="121.66" y="-159.07" font-family="Times New Roman,serif" font-size="9.00">selector_4aUN4FAA</text>
</g>
<!-- sequence_BNun8ZFM -->
<g id="node2" class="node">
<title>sequence_BNun8ZFM</title>
<polygon fill="orange" stroke="black" points="114.29,-108 15.04,-108 15.04,-72 114.29,-72 114.29,-108"/>
<text text-anchor="middle" x="64.66" y="-87.08" font-family="Times New Roman,serif" font-size="9.00">sequence_BNun8ZFM</text>
</g>
<!-- selector_4aUN4FAA&#45;&gt;sequence_BNun8ZFM -->
<g id="edge1" class="edge">
<title>selector_4aUN4FAA&#45;&gt;sequence_BNun8ZFM</title>
<path fill="none" stroke="black" d="M107.57,-143.7C101.01,-135.64 93.08,-125.89 85.82,-116.98"/>
<polygon fill="black" stroke="black" points="88.57,-114.82 79.55,-109.28 83.15,-119.24 88.57,-114.82"/>
</g>
<!-- At(Coffee,Table) -->
<g id="node5" class="node">
<title>At(Coffee,Table)</title>
<ellipse fill="gray" stroke="black" cx="178.66" cy="-90" rx="46.3" ry="18"/>
<text text-anchor="middle" x="178.66" y="-87.08" font-family="Times New Roman,serif" font-size="9.00">At(Coffee,Table)</text>
</g>
<!-- selector_4aUN4FAA&#45;&gt;At(Coffee,Table) -->
<g id="edge4" class="edge">
<title>selector_4aUN4FAA&#45;&gt;At(Coffee,Table)</title>
<path fill="none" stroke="black" d="M135.75,-143.7C142.48,-135.44 150.66,-125.39 158.06,-116.3"/>
<polygon fill="black" stroke="black" points="160.57,-118.76 164.17,-108.8 155.14,-114.34 160.57,-118.76"/>
</g>
<!-- Chatting -->
<g id="node3" class="node">
<title>Chatting</title>
<ellipse fill="gray" stroke="black" cx="27.66" cy="-18" rx="27.66" ry="18"/>
<text text-anchor="middle" x="27.66" y="-15.07" font-family="Times New Roman,serif" font-size="9.00">Chatting</text>
</g>
<!-- sequence_BNun8ZFM&#45;&gt;Chatting -->
<g id="edge2" class="edge">
<title>sequence_BNun8ZFM&#45;&gt;Chatting</title>
<path fill="none" stroke="black" d="M55.52,-71.7C51.27,-63.67 46.13,-53.95 41.43,-45.05"/>
<polygon fill="black" stroke="black" points="44.67,-43.69 36.9,-36.48 38.48,-46.96 44.67,-43.69"/>
</g>
<!-- DealChat -->
<g id="node4" class="node">
<title>DealChat</title>
<ellipse fill="gray" stroke="black" cx="102.66" cy="-18" rx="29.44" ry="18"/>
<text text-anchor="middle" x="102.66" y="-15.07" font-family="Times New Roman,serif" font-size="9.00">DealChat</text>
</g>
<!-- sequence_BNun8ZFM&#45;&gt;DealChat -->
<g id="edge3" class="edge">
<title>sequence_BNun8ZFM&#45;&gt;DealChat</title>
<path fill="none" stroke="black" d="M74.06,-71.7C78.31,-63.87 83.43,-54.44 88.15,-45.73"/>
<polygon fill="black" stroke="black" points="91.22,-47.41 92.92,-36.95 85.07,-44.07 91.22,-47.41"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -0,0 +1,51 @@
token literal names:
null
'{'
'}'
'sequence'
'selector'
'parallel'
'task'
'cond'
'('
')'
','
'True'
'False'
null
null
null
null
null
token symbolic names:
null
null
null
null
null
null
null
null
null
null
null
null
null
Names
Integer
Float
LINE_COMMENT
WS
rule names:
root
tree
internal_node
action_sign
action_parm
boolean
atn:
[4, 1, 17, 62, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 1, 0, 4, 0, 14, 8, 0, 11, 0, 12, 0, 15, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 24, 8, 1, 11, 1, 12, 1, 25, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 34, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 40, 8, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 3, 4, 47, 8, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 53, 8, 4, 5, 4, 55, 8, 4, 10, 4, 12, 4, 58, 9, 4, 1, 5, 1, 5, 1, 5, 0, 0, 6, 0, 2, 4, 6, 8, 10, 0, 2, 1, 0, 6, 7, 1, 0, 11, 12, 66, 0, 13, 1, 0, 0, 0, 2, 19, 1, 0, 0, 0, 4, 33, 1, 0, 0, 0, 6, 35, 1, 0, 0, 0, 8, 46, 1, 0, 0, 0, 10, 59, 1, 0, 0, 0, 12, 14, 3, 2, 1, 0, 13, 12, 1, 0, 0, 0, 14, 15, 1, 0, 0, 0, 15, 13, 1, 0, 0, 0, 15, 16, 1, 0, 0, 0, 16, 17, 1, 0, 0, 0, 17, 18, 5, 0, 0, 1, 18, 1, 1, 0, 0, 0, 19, 20, 3, 4, 2, 0, 20, 23, 5, 1, 0, 0, 21, 24, 3, 6, 3, 0, 22, 24, 3, 2, 1, 0, 23, 21, 1, 0, 0, 0, 23, 22, 1, 0, 0, 0, 24, 25, 1, 0, 0, 0, 25, 23, 1, 0, 0, 0, 25, 26, 1, 0, 0, 0, 26, 27, 1, 0, 0, 0, 27, 28, 5, 2, 0, 0, 28, 3, 1, 0, 0, 0, 29, 34, 5, 3, 0, 0, 30, 34, 5, 4, 0, 0, 31, 32, 5, 5, 0, 0, 32, 34, 5, 14, 0, 0, 33, 29, 1, 0, 0, 0, 33, 30, 1, 0, 0, 0, 33, 31, 1, 0, 0, 0, 34, 5, 1, 0, 0, 0, 35, 36, 7, 0, 0, 0, 36, 37, 5, 13, 0, 0, 37, 39, 5, 8, 0, 0, 38, 40, 3, 8, 4, 0, 39, 38, 1, 0, 0, 0, 39, 40, 1, 0, 0, 0, 40, 41, 1, 0, 0, 0, 41, 42, 5, 9, 0, 0, 42, 7, 1, 0, 0, 0, 43, 47, 5, 14, 0, 0, 44, 47, 5, 15, 0, 0, 45, 47, 3, 10, 5, 0, 46, 43, 1, 0, 0, 0, 46, 44, 1, 0, 0, 0, 46, 45, 1, 0, 0, 0, 47, 56, 1, 0, 0, 0, 48, 52, 5, 10, 0, 0, 49, 53, 5, 14, 0, 0, 50, 53, 5, 15, 0, 0, 51, 53, 3, 10, 5, 0, 52, 49, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 52, 51, 1, 0, 0, 0, 53, 55, 1, 0, 0, 0, 54, 48, 1, 0, 0, 0, 55, 58, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 9, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 59, 60, 7, 1, 0, 0, 60, 11, 1, 0, 0, 0, 8, 15, 23, 25, 33, 39, 46, 52, 56]

View File

@ -0,0 +1,29 @@
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
T__5=6
T__6=7
T__7=8
T__8=9
T__9=10
T__10=11
T__11=12
Names=13
Integer=14
Float=15
LINE_COMMENT=16
WS=17
'{'=1
'}'=2
'sequence'=3
'selector'=4
'parallel'=5
'task'=6
'cond'=7
'('=8
')'=9
','=10
'True'=11
'False'=12

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,119 @@
# Generated from ptml.g4 by ANTLR 4.13.1
from antlr4 import *
from io import StringIO
import sys
if sys.version_info[1] > 5:
from typing import TextIO
else:
from typing.io import TextIO
def serializedATN():
return [
4,0,17,156,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,
2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,
13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,1,0,1,0,1,1,1,1,1,2,1,2,1,
2,1,2,1,2,1,2,1,2,1,2,1,2,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,
4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,5,1,5,1,5,1,5,1,5,1,6,1,6,1,
6,1,6,1,6,1,7,1,7,1,8,1,8,1,9,1,9,1,10,1,10,1,10,1,10,1,10,1,11,
1,11,1,11,1,11,1,11,1,11,1,12,1,12,5,12,96,8,12,10,12,12,12,99,9,
12,1,13,3,13,102,8,13,1,13,1,13,5,13,106,8,13,10,13,12,13,109,9,
13,1,13,3,13,112,8,13,1,14,4,14,115,8,14,11,14,12,14,116,1,14,1,
14,5,14,121,8,14,10,14,12,14,124,9,14,1,14,1,14,4,14,128,8,14,11,
14,12,14,129,3,14,132,8,14,1,15,1,15,1,15,1,15,5,15,138,8,15,10,
15,12,15,141,9,15,1,15,3,15,144,8,15,1,15,1,15,1,15,1,15,1,16,4,
16,151,8,16,11,16,12,16,152,1,16,1,16,1,139,0,17,1,1,3,2,5,3,7,4,
9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,27,14,29,15,31,16,
33,17,1,0,5,3,0,65,90,95,95,97,122,4,0,48,57,65,90,95,95,97,122,
1,0,49,57,1,0,48,57,3,0,9,10,12,13,32,32,166,0,1,1,0,0,0,0,3,1,0,
0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,
0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,
0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,
0,1,35,1,0,0,0,3,37,1,0,0,0,5,39,1,0,0,0,7,48,1,0,0,0,9,57,1,0,0,
0,11,66,1,0,0,0,13,71,1,0,0,0,15,76,1,0,0,0,17,78,1,0,0,0,19,80,
1,0,0,0,21,82,1,0,0,0,23,87,1,0,0,0,25,93,1,0,0,0,27,111,1,0,0,0,
29,131,1,0,0,0,31,133,1,0,0,0,33,150,1,0,0,0,35,36,5,123,0,0,36,
2,1,0,0,0,37,38,5,125,0,0,38,4,1,0,0,0,39,40,5,115,0,0,40,41,5,101,
0,0,41,42,5,113,0,0,42,43,5,117,0,0,43,44,5,101,0,0,44,45,5,110,
0,0,45,46,5,99,0,0,46,47,5,101,0,0,47,6,1,0,0,0,48,49,5,115,0,0,
49,50,5,101,0,0,50,51,5,108,0,0,51,52,5,101,0,0,52,53,5,99,0,0,53,
54,5,116,0,0,54,55,5,111,0,0,55,56,5,114,0,0,56,8,1,0,0,0,57,58,
5,112,0,0,58,59,5,97,0,0,59,60,5,114,0,0,60,61,5,97,0,0,61,62,5,
108,0,0,62,63,5,108,0,0,63,64,5,101,0,0,64,65,5,108,0,0,65,10,1,
0,0,0,66,67,5,116,0,0,67,68,5,97,0,0,68,69,5,115,0,0,69,70,5,107,
0,0,70,12,1,0,0,0,71,72,5,99,0,0,72,73,5,111,0,0,73,74,5,110,0,0,
74,75,5,100,0,0,75,14,1,0,0,0,76,77,5,40,0,0,77,16,1,0,0,0,78,79,
5,41,0,0,79,18,1,0,0,0,80,81,5,44,0,0,81,20,1,0,0,0,82,83,5,84,0,
0,83,84,5,114,0,0,84,85,5,117,0,0,85,86,5,101,0,0,86,22,1,0,0,0,
87,88,5,70,0,0,88,89,5,97,0,0,89,90,5,108,0,0,90,91,5,115,0,0,91,
92,5,101,0,0,92,24,1,0,0,0,93,97,7,0,0,0,94,96,7,1,0,0,95,94,1,0,
0,0,96,99,1,0,0,0,97,95,1,0,0,0,97,98,1,0,0,0,98,26,1,0,0,0,99,97,
1,0,0,0,100,102,5,45,0,0,101,100,1,0,0,0,101,102,1,0,0,0,102,103,
1,0,0,0,103,107,7,2,0,0,104,106,7,3,0,0,105,104,1,0,0,0,106,109,
1,0,0,0,107,105,1,0,0,0,107,108,1,0,0,0,108,112,1,0,0,0,109,107,
1,0,0,0,110,112,5,48,0,0,111,101,1,0,0,0,111,110,1,0,0,0,112,28,
1,0,0,0,113,115,7,3,0,0,114,113,1,0,0,0,115,116,1,0,0,0,116,114,
1,0,0,0,116,117,1,0,0,0,117,118,1,0,0,0,118,122,5,46,0,0,119,121,
7,3,0,0,120,119,1,0,0,0,121,124,1,0,0,0,122,120,1,0,0,0,122,123,
1,0,0,0,123,132,1,0,0,0,124,122,1,0,0,0,125,127,5,46,0,0,126,128,
7,3,0,0,127,126,1,0,0,0,128,129,1,0,0,0,129,127,1,0,0,0,129,130,
1,0,0,0,130,132,1,0,0,0,131,114,1,0,0,0,131,125,1,0,0,0,132,30,1,
0,0,0,133,134,5,47,0,0,134,135,5,47,0,0,135,139,1,0,0,0,136,138,
9,0,0,0,137,136,1,0,0,0,138,141,1,0,0,0,139,140,1,0,0,0,139,137,
1,0,0,0,140,143,1,0,0,0,141,139,1,0,0,0,142,144,5,13,0,0,143,142,
1,0,0,0,143,144,1,0,0,0,144,145,1,0,0,0,145,146,5,10,0,0,146,147,
1,0,0,0,147,148,6,15,0,0,148,32,1,0,0,0,149,151,7,4,0,0,150,149,
1,0,0,0,151,152,1,0,0,0,152,150,1,0,0,0,152,153,1,0,0,0,153,154,
1,0,0,0,154,155,6,16,0,0,155,34,1,0,0,0,12,0,97,101,107,111,116,
122,129,131,139,143,152,1,6,0,0
]
class ptmlLexer(Lexer):
atn = ATNDeserializer().deserialize(serializedATN())
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
T__0 = 1
T__1 = 2
T__2 = 3
T__3 = 4
T__4 = 5
T__5 = 6
T__6 = 7
T__7 = 8
T__8 = 9
T__9 = 10
T__10 = 11
T__11 = 12
Names = 13
Integer = 14
Float = 15
LINE_COMMENT = 16
WS = 17
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
modeNames = [ "DEFAULT_MODE" ]
literalNames = [ "<INVALID>",
"'{'", "'}'", "'sequence'", "'selector'", "'parallel'", "'task'",
"'cond'", "'('", "')'", "','", "'True'", "'False'" ]
symbolicNames = [ "<INVALID>",
"Names", "Integer", "Float", "LINE_COMMENT", "WS" ]
ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6",
"T__7", "T__8", "T__9", "T__10", "T__11", "Names", "Integer",
"Float", "LINE_COMMENT", "WS" ]
grammarFileName = "ptml.g4"
def __init__(self, input=None, output:TextIO = sys.stdout):
super().__init__(input, output)
self.checkVersion("4.13.1")
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
self._actions = None
self._predicates = None

View File

@ -0,0 +1,29 @@
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
T__5=6
T__6=7
T__7=8
T__8=9
T__9=10
T__10=11
T__11=12
Names=13
Integer=14
Float=15
LINE_COMMENT=16
WS=17
'{'=1
'}'=2
'sequence'=3
'selector'=4
'parallel'=5
'task'=6
'cond'=7
'('=8
')'=9
','=10
'True'=11
'False'=12

View File

@ -0,0 +1,66 @@
# Generated from ptml.g4 by ANTLR 4.13.1
from antlr4 import *
if "." in __name__:
from .ptmlParser import ptmlParser
else:
from ptmlParser import ptmlParser
# This class defines a complete listener for a parse tree produced by ptmlParser.
class ptmlListener(ParseTreeListener):
# Enter a parse tree produced by ptmlParser#root.
def enterRoot(self, ctx:ptmlParser.RootContext):
pass
# Exit a parse tree produced by ptmlParser#root.
def exitRoot(self, ctx:ptmlParser.RootContext):
pass
# Enter a parse tree produced by ptmlParser#tree.
def enterTree(self, ctx:ptmlParser.TreeContext):
pass
# Exit a parse tree produced by ptmlParser#tree.
def exitTree(self, ctx:ptmlParser.TreeContext):
pass
# Enter a parse tree produced by ptmlParser#internal_node.
def enterInternal_node(self, ctx:ptmlParser.Internal_nodeContext):
pass
# Exit a parse tree produced by ptmlParser#internal_node.
def exitInternal_node(self, ctx:ptmlParser.Internal_nodeContext):
pass
# Enter a parse tree produced by ptmlParser#action_sign.
def enterAction_sign(self, ctx:ptmlParser.Action_signContext):
pass
# Exit a parse tree produced by ptmlParser#action_sign.
def exitAction_sign(self, ctx:ptmlParser.Action_signContext):
pass
# Enter a parse tree produced by ptmlParser#action_parm.
def enterAction_parm(self, ctx:ptmlParser.Action_parmContext):
pass
# Exit a parse tree produced by ptmlParser#action_parm.
def exitAction_parm(self, ctx:ptmlParser.Action_parmContext):
pass
# Enter a parse tree produced by ptmlParser#boolean.
def enterBoolean(self, ctx:ptmlParser.BooleanContext):
pass
# Exit a parse tree produced by ptmlParser#boolean.
def exitBoolean(self, ctx:ptmlParser.BooleanContext):
pass
del ptmlParser

View File

@ -0,0 +1,514 @@
# Generated from ptml.g4 by ANTLR 4.13.1
# encoding: utf-8
from antlr4 import *
from io import StringIO
import sys
if sys.version_info[1] > 5:
from typing import TextIO
else:
from typing.io import TextIO
def serializedATN():
return [
4,1,17,62,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,1,0,4,
0,14,8,0,11,0,12,0,15,1,0,1,0,1,1,1,1,1,1,1,1,4,1,24,8,1,11,1,12,
1,25,1,1,1,1,1,2,1,2,1,2,1,2,3,2,34,8,2,1,3,1,3,1,3,1,3,3,3,40,8,
3,1,3,1,3,1,4,1,4,1,4,3,4,47,8,4,1,4,1,4,1,4,1,4,3,4,53,8,4,5,4,
55,8,4,10,4,12,4,58,9,4,1,5,1,5,1,5,0,0,6,0,2,4,6,8,10,0,2,1,0,6,
7,1,0,11,12,66,0,13,1,0,0,0,2,19,1,0,0,0,4,33,1,0,0,0,6,35,1,0,0,
0,8,46,1,0,0,0,10,59,1,0,0,0,12,14,3,2,1,0,13,12,1,0,0,0,14,15,1,
0,0,0,15,13,1,0,0,0,15,16,1,0,0,0,16,17,1,0,0,0,17,18,5,0,0,1,18,
1,1,0,0,0,19,20,3,4,2,0,20,23,5,1,0,0,21,24,3,6,3,0,22,24,3,2,1,
0,23,21,1,0,0,0,23,22,1,0,0,0,24,25,1,0,0,0,25,23,1,0,0,0,25,26,
1,0,0,0,26,27,1,0,0,0,27,28,5,2,0,0,28,3,1,0,0,0,29,34,5,3,0,0,30,
34,5,4,0,0,31,32,5,5,0,0,32,34,5,14,0,0,33,29,1,0,0,0,33,30,1,0,
0,0,33,31,1,0,0,0,34,5,1,0,0,0,35,36,7,0,0,0,36,37,5,13,0,0,37,39,
5,8,0,0,38,40,3,8,4,0,39,38,1,0,0,0,39,40,1,0,0,0,40,41,1,0,0,0,
41,42,5,9,0,0,42,7,1,0,0,0,43,47,5,14,0,0,44,47,5,15,0,0,45,47,3,
10,5,0,46,43,1,0,0,0,46,44,1,0,0,0,46,45,1,0,0,0,47,56,1,0,0,0,48,
52,5,10,0,0,49,53,5,14,0,0,50,53,5,15,0,0,51,53,3,10,5,0,52,49,1,
0,0,0,52,50,1,0,0,0,52,51,1,0,0,0,53,55,1,0,0,0,54,48,1,0,0,0,55,
58,1,0,0,0,56,54,1,0,0,0,56,57,1,0,0,0,57,9,1,0,0,0,58,56,1,0,0,
0,59,60,7,1,0,0,60,11,1,0,0,0,8,15,23,25,33,39,46,52,56
]
class ptmlParser ( Parser ):
grammarFileName = "ptml.g4"
atn = ATNDeserializer().deserialize(serializedATN())
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
sharedContextCache = PredictionContextCache()
literalNames = [ "<INVALID>", "'{'", "'}'", "'sequence'", "'selector'",
"'parallel'", "'task'", "'cond'", "'('", "')'", "','",
"'True'", "'False'" ]
symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
"<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
"<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
"<INVALID>", "Names", "Integer", "Float", "LINE_COMMENT",
"WS" ]
RULE_root = 0
RULE_tree = 1
RULE_internal_node = 2
RULE_action_sign = 3
RULE_action_parm = 4
RULE_boolean = 5
ruleNames = [ "root", "tree", "internal_node", "action_sign", "action_parm",
"boolean" ]
EOF = Token.EOF
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
T__5=6
T__6=7
T__7=8
T__8=9
T__9=10
T__10=11
T__11=12
Names=13
Integer=14
Float=15
LINE_COMMENT=16
WS=17
def __init__(self, input:TokenStream, output:TextIO = sys.stdout):
super().__init__(input, output)
self.checkVersion("4.13.1")
self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache)
self._predicates = None
class RootContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def EOF(self):
return self.getToken(ptmlParser.EOF, 0)
def tree(self, i:int=None):
if i is None:
return self.getTypedRuleContexts(ptmlParser.TreeContext)
else:
return self.getTypedRuleContext(ptmlParser.TreeContext,i)
def getRuleIndex(self):
return ptmlParser.RULE_root
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterRoot" ):
listener.enterRoot(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitRoot" ):
listener.exitRoot(self)
def root(self):
localctx = ptmlParser.RootContext(self, self._ctx, self.state)
self.enterRule(localctx, 0, self.RULE_root)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 13
self._errHandler.sync(self)
_la = self._input.LA(1)
while True:
self.state = 12
self.tree()
self.state = 15
self._errHandler.sync(self)
_la = self._input.LA(1)
if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & 56) != 0)):
break
self.state = 17
self.match(ptmlParser.EOF)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class TreeContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def internal_node(self):
return self.getTypedRuleContext(ptmlParser.Internal_nodeContext,0)
def action_sign(self, i:int=None):
if i is None:
return self.getTypedRuleContexts(ptmlParser.Action_signContext)
else:
return self.getTypedRuleContext(ptmlParser.Action_signContext,i)
def tree(self, i:int=None):
if i is None:
return self.getTypedRuleContexts(ptmlParser.TreeContext)
else:
return self.getTypedRuleContext(ptmlParser.TreeContext,i)
def getRuleIndex(self):
return ptmlParser.RULE_tree
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterTree" ):
listener.enterTree(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitTree" ):
listener.exitTree(self)
def tree(self):
localctx = ptmlParser.TreeContext(self, self._ctx, self.state)
self.enterRule(localctx, 2, self.RULE_tree)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 19
self.internal_node()
self.state = 20
self.match(ptmlParser.T__0)
self.state = 23
self._errHandler.sync(self)
_la = self._input.LA(1)
while True:
self.state = 23
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [6, 7]:
self.state = 21
self.action_sign()
pass
elif token in [3, 4, 5]:
self.state = 22
self.tree()
pass
else:
raise NoViableAltException(self)
self.state = 25
self._errHandler.sync(self)
_la = self._input.LA(1)
if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & 248) != 0)):
break
self.state = 27
self.match(ptmlParser.T__1)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Internal_nodeContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def Integer(self):
return self.getToken(ptmlParser.Integer, 0)
def getRuleIndex(self):
return ptmlParser.RULE_internal_node
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterInternal_node" ):
listener.enterInternal_node(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitInternal_node" ):
listener.exitInternal_node(self)
def internal_node(self):
localctx = ptmlParser.Internal_nodeContext(self, self._ctx, self.state)
self.enterRule(localctx, 4, self.RULE_internal_node)
try:
self.state = 33
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [3]:
self.enterOuterAlt(localctx, 1)
self.state = 29
self.match(ptmlParser.T__2)
pass
elif token in [4]:
self.enterOuterAlt(localctx, 2)
self.state = 30
self.match(ptmlParser.T__3)
pass
elif token in [5]:
self.enterOuterAlt(localctx, 3)
self.state = 31
self.match(ptmlParser.T__4)
self.state = 32
self.match(ptmlParser.Integer)
pass
else:
raise NoViableAltException(self)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Action_signContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def Names(self):
return self.getToken(ptmlParser.Names, 0)
def action_parm(self):
return self.getTypedRuleContext(ptmlParser.Action_parmContext,0)
def getRuleIndex(self):
return ptmlParser.RULE_action_sign
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterAction_sign" ):
listener.enterAction_sign(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitAction_sign" ):
listener.exitAction_sign(self)
def action_sign(self):
localctx = ptmlParser.Action_signContext(self, self._ctx, self.state)
self.enterRule(localctx, 6, self.RULE_action_sign)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 35
_la = self._input.LA(1)
if not(_la==6 or _la==7):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
self.state = 36
self.match(ptmlParser.Names)
self.state = 37
self.match(ptmlParser.T__7)
self.state = 39
self._errHandler.sync(self)
_la = self._input.LA(1)
if (((_la) & ~0x3f) == 0 and ((1 << _la) & 55296) != 0):
self.state = 38
self.action_parm()
self.state = 41
self.match(ptmlParser.T__8)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Action_parmContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def Integer(self, i:int=None):
if i is None:
return self.getTokens(ptmlParser.Integer)
else:
return self.getToken(ptmlParser.Integer, i)
def Float(self, i:int=None):
if i is None:
return self.getTokens(ptmlParser.Float)
else:
return self.getToken(ptmlParser.Float, i)
def boolean(self, i:int=None):
if i is None:
return self.getTypedRuleContexts(ptmlParser.BooleanContext)
else:
return self.getTypedRuleContext(ptmlParser.BooleanContext,i)
def getRuleIndex(self):
return ptmlParser.RULE_action_parm
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterAction_parm" ):
listener.enterAction_parm(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitAction_parm" ):
listener.exitAction_parm(self)
def action_parm(self):
localctx = ptmlParser.Action_parmContext(self, self._ctx, self.state)
self.enterRule(localctx, 8, self.RULE_action_parm)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 46
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [14]:
self.state = 43
self.match(ptmlParser.Integer)
pass
elif token in [15]:
self.state = 44
self.match(ptmlParser.Float)
pass
elif token in [11, 12]:
self.state = 45
self.boolean()
pass
else:
raise NoViableAltException(self)
self.state = 56
self._errHandler.sync(self)
_la = self._input.LA(1)
while _la==10:
self.state = 48
self.match(ptmlParser.T__9)
self.state = 52
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [14]:
self.state = 49
self.match(ptmlParser.Integer)
pass
elif token in [15]:
self.state = 50
self.match(ptmlParser.Float)
pass
elif token in [11, 12]:
self.state = 51
self.boolean()
pass
else:
raise NoViableAltException(self)
self.state = 58
self._errHandler.sync(self)
_la = self._input.LA(1)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class BooleanContext(ParserRuleContext):
__slots__ = 'parser'
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
super().__init__(parent, invokingState)
self.parser = parser
def getRuleIndex(self):
return ptmlParser.RULE_boolean
def enterRule(self, listener:ParseTreeListener):
if hasattr( listener, "enterBoolean" ):
listener.enterBoolean(self)
def exitRule(self, listener:ParseTreeListener):
if hasattr( listener, "exitBoolean" ):
listener.exitBoolean(self)
def boolean(self):
localctx = ptmlParser.BooleanContext(self, self._ctx, self.state)
self.enterRule(localctx, 10, self.RULE_boolean)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 59
_la = self._input.LA(1)
if not(_la==11 or _la==12):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx

View File

@ -10,17 +10,27 @@ import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def ask_llm(question):
url = "https://45.125.46.134:25344/v1/completions"
url = "https://45.125.46.134:25344/v1/chat/completions"
headers = {"Content-Type": "application/json"}
data = {
"prompt": question
}
"model": "RoboWaiter",
"messages": [
{
"role": "system",
"content": "你是一个机器人服务员RoboWaiter. 你的职责是为顾客提供对话及具身服务。"
},
{
"role": "user",
"content": question
}
]
}
response = requests.post(url, headers=headers, json=data, verify=False)
if response.status_code == 200:
result = response.json()
return result['choices'][0]['text']
return result['choices'][0]['message']['content']
else:
return "大模型请求失败:", response.status_code