Skip to content

Commit 0a43b6c

Browse files
committed
DataFrms And PM added
1 parent fe9307c commit 0a43b6c

17 files changed

Lines changed: 12134 additions & 127 deletions

AI_AgentModel.vb

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Public Class AI_AgentModel
1111
Public UserInput As String
1212
Public Response As String
1313

14-
Private PLUGIN_FOLDER As String = Application.StartupPath & "\Plugins"
14+
1515
Public Sentiment As New Emotional_State
1616

1717
'Responses Are Genearated Externally
@@ -51,94 +51,5 @@ Public Class AI_AgentModel
5151
Public Sub New()
5252

5353
End Sub
54-
#Region "Plugins"
55-
56-
57-
''' <summary>
58-
''' Scans and Loads Plugins
59-
''' </summary>
60-
Private Function ScanPlugins() As ICollection(Of IPlugin)
61-
Return GET_PLUGINS(PLUGIN_FOLDER)
62-
End Function
63-
''' <summary>
64-
''' Resets the plugin folder and reloads plugins found
65-
''' </summary>
66-
''' <param name="Path"></param>
67-
Public Sub SET_PLUGIN_FOLDER(ByRef Path As String)
68-
PLUGIN_FOLDER = Path
69-
ScanPlugins()
70-
End Sub
71-
''' <summary>
72-
''' This populates the Plugins Responses Variable with all the responses and Plugins names
73-
''' </summary>
74-
''' <param name="_userInput"></param>
75-
''' <remarks></remarks>
76-
Private Function ExecutePlugins(ByVal _userInput As String, ByRef Plugins As ICollection(Of IPlugin)) As String
77-
Dim Str As String = ""
7854

79-
'Plugins
80-
If Plugins IsNot Nothing Then
81-
For Each NewPlugin In Plugins
82-
NewPlugin.GetResponse(_userInput)
83-
If IsNotTest(NewPlugin.Response) = True Then
84-
If NewPlugin.Response <> "" Or NewPlugin.Response <> " " Then
85-
Str &= LCase(RTrim(LTrim(Str)) & NewPlugin.Response)
86-
End If
87-
Else
88-
End If
89-
Next
90-
End If
91-
92-
Return Str
93-
End Function
94-
Private Function IsNotTest(ByVal _Response As String) As Boolean
95-
If LCase(_Response).Contains(LCase("plugintest")) = False Then
96-
Return True
97-
Else
98-
Return False
99-
End If
100-
End Function
101-
''' <summary>
102-
''' Loads the plugins into the class
103-
''' </summary>
104-
''' <param name="path">Pathname directory which contains files of type</param>
105-
''' <returns></returns>
106-
''' <remarks></remarks>
107-
Private Function GET_PLUGINS(path As String) As ICollection(Of IPlugin)
108-
On Error Resume Next
109-
Dim dllFileNames As String()
110-
If IO.Directory.Exists(path) Then
111-
dllFileNames = IO.Directory.GetFiles(path, "*.dll")
112-
Dim assemblies As ICollection(Of Reflection.Assembly) = New List(Of Reflection.Assembly)(dllFileNames.Length)
113-
For Each dllFile As String In dllFileNames
114-
Dim an As Reflection.AssemblyName = Reflection.AssemblyName.GetAssemblyName(dllFile)
115-
Dim assembly As Reflection.Assembly = Reflection.Assembly.Load(an)
116-
assemblies.Add(assembly)
117-
Next
118-
Dim pluginType As Type = GetType(IPlugin)
119-
Dim pluginTypes As ICollection(Of Type) = New List(Of Type)
120-
For Each assembly As Reflection.Assembly In assemblies
121-
If assembly <> Nothing Then
122-
Dim types As Type() = assembly.GetTypes()
123-
For Each type As Type In types
124-
If type.IsInterface Or type.IsAbstract Then
125-
Continue For
126-
Else
127-
If type.GetInterface(pluginType.FullName) <> Nothing Then
128-
pluginTypes.Add(type)
129-
End If
130-
End If
131-
Next
132-
End If
133-
Next
134-
Dim plugins As ICollection(Of IPlugin) = New List(Of IPlugin)(pluginTypes.Count)
135-
For Each type As Type In pluginTypes
136-
Dim plugin As IPlugin = Activator.CreateInstance(type)
137-
plugins.Add(plugin)
138-
Next
139-
Return plugins
140-
End If
141-
Return Nothing
142-
End Function
143-
#End Region
14455
End Class

