merge with remote
This commit is contained in:
commit
dc755e33f9
|
|
@ -1,69 +1,72 @@
|
|||
<mxfile host="Electron" modified="2023-09-04T01:23:28.461Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/21.6.8 Chrome/114.0.5735.289 Electron/25.5.0 Safari/537.36" etag="A6frJLpTHNKz4FBL38kf" version="21.6.8" type="device">
|
||||
<mxfile host="Electron" modified="2023-09-05T02:34:27.433Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/21.6.8 Chrome/114.0.5735.289 Electron/25.5.0 Safari/537.36" etag="9t635ybkj5y8Tzf_PMHD" version="21.6.8" type="device">
|
||||
<diagram id="6jfvZ688tm8pOZHgqSFM" name="Page-1">
|
||||
<mxGraphModel dx="1434" dy="836" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="kNc4F-3AqUrd7lAFkTx2-3" value="BotSharp<br><span style="font-weight: normal;">Agent<br>Conversation<br>Routing</span>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffcc99;strokeColor=#36393d;fontStyle=1" parent="1" vertex="1">
|
||||
<mxCell id="kNc4F-3AqUrd7lAFkTx2-3" value="BotSharp<br><span style="font-weight: normal;">Agent<br>Conversation<br>Routing</span>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffcc99;strokeColor=#36393d;fontStyle=1;sketch=1;curveFitting=1;jiggle=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="345.71" y="340" width="214.29" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-7" value="<b>Phone&nbsp;Voice</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-7" value="<b>Phone&nbsp;Voice</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="240" y="240" width="90" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-8" value="<b>Web Chat</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-8" value="<b>Web Chat</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="360" y="240" width="90" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-9" value="<b>Message</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-9" value="<b>Message</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="474" y="240" width="90" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-10" value="<b>Open API</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-10" value="<b>Open API</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="590" y="240" width="90" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-11" value="<h1>BotSharp AI Orchestration</h1><p><br></p>" style="text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="50" y="50" width="310" height="120" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-12" value="<b>Knowlege Base</b>" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;fillColor=#eeeeee;strokeColor=#36393d;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-12" value="<b>Knowlege Base</b>" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;fillColor=#eeeeee;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="270" y="670" width="60" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-13" value="<b>Knowledge</b><br>RAG" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#cce5ff;strokeColor=#36393d;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-13" value="<b>Knowledge</b><br>RAG" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#cce5ff;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="240" y="565" width="120" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-14" value="" style="shape=curlyBracket;whiteSpace=wrap;html=1;rounded=1;labelPosition=left;verticalLabelPosition=middle;align=right;verticalAlign=middle;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-14" value="" style="shape=curlyBracket;whiteSpace=wrap;html=1;rounded=1;labelPosition=left;verticalLabelPosition=middle;align=right;verticalAlign=middle;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="150" y="260" width="20" height="450" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-15" value="<b><br><br>Agent</b>" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-15" value="<b><br><br>Agent</b>" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="345.71" y="450" width="42.86" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-16" value="<b><br><br>Agent</b>" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-16" value="<b><br><br>Agent</b>" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="431.43" y="450" width="42.86" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-17" value="<b><br><br>Agent</b>" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-17" value="<b><br><br>Agent</b>" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="517.14" y="450" width="42.86" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-18" value="<b>Meta Messenger</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#cce5ff;strokeColor=#36393d;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-18" value="<b>Meta Messenger</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#cce5ff;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="381.43" y="565" width="120" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-19" value="<b>Data Storage</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#cce5ff;strokeColor=#36393d;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-19" value="<b>Data Storage</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#cce5ff;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="520" y="565" width="120" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-20" value="<b>Storage</b>" style="shape=datastore;whiteSpace=wrap;html=1;fillColor=#eeeeee;strokeColor=#36393d;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-20" value="<b>Storage</b>" style="shape=datastore;whiteSpace=wrap;html=1;fillColor=#eeeeee;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="550" y="680" width="60" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-22" value="<b>UI/ UX</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-22" value="<b>UI/ UX</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="60" y="250" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-25" value="<b>Kernel</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-25" value="<b>Kernel</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="60" y="355" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-26" value="<b>Agent</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-26" value="<b>Agent</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="60" y="460" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-27" value="<b>Plugin</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-27" value="<b>Plugin</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="60" y="565" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-28" value="<b>Data Storage</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-28" value="<b>Data Storage</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="60" y="680" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-29" value="<b>File Storage&nbsp;&nbsp;</b>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.multi-document;whiteSpace=wrap;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="397" y="680" width="88" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
|
|
|
|||
73
docs/architecture/assets/overview.drawio
Normal file
73
docs/architecture/assets/overview.drawio
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<mxfile host="Electron" modified="2023-09-04T04:15:39.989Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/21.6.8 Chrome/114.0.5735.289 Electron/25.5.0 Safari/537.36" etag="EYukBgFOzSkZaMHsrLLu" version="21.6.8" type="device">
|
||||
<diagram id="6jfvZ688tm8pOZHgqSFM" name="Page-1">
|
||||
<mxGraphModel dx="1434" dy="836" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="kNc4F-3AqUrd7lAFkTx2-3" value="BotSharp<br><span style="font-weight: normal;">Agent<br>Conversation<br>Routing</span>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffcc99;strokeColor=#36393d;fontStyle=1;sketch=1;curveFitting=1;jiggle=2;" parent="1" vertex="1">
|
||||
<mxGeometry x="345.71" y="340" width="214.29" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-7" value="<b>Phone&nbsp;Voice</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="240" y="240" width="90" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-8" value="<b>Web Chat</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="360" y="240" width="90" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-9" value="<b>Message</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="474" y="240" width="90" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-10" value="<b>Open API</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f9f7ed;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="590" y="240" width="90" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-11" value="<h1>BotSharp AI Orchestration</h1><p><br></p>" style="text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="50" y="50" width="310" height="120" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-12" value="<b>Knowlege Base</b>" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;fillColor=#eeeeee;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="270" y="670" width="60" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-13" value="<b>Knowledge</b><br>RAG" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#cce5ff;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="240" y="565" width="120" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-14" value="" style="shape=curlyBracket;whiteSpace=wrap;html=1;rounded=1;labelPosition=left;verticalLabelPosition=middle;align=right;verticalAlign=middle;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="150" y="260" width="20" height="450" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-15" value="<b><br><br>Agent</b>" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="345.71" y="450" width="42.86" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-16" value="<b><br><br>Agent</b>" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="431.43" y="450" width="42.86" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-17" value="<b><br><br>Agent</b>" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="517.14" y="450" width="42.86" height="50" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-18" value="<b>Meta Messenger</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#cce5ff;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="381.43" y="565" width="120" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-19" value="<b>Data Storage</b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#cce5ff;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="520" y="565" width="120" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-20" value="<b>Storage</b>" style="shape=datastore;whiteSpace=wrap;html=1;fillColor=#eeeeee;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="550" y="680" width="60" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-22" value="<b>UI/ UX</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="60" y="250" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-25" value="<b>Kernel</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="60" y="355" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-26" value="<b>Agent</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="60" y="460" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-27" value="<b>Plugin</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="60" y="565" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-28" value="<b>Data Storage</b>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="60" y="680" width="60" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9DShFkwYbzccSmdIPQ0x-29" value="<b>File Storage&nbsp;&nbsp;</b>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.multi-document;whiteSpace=wrap;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="397" y="680" width="88" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
92
docs/architecture/assets/routing-reasoning.drawio
Normal file
92
docs/architecture/assets/routing-reasoning.drawio
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<mxfile host="Electron" modified="2023-09-05T01:58:45.080Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/21.6.8 Chrome/114.0.5735.289 Electron/25.5.0 Safari/537.36" etag="JZhE_J1lWIuWd_gVRcGi" version="21.6.8" type="device">
|
||||
<diagram name="Page-1" id="kO8wPeW4tp55nROlIybF">
|
||||
<mxGraphModel dx="1434" dy="836" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-7" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=0.5;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fillColor=#f8cecc;gradientColor=#ea6b66;strokeColor=#b85450;sketch=1;curveFitting=1;jiggle=2;" edge="1" parent="1" source="X3GvA0o1aQpa0wGmxsrW-1" target="X3GvA0o1aQpa0wGmxsrW-5">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-1" value="<b>User</b>" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="370" y="150" width="30" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-4" value="<div style="line-height: 18px;"><font color="#1e1e1e"><b>My previous order is P123-01, it's a slice of cheese pizza.&nbsp;</b></font></div><div style="line-height: 18px;"><font color="#1e1e1e"><b>If the baking can be done in 10 minutes, I want to order more slices.</b></font><br></div>" style="shape=callout;whiteSpace=wrap;html=1;perimeter=calloutPerimeter;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="290" y="50" width="230" height="110" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-8" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.25;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;sketch=1;curveFitting=1;jiggle=2;" edge="1" parent="1" source="X3GvA0o1aQpa0wGmxsrW-5" target="X3GvA0o1aQpa0wGmxsrW-6">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="558" y="325" />
|
||||
<mxPoint x="558" y="240" />
|
||||
<mxPoint x="670" y="240" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-19" value="How long does it take to <br>bake a slice of cheese pizza?" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fontStyle=1" vertex="1" connectable="0" parent="X3GvA0o1aQpa0wGmxsrW-8">
|
||||
<mxGeometry x="-0.0526" y="-1" relative="1" as="geometry">
|
||||
<mxPoint x="-19" y="28" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-11" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;sketch=1;curveFitting=1;jiggle=2;" edge="1" parent="1" source="X3GvA0o1aQpa0wGmxsrW-5" target="X3GvA0o1aQpa0wGmxsrW-10">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-5" value="<b><font style="font-size: 15px;">BotSharp</font></b><br>Routing with Reasoning" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffcc99;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="295" y="310" width="180" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-9" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=1;entryY=0.75;entryDx=0;entryDy=0;sketch=1;curveFitting=1;jiggle=2;" edge="1" parent="1" source="X3GvA0o1aQpa0wGmxsrW-6" target="X3GvA0o1aQpa0wGmxsrW-5">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="670" y="440" />
|
||||
<mxPoint x="558" y="440" />
|
||||
<mxPoint x="558" y="355" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-18" value="15 minutes remaining" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fontStyle=1" vertex="1" connectable="0" parent="X3GvA0o1aQpa0wGmxsrW-9">
|
||||
<mxGeometry x="-0.3214" relative="1" as="geometry">
|
||||
<mxPoint x="-68" y="-40" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-6" value="<b><br><br>Baking<br></b>" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="640" y="290" width="60" height="70" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-13" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;sketch=1;curveFitting=1;jiggle=2;" edge="1" parent="1" source="X3GvA0o1aQpa0wGmxsrW-10" target="X3GvA0o1aQpa0wGmxsrW-12">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-16" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=1;entryDx=0;entryDy=0;entryPerimeter=0;fillColor=#f8cecc;gradientColor=#ea6b66;strokeColor=#b85450;sketch=1;curveFitting=1;jiggle=2;" edge="1" parent="1" source="X3GvA0o1aQpa0wGmxsrW-10" target="X3GvA0o1aQpa0wGmxsrW-1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="200" y="510" />
|
||||
<mxPoint x="200" y="210" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-17" value="<b>I'm sorry, but the baking for your <br>previous order&nbsp;will take 15 minutes, <br>which is longer than the 10 minutes <br>you requested. <br>Therefore, we can't proceed <br>with ordering more slices at this time.</b>" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="X3GvA0o1aQpa0wGmxsrW-16">
|
||||
<mxGeometry x="-0.0341" y="-1" relative="1" as="geometry">
|
||||
<mxPoint x="-21" y="-18" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-10" value="<b>Interrupt/<br>Continue</b>" style="rhombus;whiteSpace=wrap;html=1;fillColor=#ffcc99;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="345" y="470" width="80" height="80" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-14" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.75;exitDx=0;exitDy=0;fillColor=#f8cecc;gradientColor=#ea6b66;strokeColor=#b85450;entryX=1;entryY=0.3333333333333333;entryDx=0;entryDy=0;entryPerimeter=0;sketch=1;curveFitting=1;jiggle=2;" edge="1" parent="1" source="X3GvA0o1aQpa0wGmxsrW-12" target="X3GvA0o1aQpa0wGmxsrW-1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="410" y="170" as="targetPoint" />
|
||||
<Array as="points">
|
||||
<mxPoint x="620" y="683" />
|
||||
<mxPoint x="620" y="170" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-20" value="Sure, I can help you with that. <br>How many slices of pizza would you like to order?" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fontStyle=1" vertex="1" connectable="0" parent="X3GvA0o1aQpa0wGmxsrW-14">
|
||||
<mxGeometry x="-0.2928" y="1" relative="1" as="geometry">
|
||||
<mxPoint y="1" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="X3GvA0o1aQpa0wGmxsrW-12" value="<b><br><br>Ordering</b>" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="355" y="630" width="60" height="70" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
59
docs/architecture/assets/routing.drawio
Normal file
59
docs/architecture/assets/routing.drawio
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<mxfile host="Electron" modified="2023-09-05T01:59:06.699Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/21.6.8 Chrome/114.0.5735.289 Electron/25.5.0 Safari/537.36" etag="cm-9kpR-IQWk9TqhWNbL" version="21.6.8" type="device">
|
||||
<diagram name="Page-1" id="FNTbtRNAYl-cjTgH9x2x">
|
||||
<mxGraphModel dx="1434" dy="836" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="DrYO5MgT0EdguJCGkx49-10" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;sketch=1;curveFitting=1;jiggle=2;" edge="1" parent="1" source="DrYO5MgT0EdguJCGkx49-1" target="DrYO5MgT0EdguJCGkx49-8">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="DrYO5MgT0EdguJCGkx49-1" value="<b><font style="font-size: 15px;">BotSharp</font></b>" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffcc99;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="345" y="460" width="180" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="DrYO5MgT0EdguJCGkx49-9" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=0.5;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;sketch=1;curveFitting=1;jiggle=2;fillColor=#e51400;strokeColor=#B20000;" edge="1" parent="1" source="DrYO5MgT0EdguJCGkx49-3" target="DrYO5MgT0EdguJCGkx49-1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="DrYO5MgT0EdguJCGkx49-3" value="<b>User</b>" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="420" y="340" width="30" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="DrYO5MgT0EdguJCGkx49-4" value="<div style="line-height: 18px;"><font color="#1e1e1e"><b>Can I have a slice of cheese pizza?</b></font><br></div>" style="shape=callout;whiteSpace=wrap;html=1;perimeter=calloutPerimeter;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="345" y="270" width="230" height="70" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="DrYO5MgT0EdguJCGkx49-19" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;sketch=1;curveFitting=1;jiggle=2;" edge="1" parent="1" source="DrYO5MgT0EdguJCGkx49-8" target="DrYO5MgT0EdguJCGkx49-12">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="DrYO5MgT0EdguJCGkx49-24" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;sketch=1;curveFitting=1;jiggle=2;" edge="1" parent="1" source="DrYO5MgT0EdguJCGkx49-8" target="DrYO5MgT0EdguJCGkx49-14">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="DrYO5MgT0EdguJCGkx49-25" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;sketch=1;curveFitting=1;jiggle=2;" edge="1" parent="1" source="DrYO5MgT0EdguJCGkx49-8" target="DrYO5MgT0EdguJCGkx49-15">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="DrYO5MgT0EdguJCGkx49-8" value="<b><font style="font-size: 15px;">Router</font></b>" style="strokeWidth=2;html=1;shape=mxgraph.flowchart.start_2;whiteSpace=wrap;fillColor=#ffcc99;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="385" y="570" width="100" height="100" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="DrYO5MgT0EdguJCGkx49-28" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0.75;exitDx=0;exitDy=0;entryX=0;entryY=0.3333333333333333;entryDx=0;entryDy=0;entryPerimeter=0;fillColor=#e51400;strokeColor=#B20000;sketch=1;curveFitting=1;jiggle=2;" edge="1" parent="1" source="DrYO5MgT0EdguJCGkx49-12" target="DrYO5MgT0EdguJCGkx49-3">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="190" y="793" />
|
||||
<mxPoint x="190" y="360" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="DrYO5MgT0EdguJCGkx49-29" value="<b style="font-size: 11px;">How many slices would you like to order?</b>" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];fontSize=11;" vertex="1" connectable="0" parent="DrYO5MgT0EdguJCGkx49-28">
|
||||
<mxGeometry x="-0.1958" relative="1" as="geometry">
|
||||
<mxPoint as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="DrYO5MgT0EdguJCGkx49-12" value="<b><br><br>Ordering</b>" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="240" y="740" width="60" height="70" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="DrYO5MgT0EdguJCGkx49-14" value="<b><br><br>Baking<br></b>" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="405" y="740" width="60" height="70" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="DrYO5MgT0EdguJCGkx49-15" value="<b><br><br>Payment<br></b>" style="shape=actor;whiteSpace=wrap;html=1;fillColor=#ffff88;strokeColor=#36393d;sketch=1;curveFitting=1;jiggle=2;" vertex="1" parent="1">
|
||||
<mxGeometry x="570" y="740" width="60" height="70" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
|
|
@ -4,7 +4,9 @@ namespace BotSharp.Abstraction.Conversations;
|
|||
|
||||
public interface IConversationService
|
||||
{
|
||||
IConversationStateService States { get; }
|
||||
Task<Conversation> NewConversation(Conversation conversation);
|
||||
void SetConversationId(string conversationId, string channel);
|
||||
Task<Conversation> GetConversation(string id);
|
||||
Task<List<Conversation>> GetConversations();
|
||||
Task DeleteConversation(string id);
|
||||
|
|
@ -22,13 +24,12 @@ public interface IConversationService
|
|||
/// <param name="onFunctionExecuted">This delegate is useful when you want to report progress on UI</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> SendMessage(string agentId,
|
||||
string conversationId,
|
||||
RoleDialogModel lastDalog,
|
||||
Func<RoleDialogModel, Task> onMessageReceived,
|
||||
Func<RoleDialogModel, Task> onFunctionExecuting,
|
||||
Func<RoleDialogModel, Task> onFunctionExecuted);
|
||||
|
||||
List<RoleDialogModel> GetDialogHistory(string conversationId, int lastCount = 20);
|
||||
List<RoleDialogModel> GetDialogHistory(int lastCount = 20);
|
||||
Task CleanHistory(string agentId);
|
||||
|
||||
Task CallFunctions(RoleDialogModel msg);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
using BotSharp.Abstraction.Conversations.Models;
|
||||
|
||||
namespace BotSharp.Abstraction.Conversations;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -7,9 +5,9 @@ namespace BotSharp.Abstraction.Conversations;
|
|||
/// </summary>
|
||||
public interface IConversationStateService
|
||||
{
|
||||
void SetConversation(string conversationId);
|
||||
ConversationState Load();
|
||||
ConversationState Load(string conversationId);
|
||||
string GetState(string name);
|
||||
ConversationState GetStates();
|
||||
void SetState(string name, string value);
|
||||
void CleanState();
|
||||
void Save();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
using BotSharp.Abstraction.Conversations.Models;
|
||||
|
||||
namespace BotSharp.Abstraction.Conversations;
|
||||
|
||||
public interface IConversationStorage
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ public class RetrievalArgs : RoutingArgs
|
|||
[JsonPropertyName("answer")]
|
||||
public string Answer { get; set; }
|
||||
|
||||
[JsonPropertyName("reason")]
|
||||
public string Reason { get; set; }
|
||||
[JsonPropertyName("response")]
|
||||
public string Response { get; set; }
|
||||
|
||||
[JsonPropertyName("args")]
|
||||
public JsonDocument Arguments { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using BotSharp.Abstraction.Agents.Models;
|
||||
using BotSharp.Abstraction.Templating;
|
||||
using BotSharp.Core.Templating;
|
||||
|
||||
namespace BotSharp.Core.Agents.Services;
|
||||
|
||||
|
|
@ -56,9 +55,8 @@ public partial class AgentService
|
|||
|
||||
private void PopulateState(Dictionary<string, object> dict)
|
||||
{
|
||||
var stateService = _services.GetRequiredService<IConversationStateService>();
|
||||
var state = stateService.Load();
|
||||
foreach (var t in state)
|
||||
var conv = _services.GetRequiredService<IConversationService>();
|
||||
foreach (var t in conv.States.GetStates())
|
||||
{
|
||||
dict[t.Key] = t.Value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ public partial class ConversationService
|
|||
public async Task CallFunctions(RoleDialogModel msg)
|
||||
{
|
||||
var hooks = _services.GetServices<IConversationHook>()
|
||||
.OrderBy(x => x.Priority).ToList();
|
||||
.OrderBy(x => x.Priority)
|
||||
.ToList();
|
||||
|
||||
// Invoke functions
|
||||
var functions = _services.GetServices<IFunctionCallback>()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ public partial class ConversationService
|
|||
int currentRecursiveDepth = 0;
|
||||
|
||||
private async Task<bool> GetChatCompletionsAsyncRecursively(IChatCompletion chatCompletion,
|
||||
string conversationId,
|
||||
Agent agent,
|
||||
List<RoleDialogModel> wholeDialogs,
|
||||
Func<RoleDialogModel, Task> onMessageReceived,
|
||||
|
|
@ -43,7 +42,7 @@ public partial class ConversationService
|
|||
await HandleAssistantMessage(msg, onMessageReceived);
|
||||
|
||||
// Add to dialog history
|
||||
_storage.Append(conversationId, agent.Id, msg);
|
||||
_storage.Append(_conversationId, agent.Id, msg);
|
||||
}, async fn =>
|
||||
{
|
||||
var preAgentId = agent.Id;
|
||||
|
|
@ -72,7 +71,6 @@ public partial class ConversationService
|
|||
wholeDialogs.Add(fn);
|
||||
|
||||
await GetChatCompletionsAsyncRecursively(chatCompletion,
|
||||
conversationId,
|
||||
agent,
|
||||
wholeDialogs,
|
||||
onMessageReceived,
|
||||
|
|
@ -103,7 +101,6 @@ public partial class ConversationService
|
|||
wholeDialogs.Add(fn);
|
||||
|
||||
await GetChatCompletionsAsyncRecursively(chatCompletion,
|
||||
conversationId,
|
||||
agent,
|
||||
wholeDialogs,
|
||||
onMessageReceived,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using BotSharp.Abstraction.Agents.Enums;
|
||||
using BotSharp.Abstraction.Agents.Models;
|
||||
using BotSharp.Abstraction.Conversations.Models;
|
||||
using BotSharp.Abstraction.MLTasks;
|
||||
using BotSharp.Abstraction.Routing.Settings;
|
||||
using BotSharp.Core.Routing;
|
||||
|
|
@ -9,30 +8,13 @@ namespace BotSharp.Core.Conversations.Services;
|
|||
|
||||
public partial class ConversationService
|
||||
{
|
||||
public async Task<bool> SendMessage(string agentId, string conversationId,
|
||||
public async Task<bool> SendMessage(string agentId,
|
||||
RoleDialogModel lastDialog,
|
||||
Func<RoleDialogModel, Task> onMessageReceived,
|
||||
Func<RoleDialogModel, Task> onFunctionExecuting,
|
||||
Func<RoleDialogModel, Task> onFunctionExecuted)
|
||||
{
|
||||
var converation = await GetConversation(conversationId);
|
||||
|
||||
// Create conversation if this conversation not exists
|
||||
if (converation == null)
|
||||
{
|
||||
var sess = new Conversation
|
||||
{
|
||||
Id = conversationId,
|
||||
AgentId = agentId
|
||||
};
|
||||
converation = await NewConversation(sess);
|
||||
}
|
||||
|
||||
// conversation state
|
||||
var stateService = _services.GetRequiredService<IConversationStateService>();
|
||||
stateService.SetConversation(conversationId);
|
||||
stateService.Load();
|
||||
stateService.SetState("channel", lastDialog.Channel);
|
||||
var conversation = await GetConversationRecord(agentId);
|
||||
|
||||
var agentService = _services.GetRequiredService<IAgentService>();
|
||||
Agent agent = await agentService.LoadAgent(agentId);
|
||||
|
|
@ -41,10 +23,10 @@ public partial class ConversationService
|
|||
|
||||
lastDialog.CurrentAgentId = agent.Id;
|
||||
|
||||
var wholeDialogs = GetDialogHistory(conversationId);
|
||||
var wholeDialogs = GetDialogHistory();
|
||||
wholeDialogs.Add(lastDialog);
|
||||
|
||||
_storage.Append(conversationId, agent.Id, lastDialog);
|
||||
_storage.Append(_conversationId, agent.Id, lastDialog);
|
||||
|
||||
// Get relevant domain knowledge
|
||||
/*if (_settings.EnableKnowledgeBase)
|
||||
|
|
@ -63,7 +45,7 @@ public partial class ConversationService
|
|||
foreach (var hook in hooks)
|
||||
{
|
||||
hook.SetAgent(agent)
|
||||
.SetConversation(converation);
|
||||
.SetConversation(conversation);
|
||||
|
||||
await hook.OnDialogsLoaded(wholeDialogs);
|
||||
await hook.BeforeCompletion(lastDialog);
|
||||
|
|
@ -73,7 +55,7 @@ public partial class ConversationService
|
|||
{
|
||||
var response = new RoleDialogModel(AgentRole.Assistant, lastDialog.Content);
|
||||
await onMessageReceived(response);
|
||||
_storage.Append(conversationId, agent.Id, response);
|
||||
_storage.Append(_conversationId, agent.Id, response);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -114,13 +96,15 @@ public partial class ConversationService
|
|||
simulator.Dialogs.ForEach(x =>
|
||||
{
|
||||
wholeDialogs.Add(x);
|
||||
_storage.Append(conversationId, agent.Id, x);
|
||||
if (x.Content != null)
|
||||
{
|
||||
_storage.Append(_conversationId, agent.Id, x);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var chatCompletion = GetChatCompletion();
|
||||
var result = await GetChatCompletionsAsyncRecursively(chatCompletion,
|
||||
conversationId,
|
||||
agent,
|
||||
wholeDialogs,
|
||||
onMessageReceived,
|
||||
|
|
@ -130,6 +114,24 @@ public partial class ConversationService
|
|||
return result;
|
||||
}
|
||||
|
||||
private async Task<Conversation> GetConversationRecord(string agentId)
|
||||
{
|
||||
var converation = await GetConversation(_conversationId);
|
||||
|
||||
// Create conversation if this conversation not exists
|
||||
if (converation == null)
|
||||
{
|
||||
var sess = new Conversation
|
||||
{
|
||||
Id = _conversationId,
|
||||
AgentId = agentId
|
||||
};
|
||||
converation = await NewConversation(sess);
|
||||
}
|
||||
|
||||
return converation;
|
||||
}
|
||||
|
||||
private void SaveStateByArgs(string args)
|
||||
{
|
||||
var stateService = _services.GetRequiredService<IConversationStateService>();
|
||||
|
|
|
|||
|
|
@ -1,10 +1,3 @@
|
|||
using BotSharp.Abstraction.Conversations.Models;
|
||||
using BotSharp.Abstraction.Conversations.Settings;
|
||||
using BotSharp.Abstraction.Repositories;
|
||||
using BotSharp.Abstraction.Repositories.Records;
|
||||
using MongoDB.Bson;
|
||||
using System.IO;
|
||||
|
||||
namespace BotSharp.Core.Conversations.Services;
|
||||
|
||||
public partial class ConversationService : IConversationService
|
||||
|
|
@ -14,17 +7,23 @@ public partial class ConversationService : IConversationService
|
|||
private readonly IUserIdentity _user;
|
||||
private readonly ConversationSetting _settings;
|
||||
private readonly IConversationStorage _storage;
|
||||
private readonly IConversationStateService _state;
|
||||
private string _conversationId;
|
||||
|
||||
public IConversationStateService States => _state;
|
||||
|
||||
public ConversationService(IServiceProvider services,
|
||||
IUserIdentity user,
|
||||
ConversationSetting settings,
|
||||
IConversationStorage storage,
|
||||
IConversationStateService state,
|
||||
ILogger<ConversationService> logger)
|
||||
{
|
||||
_services = services;
|
||||
_user = user;
|
||||
_settings = settings;
|
||||
_storage = storage;
|
||||
_state = state;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
|
@ -80,11 +79,19 @@ public partial class ConversationService : IConversationService
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<RoleDialogModel> GetDialogHistory(string conversationId, int lastCount = 20)
|
||||
public List<RoleDialogModel> GetDialogHistory(int lastCount = 20)
|
||||
{
|
||||
var dialogs = _storage.GetDialogs(conversationId);
|
||||
var dialogs = _storage.GetDialogs(_conversationId);
|
||||
return dialogs
|
||||
.Where(x => x.CreatedAt > DateTime.UtcNow.AddHours(-8))
|
||||
.TakeLast(lastCount).ToList();
|
||||
.TakeLast(lastCount)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public void SetConversationId(string conversationId, string channel)
|
||||
{
|
||||
_conversationId = conversationId;
|
||||
_state.Load(_conversationId);
|
||||
_state.SetState("channel", channel);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,3 @@
|
|||
using BotSharp.Abstraction.Conversations.Models;
|
||||
using BotSharp.Abstraction.Repositories;
|
||||
using BotSharp.Abstraction.Repositories.Models;
|
||||
using BotSharp.Abstraction.Repositories.Records;
|
||||
using MongoDB.Bson;
|
||||
using System.IO;
|
||||
|
||||
namespace BotSharp.Core.Conversations.Services;
|
||||
|
|
@ -14,11 +9,8 @@ public class ConversationStateService : IConversationStateService, IDisposable
|
|||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IServiceProvider _services;
|
||||
private readonly AgentSettings _agentSettings;
|
||||
private readonly IUserIdentity _user;
|
||||
private readonly IBotSharpRepository _db;
|
||||
private ConversationState _state;
|
||||
private BotSharpDatabaseSettings _dbSettings;
|
||||
private ConversationState _states;
|
||||
private MyDatabaseSettings _dbSettings;
|
||||
private string _conversationId;
|
||||
private string _file;
|
||||
private List<KeyValueModel> _savedStates;
|
||||
|
|
@ -33,19 +25,17 @@ public class ConversationStateService : IConversationStateService, IDisposable
|
|||
_logger = logger;
|
||||
_services = services;
|
||||
_dbSettings = dbSettings;
|
||||
_agentSettings = agentSettings;
|
||||
_user = user;
|
||||
_db = db;
|
||||
_states = new ConversationState();
|
||||
}
|
||||
|
||||
public void SetState(string name, string value)
|
||||
{
|
||||
var hooks = _services.GetServices<IConversationHook>();
|
||||
string preValue = _state.ContainsKey(name) ? _state[name] : "";
|
||||
if (!_state.ContainsKey(name) || _state[name] != value)
|
||||
string preValue = _states.ContainsKey(name) ? _states[name] : "";
|
||||
if (!_states.ContainsKey(name) || _states[name] != value)
|
||||
{
|
||||
var currentValue = value;
|
||||
_state[name] = currentValue;
|
||||
_states[name] = currentValue;
|
||||
_logger.LogInformation($"Set state: {name} = {value}");
|
||||
foreach (var hook in hooks)
|
||||
{
|
||||
|
|
@ -54,7 +44,7 @@ public class ConversationStateService : IConversationStateService, IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
public void SetConversation(string conversationId)
|
||||
public ConversationState Load(string conversationId)
|
||||
{
|
||||
_conversationId = conversationId;
|
||||
}
|
||||
|
|
@ -77,14 +67,14 @@ public class ConversationStateService : IConversationStateService, IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation($"Loaded state {_conversationId}");
|
||||
_logger.LogInformation($"Loaded conversation states: {_conversationId}");
|
||||
var hooks = _services.GetServices<IConversationHook>();
|
||||
foreach (var hook in hooks)
|
||||
{
|
||||
hook.OnStateLoaded(_state).Wait();
|
||||
hook.OnStateLoaded(_states).Wait();
|
||||
}
|
||||
|
||||
return _state;
|
||||
return _states;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
|
|
@ -126,13 +116,16 @@ public class ConversationStateService : IConversationStateService, IDisposable
|
|||
return stateFile;
|
||||
}
|
||||
|
||||
public ConversationState GetStates()
|
||||
=> _states;
|
||||
|
||||
public string GetState(string name)
|
||||
{
|
||||
if (!_state.ContainsKey(name))
|
||||
if (!_states.ContainsKey(name))
|
||||
{
|
||||
_state[name] = "";
|
||||
_states[name] = "";
|
||||
}
|
||||
return _state[name];
|
||||
return _states[name];
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ public class Simulator
|
|||
}
|
||||
else if (args.Function == "interrupt_task_execution")
|
||||
{
|
||||
response.Content = args.Parameters.Reason;
|
||||
response.ExecutionResult = args.Parameters.Reason;
|
||||
response.Content = args.Parameters.Response;
|
||||
response.ExecutionResult = args.Parameters.Response;
|
||||
}
|
||||
else if (args.Function == "response_to_user")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,11 +44,13 @@ public class ConversationController : ControllerBase, IApiAdapter
|
|||
[FromQuery] string? channel = "openapi")
|
||||
{
|
||||
var conv = _services.GetRequiredService<IConversationService>();
|
||||
|
||||
conv.SetConversationId(conversationId, channel);
|
||||
input.States.ForEach(x => conv.States.SetState(x.Split('=')[0], x.Split('=')[1]));
|
||||
|
||||
var response = new MessageResponseModel();
|
||||
var stackMsg = new List<RoleDialogModel>();
|
||||
|
||||
await conv.SendMessage(agentId, conversationId,
|
||||
await conv.SendMessage(agentId,
|
||||
new RoleDialogModel("user", input.Text)
|
||||
{
|
||||
Channel = channel
|
||||
|
|
|
|||
|
|
@ -3,4 +3,9 @@ namespace BotSharp.OpenAPI.ViewModels.Conversations;
|
|||
public class NewMessageModel
|
||||
{
|
||||
public string Text { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Conversation states from input
|
||||
/// </summary>
|
||||
public List<string> States { get; set; } = new List<string>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
using BotSharp.Abstraction.Conversations;
|
||||
using BotSharp.Abstraction.Conversations.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using BotSharp.Abstraction.Agents.Models;
|
||||
using BotSharp.Abstraction.Agents.Enums;
|
||||
|
||||
namespace BotSharp.Plugin.ChatbotUI.Controllers;
|
||||
|
|
@ -62,18 +61,19 @@ public class ChatbotUiController : ControllerBase, IApiAdapter
|
|||
Response.Headers.Add(HeaderNames.Connection, "keep-alive");
|
||||
var outputStream = Response.Body;
|
||||
|
||||
var channel = "webchat";
|
||||
var conversation = input.Messages
|
||||
.Where(x => x.Role == AgentRole.User)
|
||||
.Select(x => new RoleDialogModel(x.Role, x.Content)
|
||||
{
|
||||
Channel = "webchat"
|
||||
})
|
||||
.Last();
|
||||
Channel = channel
|
||||
}).Last();
|
||||
|
||||
var conversationService = _services.GetRequiredService<IConversationService>();
|
||||
var conv = _services.GetRequiredService<IConversationService>();
|
||||
conv.SetConversationId(input.ConversationId, channel);
|
||||
input.States.ForEach(x => conv.States.SetState(x.Split('=')[0], x.Split('=')[1]));
|
||||
|
||||
var result = await conversationService.SendMessage(input.AgentId,
|
||||
input.ConversationId,
|
||||
var result = await conv.SendMessage(input.AgentId,
|
||||
conversation,
|
||||
async msg =>
|
||||
await OnChunkReceived(outputStream, msg),
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ public class OpenAiMessageInput
|
|||
public int MaxTokens { get; set; } = 4000;
|
||||
public bool Stream { get; set; } = true;
|
||||
public float Temperature { get; set; } = 0.9f;
|
||||
/// <summary>
|
||||
/// Conversation states from input
|
||||
/// </summary>
|
||||
public List<string> States { get; set; } = new List<string>();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -67,8 +67,6 @@ public class WebhookController : ControllerBase
|
|||
// received message
|
||||
if (req.Entry[0].Messaging[0].Message != null)
|
||||
{
|
||||
var conv = _services.GetRequiredService<IConversationService>();
|
||||
|
||||
var reply = new QuickReplyMessage();
|
||||
var senderId = req.Entry[0].Messaging[0].Sender.Id;
|
||||
var input = req.Entry[0].Messaging[0].Message.Text;
|
||||
|
|
@ -99,7 +97,10 @@ public class WebhookController : ControllerBase
|
|||
});
|
||||
|
||||
// Go to LLM
|
||||
var result = await conv.SendMessage(agentId, senderId, new RoleDialogModel("user", input)
|
||||
var conv = _services.GetRequiredService<IConversationService>();
|
||||
conv.SetConversationId(senderId, "messenger");
|
||||
|
||||
var result = await conv.SendMessage(agentId, new RoleDialogModel("user", input)
|
||||
{
|
||||
Channel = "messenger"
|
||||
}, async msg =>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ using System;
|
|||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using Tensorflow;
|
||||
using static Tensorflow.KerasApi;
|
||||
using Tensorflow.Keras.Engine;
|
||||
using Tensorflow.NumPy;
|
||||
|
|
@ -16,11 +15,7 @@ using BotSharp.Plugin.RoutingSpeeder.Providers.Models;
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Linq;
|
||||
using Tensorflow.Keras;
|
||||
using System.Numerics;
|
||||
using Newtonsoft.Json;
|
||||
using Tensorflow.Keras.Layers;
|
||||
using BotSharp.Abstraction.Agents;
|
||||
using BotSharp.Abstraction.Knowledges;
|
||||
|
||||
namespace BotSharp.Plugin.RoutingSpeeder.Providers;
|
||||
|
||||
|
|
@ -33,11 +28,8 @@ public class IntentClassifier
|
|||
private bool _isModelReady;
|
||||
public bool isModelReady => _isModelReady;
|
||||
private ClassifierSetting _settings;
|
||||
|
||||
private string[] _labels;
|
||||
|
||||
public string[] Labels => GetLabels();
|
||||
|
||||
private int _numLabels
|
||||
{
|
||||
get
|
||||
|
|
@ -67,7 +59,7 @@ public class IntentClassifier
|
|||
}
|
||||
|
||||
var vector = _services.GetServices<ITextEmbedding>()
|
||||
.FirstOrDefault(x => x.GetType().FullName.EndsWith(_knowledgeBaseSettings.TextEmbedding));
|
||||
.FirstOrDefault(x => x.GetType().FullName.EndsWith(_knowledgeBaseSettings.TextEmbedding));
|
||||
|
||||
var layers = new List<ILayer>
|
||||
{
|
||||
|
|
@ -89,10 +81,9 @@ public class IntentClassifier
|
|||
{
|
||||
_model.compile(optimizer: keras.optimizers.Adam(trainingParams.LearningRate),
|
||||
loss: keras.losses.SparseCategoricalCrossentropy(),
|
||||
metrics: new[] { "accuracy" }
|
||||
);
|
||||
metrics: new[] { "accuracy" });
|
||||
|
||||
CallbackParams callback_parameters = new CallbackParams
|
||||
var callback_parameters = new CallbackParams
|
||||
{
|
||||
Model = _model,
|
||||
Epochs = trainingParams.Epochs,
|
||||
|
|
@ -100,9 +91,12 @@ public class IntentClassifier
|
|||
Steps = 10
|
||||
};
|
||||
|
||||
ICallback earlyStop = new EarlyStopping(callback_parameters, "accuracy");
|
||||
var earlyStop = new EarlyStopping(callback_parameters, "accuracy");
|
||||
|
||||
var callbacks = new List<ICallback>() { earlyStop };
|
||||
var callbacks = new List<ICallback>()
|
||||
{
|
||||
earlyStop
|
||||
};
|
||||
|
||||
var weights = LoadWeights(trainingParams.Inference);
|
||||
|
||||
|
|
@ -110,7 +104,6 @@ public class IntentClassifier
|
|||
batch_size: trainingParams.BatchSize,
|
||||
epochs: trainingParams.Epochs,
|
||||
callbacks: callbacks,
|
||||
// validation_split: 0.1f,
|
||||
shuffle: true);
|
||||
|
||||
_model.save_weights(weights);
|
||||
|
|
@ -120,7 +113,9 @@ public class IntentClassifier
|
|||
|
||||
public string LoadWeights(bool inference = true)
|
||||
{
|
||||
var agentService = _services.CreateScope().ServiceProvider.GetRequiredService<IAgentService>();
|
||||
var agentService = _services.CreateScope()
|
||||
.ServiceProvider
|
||||
.GetRequiredService<IAgentService>();
|
||||
|
||||
var weightsFile = Path.Combine(agentService.GetDataDir(), _settings.MODEL_DIR, $"intent-classifier.h5");
|
||||
|
||||
|
|
@ -129,13 +124,13 @@ public class IntentClassifier
|
|||
_model.load_weights(weightsFile);
|
||||
_isModelReady = true;
|
||||
Console.WriteLine($"Successfully load the weights!");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var logInfo = inference ? "No available weights." : "Will implement model training process and write trained weights into local";
|
||||
Console.WriteLine(logInfo);
|
||||
}
|
||||
|
||||
return weightsFile;
|
||||
}
|
||||
|
||||
|
|
@ -152,24 +147,33 @@ public class IntentClassifier
|
|||
|
||||
public (NDArray, NDArray) PrepareLoadData()
|
||||
{
|
||||
var agentService = _services.CreateScope().ServiceProvider.GetRequiredService<IAgentService>();
|
||||
string rootDirectory = Path.Combine(agentService.GetDataDir(), _settings.RAW_DATA_DIR);
|
||||
string saveLabelDirectory = Path.Combine(agentService.GetDataDir(), _settings.MODEL_DIR, _settings.LABEL_FILE_NAME);
|
||||
var agentService = _services.CreateScope()
|
||||
.ServiceProvider
|
||||
.GetRequiredService<IAgentService>();
|
||||
string rootDirectory = Path.Combine(
|
||||
agentService.GetDataDir(),
|
||||
_settings.RAW_DATA_DIR);
|
||||
string saveLabelDirectory = Path.Combine(
|
||||
agentService.GetDataDir(),
|
||||
_settings.MODEL_DIR,
|
||||
_settings.LABEL_FILE_NAME);
|
||||
|
||||
if (!Directory.Exists(rootDirectory))
|
||||
{
|
||||
throw new Exception($"No training data found! Please put training data in this path: {rootDirectory}");
|
||||
}
|
||||
|
||||
// Do embedding and store results
|
||||
var vector = _services.GetRequiredService<ITextEmbedding>();
|
||||
|
||||
var vectorList = new List<float[]>();
|
||||
|
||||
var labelList = new List<string>();
|
||||
|
||||
foreach (var filePath in GetFiles())
|
||||
{
|
||||
var texts = File.ReadAllLines(filePath, Encoding.UTF8).Select(x => TextClean(x)).ToList();
|
||||
var texts = File.ReadAllLines(filePath, Encoding.UTF8)
|
||||
.Select(x => TextClean(x))
|
||||
.ToList();
|
||||
|
||||
vectorList.AddRange(vector.GetVectors(texts));
|
||||
string fileName = Path.GetFileNameWithoutExtension(filePath);
|
||||
labelList.AddRange(Enumerable.Repeat(fileName, texts.Count).ToList());
|
||||
|
|
@ -185,25 +189,39 @@ public class IntentClassifier
|
|||
for (int i = 0; i < vectorList.Count; i++)
|
||||
{
|
||||
x[i] = vectorList[i];
|
||||
// y[i] = (float)uniqueLabelList.IndexOf(labelList[i]);
|
||||
y[i] = (float)Array.IndexOf(uniqueLabelList, labelList[i]);
|
||||
}
|
||||
|
||||
return (x, y);
|
||||
}
|
||||
|
||||
public string[] GetFiles(string prefix = "intent")
|
||||
{
|
||||
var agentService = _services.CreateScope().ServiceProvider.GetRequiredService<IAgentService>();
|
||||
var agentService = _services.CreateScope()
|
||||
.ServiceProvider
|
||||
.GetRequiredService<IAgentService>();
|
||||
string rootDirectory = Path.Combine(agentService.GetDataDir(), _settings.RAW_DATA_DIR);
|
||||
return Directory.GetFiles(rootDirectory).Where(x => Path.GetFileNameWithoutExtension(x).StartsWith(prefix)).OrderBy(x => x).ToArray();
|
||||
|
||||
return Directory.GetFiles(rootDirectory)
|
||||
.Where(x => Path.GetFileNameWithoutExtension(x)
|
||||
.StartsWith(prefix))
|
||||
.OrderBy(x => x)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
public string[] GetLabels()
|
||||
{
|
||||
if (_labels == null)
|
||||
{
|
||||
var agentService = _services.CreateScope().ServiceProvider.GetRequiredService<IAgentService>();
|
||||
string rootDirectory = Path.Combine(agentService.GetDataDir(), _settings.MODEL_DIR, _settings.LABEL_FILE_NAME);
|
||||
var agentService = _services.CreateScope()
|
||||
.ServiceProvider
|
||||
.GetRequiredService<IAgentService>();
|
||||
string rootDirectory = Path.Combine(
|
||||
agentService.GetDataDir(),
|
||||
_settings.MODEL_DIR,
|
||||
_settings.LABEL_FILE_NAME
|
||||
);
|
||||
|
||||
var labelText = File.ReadAllLines(rootDirectory);
|
||||
_labels = labelText.OrderBy(x => x).ToArray();
|
||||
}
|
||||
|
|
@ -217,9 +235,11 @@ public class IntentClassifier
|
|||
// Remove digits
|
||||
// To lowercase
|
||||
var processedText = Regex.Replace(text, "[AB0-9]", " ");
|
||||
processedText = string.Join("", processedText.Select(c => char.IsPunctuation(c) ? ' ' : c).ToList());
|
||||
processedText = processedText.Replace(" ", " ").ToLower();
|
||||
return processedText;
|
||||
var replacedTextList = processedText.Select(c => char.IsPunctuation(c) ? ' ' : c).ToList();
|
||||
|
||||
return string.Join("", replacedTextList)
|
||||
.Replace(" ", " ")
|
||||
.ToLower();
|
||||
}
|
||||
|
||||
public string Predict(NDArray vector, float confidenceScore = 0.9f)
|
||||
|
|
@ -229,8 +249,8 @@ public class IntentClassifier
|
|||
InitClassifer();
|
||||
}
|
||||
|
||||
// Generate and post-process prediction
|
||||
var prob = _model.predict(vector).numpy();
|
||||
|
||||
var probLabel = tf.arg_max(prob, -1).numpy().ToArray<long>();
|
||||
prob = np.squeeze(prob, axis: 0);
|
||||
|
||||
|
|
@ -239,9 +259,9 @@ public class IntentClassifier
|
|||
return string.Empty;
|
||||
}
|
||||
|
||||
var prediction = _labels[probLabel[0]];
|
||||
var labelIndex = probLabel[0];
|
||||
|
||||
return prediction;
|
||||
return _labels[labelIndex];
|
||||
}
|
||||
public void InitClassifer(bool inference = true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -48,7 +48,10 @@ namespace BotSharp.Plugin.WeChat
|
|||
|
||||
var conversationService = scoped.GetRequiredService<IConversationService>();
|
||||
|
||||
var latestConversationId = (await conversationService.GetConversations()).OrderByDescending(_ => _.CreatedTime).FirstOrDefault()?.Id;
|
||||
var latestConversationId = (await conversationService.GetConversations())
|
||||
.OrderByDescending(_ => _.CreatedTime)
|
||||
.FirstOrDefault()?.Id;
|
||||
conversationService.SetConversationId(latestConversationId, "wechat");
|
||||
|
||||
latestConversationId ??= (await conversationService.NewConversation(new Conversation()
|
||||
{
|
||||
|
|
@ -56,7 +59,7 @@ namespace BotSharp.Plugin.WeChat
|
|||
AgentId = AgentId
|
||||
}))?.Id;
|
||||
|
||||
var result = await conversationService.SendMessage(AgentId, latestConversationId, new RoleDialogModel("user", message), async msg =>
|
||||
var result = await conversationService.SendMessage(AgentId, new RoleDialogModel("user", message), async msg =>
|
||||
{
|
||||
await ReplyTextMessageAsync(openid, msg.Content);
|
||||
}, async functionExecuting =>
|
||||
|
|
|
|||
14
tests/BotSharp.Plugin.PizzaBot/Functions/GetBakingTimeFn.cs
Normal file
14
tests/BotSharp.Plugin.PizzaBot/Functions/GetBakingTimeFn.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
using BotSharp.Abstraction.Conversations.Models;
|
||||
|
||||
namespace BotSharp.Plugin.PizzaBot.Functions;
|
||||
|
||||
public class GetBakingTimeFn : IFunctionCallback
|
||||
{
|
||||
public string Name => "get_cooking_remaing_time";
|
||||
|
||||
public async Task<bool> Execute(RoleDialogModel message)
|
||||
{
|
||||
message.ExecutionResult = "15 minutes remaining";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
using BotSharp.Abstraction.Conversations.Models;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace BotSharp.Plugin.PizzaBot.Functions;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ using BotSharp.Abstraction.Conversations.Models;
|
|||
|
||||
namespace BotSharp.Plugin.PizzaBot.Functions;
|
||||
|
||||
public class MakeOrderFn : IFunctionCallback
|
||||
public class PlaceOrderFn : IFunctionCallback
|
||||
{
|
||||
public string Name => "make_order";
|
||||
public string Name => "place_an_order";
|
||||
|
||||
public async Task<bool> Execute(RoleDialogModel message)
|
||||
{
|
||||
|
|
@ -10,7 +10,7 @@ public class PizzaBotAgentHook : AgentHookBase
|
|||
public override bool OnInstructionLoaded(string template, Dictionary<string, object> dict)
|
||||
{
|
||||
dict["current_date"] = $"{DateTime.Now:MMM dd, yyyy}";
|
||||
dict["current_time"] = $"{DateTime.Now:hh:mm t}";
|
||||
dict["current_time"] = $"{DateTime.Now:hh:mm tt}";
|
||||
dict["current_weekday"] = $"{DateTime.Now:dddd}";
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,9 @@ public class PizzaBotPlugin : IBotSharpPlugin
|
|||
// Register callback function
|
||||
services.AddScoped<IFunctionCallback, GetPizzaTypesFn>();
|
||||
services.AddScoped<IFunctionCallback, GetPizzaPricesFn>();
|
||||
services.AddScoped<IFunctionCallback, MakeOrderFn>();
|
||||
services.AddScoped<IFunctionCallback, PlaceOrderFn>();
|
||||
services.AddScoped<IFunctionCallback, OrderFoundFn>();
|
||||
services.AddScoped<IFunctionCallback, GetBakingTimeFn>();
|
||||
|
||||
// Register hooks
|
||||
services.AddScoped<IAgentHook, PizzaBotAgentHook>();
|
||||
|
|
|
|||
Loading…
Reference in a new issue