Skip to content

Commit

Permalink
DataFrms And PM added
Browse files Browse the repository at this point in the history
  • Loading branch information
spydaz committed Jun 9, 2020
1 parent fe9307c commit 0a43b6c
Show file tree
Hide file tree
Showing 17 changed files with 12,134 additions and 127 deletions.
91 changes: 1 addition & 90 deletions AI_AgentModel.vb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Public Class AI_AgentModel
Public UserInput As String
Public Response As String

Private PLUGIN_FOLDER As String = Application.StartupPath & "\Plugins"

Public Sentiment As New Emotional_State

'Responses Are Genearated Externally
Expand Down Expand Up @@ -51,94 +51,5 @@ Public Class AI_AgentModel
Public Sub New()

End Sub
#Region "Plugins"


''' <summary>
''' Scans and Loads Plugins
''' </summary>
Private Function ScanPlugins() As ICollection(Of IPlugin)
Return GET_PLUGINS(PLUGIN_FOLDER)
End Function
''' <summary>
''' Resets the plugin folder and reloads plugins found
''' </summary>
''' <param name="Path"></param>
Public Sub SET_PLUGIN_FOLDER(ByRef Path As String)
PLUGIN_FOLDER = Path
ScanPlugins()
End Sub
''' <summary>
''' This populates the Plugins Responses Variable with all the responses and Plugins names
''' </summary>
''' <param name="_userInput"></param>
''' <remarks></remarks>
Private Function ExecutePlugins(ByVal _userInput As String, ByRef Plugins As ICollection(Of IPlugin)) As String
Dim Str As String = ""

'Plugins
If Plugins IsNot Nothing Then
For Each NewPlugin In Plugins
NewPlugin.GetResponse(_userInput)
If IsNotTest(NewPlugin.Response) = True Then
If NewPlugin.Response <> "" Or NewPlugin.Response <> " " Then
Str &= LCase(RTrim(LTrim(Str)) & NewPlugin.Response)
End If
Else
End If
Next
End If

Return Str
End Function
Private Function IsNotTest(ByVal _Response As String) As Boolean
If LCase(_Response).Contains(LCase("plugintest")) = False Then
Return True
Else
Return False
End If
End Function
''' <summary>
''' Loads the plugins into the class
''' </summary>
''' <param name="path">Pathname directory which contains files of type</param>
''' <returns></returns>
''' <remarks></remarks>
Private Function GET_PLUGINS(path As String) As ICollection(Of IPlugin)
On Error Resume Next
Dim dllFileNames As String()
If IO.Directory.Exists(path) Then
dllFileNames = IO.Directory.GetFiles(path, "*.dll")
Dim assemblies As ICollection(Of Reflection.Assembly) = New List(Of Reflection.Assembly)(dllFileNames.Length)
For Each dllFile As String In dllFileNames
Dim an As Reflection.AssemblyName = Reflection.AssemblyName.GetAssemblyName(dllFile)
Dim assembly As Reflection.Assembly = Reflection.Assembly.Load(an)
assemblies.Add(assembly)
Next
Dim pluginType As Type = GetType(IPlugin)
Dim pluginTypes As ICollection(Of Type) = New List(Of Type)
For Each assembly As Reflection.Assembly In assemblies
If assembly <> Nothing Then
Dim types As Type() = assembly.GetTypes()
For Each type As Type In types
If type.IsInterface Or type.IsAbstract Then
Continue For
Else
If type.GetInterface(pluginType.FullName) <> Nothing Then
pluginTypes.Add(type)
End If
End If
Next
End If
Next
Dim plugins As ICollection(Of IPlugin) = New List(Of IPlugin)(pluginTypes.Count)
For Each type As Type In pluginTypes
Dim plugin As IPlugin = Activator.CreateInstance(type)
plugins.Add(plugin)
Next
Return plugins
End If
Return Nothing
End Function
#End Region
End Class
67 changes: 67 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Chatbot_2020_Tutorial.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<connectionStrings>
<add name="Chatbot_2020_Tutorial.My.MySettings.MindQAConnectionString"
Expand All @@ -10,4 +13,68 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<applicationSettings>
<Chatbot_2020_Tutorial.My.MySettings>
<setting name="SamplePlugin" serializeAs="String">
<value>Imports AI_Contracts

Public Class Sample_Plugin_Chatbot_Tutorial
Implements AI_Contracts.IPlugin

Public ReadOnly Property Info As String Implements IPlugin.Info
Get
Return "Test Plug-in for Chatbot Tutorial 2000"
End Get
End Property

Public ReadOnly Property PluginName As String Implements IPlugin.PluginName
Get
Return "Test Plug-In"
End Get
End Property

Dim mPreviousResponse As String = ""
Public Property PreviousResponse As String Implements IPlugin.PreviousResponse
Get
Return mPreviousResponse
End Get
Set(value As String)
mPreviousResponse = value
End Set
End Property
Dim mPreviousUserinput As String = ""
Public Property PreviousUserinput As String Implements IPlugin.PreviousUserinput
Get
Return mPreviousUserinput
End Get
Set(value As String)
mPreviousUserinput = value
End Set
End Property
Private MResponse As String = ""
Public Property Response As String Implements IPlugin.Response
Get
Return MResponse
End Get
Set(value As String)
MResponse = value
End Set
End Property

Public Function GetResponse(UserInput As String) As Boolean Implements IPlugin.GetResponse
Dim NewResponse As String = ""
If UCase(UserInput) = "HI" Then NewResponse = "YO BRO"
If NewResponse IsNot Nothing Then
Response = NewResponse
Return True
Else

End If
Return False
End Function
End Class
</value>
</setting>
</Chatbot_2020_Tutorial.My.MySettings>
</applicationSettings>
</configuration>
28 changes: 28 additions & 0 deletions Chatbot_2020_Tutorial.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@
<Compile Include="AI_AgentModel.vb" />
<Compile Include="ApplicationEvents.vb" />
<Compile Include="Emotion_Handler.vb" />
<Compile Include="FormMind_QA.Designer.vb">
<DependentUpon>FormMind_QA.vb</DependentUpon>
</Compile>
<Compile Include="FormMind_QA.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormPluginManager.designer.vb">
<DependentUpon>FormPluginManager.vb</DependentUpon>
</Compile>
<Compile Include="FormPluginManager.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormQA_Mind.Designer.vb">
<DependentUpon>FormQA_Mind.vb</DependentUpon>
</Compile>
<Compile Include="FormQA_Mind.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form_Chat_UI.designer.vb">
<DependentUpon>Form_Chat_UI.vb</DependentUpon>
</Compile>
Expand All @@ -91,6 +109,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>MindQADataSet.xsd</DependentUpon>
</Compile>
<Compile Include="Plugins.vb" />
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen>
Expand Down Expand Up @@ -118,6 +137,15 @@
<Compile Include="SyS.vb" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="FormMind_QA.resx">
<DependentUpon>FormMind_QA.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormPluginManager.resx">
<DependentUpon>FormPluginManager.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormQA_Mind.resx">
<DependentUpon>FormQA_Mind.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form_Chat_UI.resx">
<DependentUpon>Form_Chat_UI.vb</DependentUpon>
</EmbeddedResource>
Expand Down
Loading

0 comments on commit 0a43b6c

Please sign in to comment.