App.config

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<configuration>
33
<configSections>
4+
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
5+
<section name="Chatbot_2020_Tutorial.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
6+
</sectionGroup>
47
</configSections>
58
<connectionStrings>
69
<add name="Chatbot_2020_Tutorial.My.MySettings.MindQAConnectionString"
@@ -10,4 +13,68 @@
1013
<startup>
1114
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
1215
</startup>
16+
<applicationSettings>
17+
<Chatbot_2020_Tutorial.My.MySettings>
18+
<setting name="SamplePlugin" serializeAs="String">
19+
<value>Imports AI_Contracts
20+
21+
Public Class Sample_Plugin_Chatbot_Tutorial
22+
Implements AI_Contracts.IPlugin
23+
24+
Public ReadOnly Property Info As String Implements IPlugin.Info
25+
Get
26+
Return "Test Plug-in for Chatbot Tutorial 2000"
27+
End Get
28+
End Property
29+
30+
Public ReadOnly Property PluginName As String Implements IPlugin.PluginName
31+
Get
32+
Return "Test Plug-In"
33+
End Get
34+
End Property
35+
36+
Dim mPreviousResponse As String = ""
37+
Public Property PreviousResponse As String Implements IPlugin.PreviousResponse
38+
Get
39+
Return mPreviousResponse
40+
End Get
41+
Set(value As String)
42+
mPreviousResponse = value
43+
End Set
44+
End Property
45+
Dim mPreviousUserinput As String = ""
46+
Public Property PreviousUserinput As String Implements IPlugin.PreviousUserinput
47+
Get
48+
Return mPreviousUserinput
49+
End Get
50+
Set(value As String)
51+
mPreviousUserinput = value
52+
End Set
53+
End Property
54+
Private MResponse As String = ""
55+
Public Property Response As String Implements IPlugin.Response
56+
Get
57+
Return MResponse
58+
End Get
59+
Set(value As String)
60+
MResponse = value
61+
End Set
62+
End Property
63+
64+
Public Function GetResponse(UserInput As String) As Boolean Implements IPlugin.GetResponse
65+
Dim NewResponse As String = ""
66+
If UCase(UserInput) = "HI" Then NewResponse = "YO BRO"
67+
If NewResponse IsNot Nothing Then
68+
Response = NewResponse
69+
Return True
70+
Else
71+
72+
End If
73+
Return False
74+
End Function
75+
End Class
76+
</value>
77+
</setting>
78+
</Chatbot_2020_Tutorial.My.MySettings>
79+
</applicationSettings>
1380
</configuration>

Chatbot_2020_Tutorial.vbproj

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,24 @@
8080
<Compile Include="AI_AgentModel.vb" />
8181
<Compile Include="ApplicationEvents.vb" />
8282
<Compile Include="Emotion_Handler.vb" />
83+
<Compile Include="FormMind_QA.Designer.vb">
84+
<DependentUpon>FormMind_QA.vb</DependentUpon>
85+
</Compile>
86+
<Compile Include="FormMind_QA.vb">
87+
<SubType>Form</SubType>
88+
</Compile>
89+
<Compile Include="FormPluginManager.designer.vb">
90+
<DependentUpon>FormPluginManager.vb</DependentUpon>
91+
</Compile>
92+
<Compile Include="FormPluginManager.vb">
93+
<SubType>Form</SubType>
94+
</Compile>
95+
<Compile Include="FormQA_Mind.Designer.vb">
96+
<DependentUpon>FormQA_Mind.vb</DependentUpon>
97+
</Compile>
98+
<Compile Include="FormQA_Mind.vb">
99+
<SubType>Form</SubType>
100+
</Compile>
83101
<Compile Include="Form_Chat_UI.designer.vb">
84102
<DependentUpon>Form_Chat_UI.vb</DependentUpon>
85103
</Compile>
@@ -91,6 +109,7 @@
91109
<DesignTime>True</DesignTime>
92110
<DependentUpon>MindQADataSet.xsd</DependentUpon>
93111
</Compile>
112+
<Compile Include="Plugins.vb" />
94113
<Compile Include="My Project\AssemblyInfo.vb" />
95114
<Compile Include="My Project\Application.Designer.vb">
96115
<AutoGen>True</AutoGen>
@@ -118,6 +137,15 @@
118137
<Compile Include="SyS.vb" />
119138
</ItemGroup>
120139
<ItemGroup>
140+
<EmbeddedResource Include="FormMind_QA.resx">
141+
<DependentUpon>FormMind_QA.vb</DependentUpon>
142+
</EmbeddedResource>
143+
<EmbeddedResource Include="FormPluginManager.resx">
144+
<DependentUpon>FormPluginManager.vb</DependentUpon>
145+
</EmbeddedResource>
146+
<EmbeddedResource Include="FormQA_Mind.resx">
147+
<DependentUpon>FormQA_Mind.vb</DependentUpon>
148+
</EmbeddedResource>
121149
<EmbeddedResource Include="Form_Chat_UI.resx">
122150
<DependentUpon>Form_Chat_UI.vb</DependentUpon>
123151
</EmbeddedResource>

0 commit comments

Comments
 (0)