rich kopelow
V.I.P
Posts: 47
Joined: Thu Aug 25, 2016 7:45 am

Re: User persistent problem

Tue Aug 30, 2016 1:07 am

I did try something like:
botUser.UserSettings["Concept"].List.Clear();
botUser.UserSettings["Concept"].List.Add("Intro");
as a hack, but it did no good. I believe I did that to the Bot's Main user as well just in case, no joy.
Is there another way? If so I could certainly read the persisted settings myself and call some function to force it.

I'll try to build a minimalist example.
Rich.

rich kopelow
V.I.P
Posts: 47
Joined: Thu Aug 25, 2016 7:45 am

Re: User persistent problem

Tue Aug 30, 2016 2:59 am

Leslie, I tried to send a PM with a zip file of this project attached, but could not upload the file.
I created a vs2015 windows forms app "chatUserTest". I renamed the main form to "Main" and added a few controls:
TextBoxes: UserSettings (multiline, scrollbars:both), OutputBox
ComboBox: InputBox (with choices "test message", "set intro on", and "set intro off"
CheckBox: NewUser (default: unchecked)
Button: chatButton

The code for the Main.cs is:

CSharp Code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Syn.Bot.Siml;
using System.IO;
using System.Xml.Linq;

namespace chatUserTest
{
    public partial class Main : Form
    {
        SimlBot simlBot;
        BotUser botUser;
        public Main()
        {
            InitializeComponent();
        }

        private void Main_Load(object sender, EventArgs e)
        {
            simlBot = new SimlBot();
            simlBot.PackageManager.LoadFromString(File.ReadAllText(@"testUser.simlpk"));
            SettingsBox.Text = simlBot.DefaultUserSettings.GetDocument().ToString();
            botUser = new BotUser(simlBot, "rich");
        }

        private void chatButton_Click(object sender, EventArgs e)
        {
            if (NewUser.Checked)
                botUser = new BotUser(simlBot, "rich");
            XElement context = XElement.Parse(SettingsBox.Text).Element("UserSettings");
            botUser.Settings.Load(context);
            ChatRequest request = new ChatRequest(InputBox.Text, botUser);
            ChatResult result = simlBot.Chat(request);
            SettingsBox.Text = botUser.Settings.GetDocument().ToString();
            OutputBox.Text = result.Responses[0].OutputMessage;
        }
    }
}
The siml project was built with empty template and I modified UserSettings:

SIML Code

<Siml>
  <!--UserSettings: This element is used to store user related predicates. To use a variable as an array use <Value> tag within a Variable-->
  <!--Note: The default values declared below are used to initialize variables for the "Main" user-->
  <!--Note: Values declared below are also used to initialize variables for ALL users that interact with Syn Web Assistant-->
  <!--Note: <User Get="Variable-Name"> is used to retrieve the first variable-->
  <UserSettings>
    <!--Emotion: Default user emotion when a new user is created-->
    <Variable Name="Emotion" Value="pleased" />
    <!--Undefined: Value that renders a variable 'Undefined'-->
    <Variable Name="Undefined" Value="" />
    <!--Default: Value that is returned if a Get function is called on an undefined variable-->
    <Variable Name="Default" Value="Unknown" />
    <Variable Name="Concept" Value="" />
  </UserSettings>
</Siml>
and Hello Bot:

SIML Code

<Siml>
  <Concept Type="public" Name="Hello Bot">
    <Model>
      <Pattern>HELLO BOT</Pattern>
      <Response>Hello User!</Response>
    </Model>
    
    <Model>
      <Pattern>SET INTRO ON</Pattern>
      <Response>
        <User Set="Concept">Intro</User>
      </Response>
    </Model>
    
    <Model>
      <Pattern>SET INTRO OFF</Pattern>
      <Response>
        <User Set="Concept"></User>
      </Response>
    </Model>
    
  </Concept>
  <Concept Type="Private" Name="Intro">
    <Model>
      <Pattern>TEST MESSAGE</Pattern>
      <Response>Bingo!</Response>
    </Model>
    
  </Concept>
</Siml>
If you run this program you will be able to select an input message and should see your settings displayed on the UserSettings text box. Obviously click the button to chat. With the checkbox off, the following sequence works as expected...

test message -> Sorry, ...
set intro on -> Intro (and you can see the value change in the settings box)
test message -> Bingo!
test message -> Bingo!

Now check the box.

test message -> Sorry, ... (despite still seeing Concept = Intro in the settings)

BTW - I was concerned that the settings were not actually loading, but I simply changed the emotion to "sad" and the next cycle that is what I got back from chat. So I know that is working fine.

I hope this "tee's it up" for you.

Thanks,
Rich.

User avatar
Leslie
Lead Software Architect
Posts: 353
Joined: Fri Sep 14, 2012 12:20 pm
Contact: Website

Re: User persistent problem

Tue Aug 30, 2016 4:57 am

Sorry about the PM upload issue. I believe the forum doesn't support zip format.

Thanks for the sample codes, surely helps a lot.

The issue will be addressed within the next 24 hours and we will get back to you in this same forum post.

User avatar
Leslie
Lead Software Architect
Posts: 353
Joined: Fri Sep 14, 2012 12:20 pm
Contact: Website

Re: User persistent problem

Tue Aug 30, 2016 10:16 pm

We've worked full day trying to figure out why the behavior reflects in your Program. After unit testing we found that the Concept part is indeed being set but since the User.HasHistory returns false for new users the Concept value is ignored by the Interpreter.

Specially for your case I've released an alpha version in NuGet which you can reference in your application using the following NuGet command:

Code: Select all

Install-Package Syn.Bot -Pre
As Syn.Bot version 1.2.5 is schedule for September 19, Syn Bot Studio will still run under Interpreter version 1.2.4 till then.

Let us know if this version solves your problem.

rich kopelow
V.I.P
Posts: 47
Joined: Thu Aug 25, 2016 7:45 am

Re: User persistent problem

Wed Aug 31, 2016 3:46 am

Thanks for digging into this. I installed the alpha package in my test program and found that it didn't compile since the BotUser constructor was removed. But after changing over to SimlBot.CreateUser() it worked fine! Then I modified my "production" project and changed the constructor first to make sure that change was not part of the fix. It wasn't. Then I updated the package to the alpha and everything works great now.

Thanks again for your time and this product.

User avatar
Leslie
Lead Software Architect
Posts: 353
Joined: Fri Sep 14, 2012 12:20 pm
Contact: Website

Re: User persistent problem

Wed Aug 31, 2016 4:23 am

The pleasure is all mine. Thanks for reporting back.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest