Skip to content

Commit

Permalink
ML Node Autocomplete improvements. (#13549)
Browse files Browse the repository at this point in the history
* Show not authenticated page and refactor code

* Add enum values for Hostname.

* Update Converters.cs

* Update resource

* Update resources.

* Handle different node types for nodemodel nodes

* Add port index to ML node autocomplete response
  • Loading branch information
reddyashish authored Nov 23, 2022
1 parent 5593581 commit bf29f56
Show file tree
Hide file tree
Showing 13 changed files with 191 additions and 123 deletions.
42 changes: 21 additions & 21 deletions src/DynamoCore/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions src/DynamoCore/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -876,19 +876,19 @@ This package likely contains an assembly that is blocked. You will need to load
<value>Low confidence</value>
</data>
<data name="AutocompleteNoRecommendationsMessage" xml:space="preserve">
<value>There are no nodes that we can recommend, you may try to</value>
</data>
<data name="AutocompleteSwitchToObjectTypeMessage" xml:space="preserve">
<value>switch to Object Type Autocomplete</value>
<value>There are no recommendations yet. You can try switching to object type autocomplete.</value>
</data>
<data name="AutocompleteLowConfidenceMessage" xml:space="preserve">
<value>We are not very confident that the nodes below will work, you may try them or</value>
</data>
<data name="AutocompleteLowConfidenceMessageAditional" xml:space="preserve">
<value>to view more options</value>
<value>All recommendations are below the specified confidence level. You can try them or adjust the confidence settings in Preferences.</value>
</data>
<data name="AutocompleteLowConfidenceTooltip" xml:space="preserve">
<value>Low Confidence Tooltip</value>
<value>Show Recommendations that are below the confidence level.</value>
</data>
<data name="LoginNeededTitle" xml:space="preserve">
<value>Not authenticated</value>
</data>
<data name="LoginNeededMessage" xml:space="preserve">
<value>You need to login to your account to get recommendations. Please log in or switch to object type autocomplete.</value>
</data>
<data name="FailedInsertFileNodeExistNotification" xml:space="preserve">
<value>Failed to insert the file as some of the nodes already exist in the current worspace.</value>
Expand Down
18 changes: 9 additions & 9 deletions src/DynamoCore/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -879,19 +879,19 @@ This package likely contains an assembly that is blocked. You will need to load
<value>Low confidence</value>
</data>
<data name="AutocompleteNoRecommendationsMessage" xml:space="preserve">
<value>There are no nodes that we can recommend, you may try to</value>
</data>
<data name="AutocompleteSwitchToObjectTypeMessage" xml:space="preserve">
<value>switch to Object Type Autocomplete</value>
<value>There are no recommendations yet. You can try switching to object type autocomplete.</value>
</data>
<data name="AutocompleteLowConfidenceMessage" xml:space="preserve">
<value>We are not very confident that the nodes below will work, you may try them or</value>
</data>
<data name="AutocompleteLowConfidenceMessageAditional" xml:space="preserve">
<value>to view more options</value>
<value>All recommendations are below the specified confidence level. You can try them or adjust the confidence settings in Preferences.</value>
</data>
<data name="AutocompleteLowConfidenceTooltip" xml:space="preserve">
<value>Low Confidence Tooltip</value>
<value>Show Recommendations that are below the confidence level.</value>
</data>
<data name="LoginNeededTitle" xml:space="preserve">
<value>Not authenticated</value>
</data>
<data name="LoginNeededMessage" xml:space="preserve">
<value>You need to login to your account to get recommendations. Please log in or switch to object type autocomplete.</value>
</data>
<data name="FailedInsertFileNodeExistNotification" xml:space="preserve">
<value>Failed to insert the file as some of the nodes already exist in the current worspace.</value>
Expand Down
33 changes: 32 additions & 1 deletion src/DynamoCore/Search/SearchElements/MLNodeSearchElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ internal MLNodeAutoCompletionRequest(string dynamoVersion, int numberOfResults)
NumberOfResults = numberOfResults;
Node = new NodeRequest();
Port = new PortRequest();
Host = new HostRequest();
Context = new ContextRequest();
Packages = new List<PackageItem>();
}
Expand Down Expand Up @@ -100,6 +99,12 @@ internal PortRequest(string name, string direction)
[DataContract]
internal class HostRequest
{
internal HostRequest(string name, string version)
{
Name = name;
Version = version;
}

[DataMember(Name = "name")]
internal string Name { get; set; }

Expand Down Expand Up @@ -201,6 +206,9 @@ internal class PortResponse
{
[DataMember(Name = "name")]
internal string Name { get; set; }

[DataMember(Name = "index")]
internal int Index { get; set; }
}

[DataContract]
Expand Down Expand Up @@ -247,4 +255,27 @@ public override string ToString()
return string.Format("{0}, {1}", FullName, AssemblyName);
}
}

internal enum HostNames
{
Revit,
AdvanceSteel,
Civil3d,
FormIt,
Alias,
RSA,
None
};

// Node types for different nodemodel nodes.
internal enum NodeModelNodeTypes
{
FunctionNode,
ExtensionNode,
NumberInputNode,
StringInputNode,
BooleanInputNode,
DateTimeInputNode,
FormulaNode
};
}
16 changes: 5 additions & 11 deletions src/DynamoCoreWpf/Controls/NodeAutoCompleteSearchControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@
</ListBox>
</Border>

<StackPanel Visibility="{Binding Path=DisplayNoRecommendationsLowConfidence, Converter={StaticResource BooleanToVisibilityConverter}}">
<StackPanel Visibility="{Binding Path=DisplayAutocompleteMLStaticPage, Converter={StaticResource BooleanToVisibilityConverter}}">
<Image Name="NoRecommendations"
Width="205"
Height="120"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Source="/DynamoCoreWpf;component/UI/Images/no-recommendations.png">
Source="{Binding Path=AutocompleteMLTitle, Converter={StaticResource NodeAutocompleteImageConverter}}">
</Image>
<TextBlock Text="{Binding Path=NoRecommendationsOrLowConfidenceTitle}"
<TextBlock Text="{Binding Path=AutocompleteMLTitle}"
Background="Transparent"
Padding="5"
Foreground="{StaticResource AutocompletionWindowFontColor}"
Expand All @@ -166,13 +166,7 @@
FontFamily="{StaticResource ArtifaktElementRegular}"
Foreground="#F5F5F5"
FontSize="11">
<Run Text="{Binding Path=NoRecommendationsOrLowConfidenceMessage}"
Foreground="{StaticResource AutocompletionWindowFontColor}">
</Run>
<Run Text="{x:Static resx:Resources.AutocompleteSwitchToObjectTypeMessage}"
Foreground="{StaticResource Blue400Brush}">
</Run>
<Run Text="{Binding Path=LowConfidenceMessageAdditional}"
<Run Text="{Binding Path=AutocompleteMLMessage}"
Foreground="{StaticResource AutocompletionWindowFontColor}">
</Run>
</TextBlock>
Expand Down Expand Up @@ -202,7 +196,7 @@
Height="14"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Style="{StaticResource InformationIcon}"
Style="{StaticResource ToggleInfoStyle}"
ToolTipService.ShowDuration="10000">
<Image.ToolTip>
<ToolTip Content="{x:Static resx:Resources.AutocompleteLowConfidenceTooltip}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ private void OnSuggestion_Click(object sender, RoutedEventArgs e)
{
ViewModel.dynamoViewModel.PreferenceSettings.DefaultNodeAutocompleteSuggestion = Models.NodeAutocompleteSuggestion.ObjectType;
}
ViewModel.ResetAutoCompleteSearchViewState();
ViewModel.PopulateAutoCompleteCandidates();
}
}
}
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,7 @@
<Resource Include="UI\Images\bubble-arrow.png" />
<Resource Include="UI\Images\icon-dictionary-small.png" />
<Resource Include="UI\Images\no-recommendations.png" />
<Resource Include="UI\Images\not-authenticated.png" />
</ItemGroup>
<Target Name="AfterBuildOps" AfterTargets="Build">
<MakeDir Directories="$(OutputPath)\viewExtensions\" />
Expand Down
25 changes: 25 additions & 0 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,31 @@ public object ConvertBack(object value, Type targetType, object parameter,
}
}

public class NodeAutocompleteImageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
CultureInfo culture)
{
if (string.IsNullOrEmpty(value as string))
{
return string.Empty;
}

if (value is string && value.ToString().Equals(Properties.Resources.LoginNeededTitle))
{
return "/DynamoCoreWpf;component/UI/Images/not-authenticated.png";
}

return "/DynamoCoreWpf;component/UI/Images/no-recommendations.png";
}

public object ConvertBack(object value, Type targetType, object parameter,
CultureInfo culture)
{
return null;
}
}

public class BoolToFullscreenWatchVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
Expand Down
Binary file added src/DynamoCoreWpf/UI/Images/not-authenticated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoConverters.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<controls:PortTypeToClipConverter x:Key="PortTypeToClipConverter" />
<controls:ConsoleHeightConverter x:Key="ConsoleHeightConverter" />
<controls:NodeAutocompleteWidthConverter x:Key="NodeAutocompleteWidthConverter" />
<controls:NodeAutocompleteImageConverter x:Key="NodeAutocompleteImageConverter" />
<controls:BoolToFullscreenWatchVisibilityConverter x:Key="BoolToFullscreenWatchVisibilityConverter" />
<controls:BoolToCanvasCursorConverter x:Key="BoolToCanvasCursorConverter" />
<controls:LacingToVisibilityConverter x:Key="LacingToVisibilityConverter" />
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public bool NodeAutocompleteMachineLearningIsChecked
preferenceSettings.DefaultNodeAutocompleteSuggestion = NodeAutocompleteSuggestion.ObjectType;
nodeAutocompleteSuggestion = NodeAutocompleteSuggestion.ObjectType;
}
dynamoViewModel.HomeSpaceViewModel.NodeAutoCompleteSearchViewModel.ResetAutoCompleteSearchViewState();
dynamoViewModel.HomeSpaceViewModel.NodeAutoCompleteSearchViewModel.PopulateAutoCompleteCandidates();
RaisePropertyChanged(nameof(nodeAutocompleteSuggestion));
}
}
Expand Down
Loading

0 comments on commit bf29f56

Please sign in to comment.