Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating ML node autocomplete. #13496

Merged
merged 22 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DynamoCore/Graph/Nodes/NodeModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
Expand Down
209 changes: 209 additions & 0 deletions src/DynamoCore/Search/SearchElements/MLNodeSearchElement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using Dynamo.Configuration;
using Dynamo.Graph.Nodes;

namespace Dynamo.Search.SearchElements
{
[DataContract]
internal class MLNodeAutoCompletionRequest
reddyashish marked this conversation as resolved.
Show resolved Hide resolved
{
internal MLNodeAutoCompletionRequest()
{
Node = new NodeRequest();
Port = new PortRequest();
Host = new HostRequest();
Context = new ContextRequest();
Packages = new List<PackageItem>();
}

[DataMember(Name = "node")]
internal NodeRequest Node { get; set; }

[DataMember(Name = "port")]
internal PortRequest Port { get; set; }

[DataMember(Name = "host")]
internal HostRequest Host { get; set; }

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

[DataMember(Name = "numberOfResults")]
internal int NumberOfResults { get; set; }

[DataMember(Name = "packages")]
internal IEnumerable<PackageItem> Packages { get; set; }

[DataMember(Name = "context")]
internal ContextRequest Context { get; set; }
}

[DataContract]
internal class NodeRequest
{
internal NodeRequest()
{
Type = new NodeTypeRequest();
}

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

[DataMember(Name = "type")]
internal NodeTypeRequest Type { get; set; }

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

[DataContract]
internal class NodeTypeRequest
{
[DataMember(Name = "id")]
internal string Id { get; set; }
}

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

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

[DataMember(Name = "listAtLevel")]
internal int ListAtLevel { get; set; }

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

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

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

[DataContract]
internal class ContextRequest
{
internal ContextRequest()
{
Connections = new List<ConnectionsRequest>();
Nodes = new List<NodeRequest>();
}

[DataMember(Name = "nodes")]
internal IEnumerable<NodeRequest> Nodes { get; set; }

[DataMember(Name = "connections")]
internal IEnumerable<ConnectionsRequest> Connections { get; set; }
}

[DataContract]
internal class ConnectionsRequest
{
[DataMember(Name = "from")]
internal ConnectorNodeItem StartNode { get; set; }

[DataMember(Name = "to")]
internal ConnectorNodeItem EndNode { get; set; }
}

[DataContract]
internal class ConnectorNodeItem
{
internal ConnectorNodeItem(string nodeId, string portName)
{
NodeId = nodeId;
PortName = portName;
}

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

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

[DataContract]
internal class PackageItem
{
internal PackageItem(string name, string version)
{
Name = name;
Version = version;
}

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

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

[DataContract]
internal class MLNodeAutoCompletionResponse
{
internal MLNodeAutoCompletionResponse()
{
Results = new List<ResultItem>();
}

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

[DataMember(Name = "results")]
internal IEnumerable<ResultItem> Results { get; set; }
reddyashish marked this conversation as resolved.
Show resolved Hide resolved
}

[DataContract]
internal class ResultItem
{
[DataMember(Name = "node")]
internal NodeResponse Node { get; set; }

[DataMember(Name = "port")]
internal PortResponse Port { get; set; }

[DataMember(Name = "score")]
internal double Score { get; set; }
}

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

[DataContract]
internal class NodeResponse
{
internal NodeResponse()
{
Type = new NodeTypeResponse();
}

[DataMember(Name = "type")]
internal NodeTypeResponse Type { get; set; }
}

[DataContract]
internal class NodeTypeResponse
{
[DataMember(Name = "nodeType")]
internal string NodeType { get; set; }

[DataMember(Name = "id")]
internal string Id { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/DynamoCore/Search/SearchElements/NodeSearchElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public class AutoCompletionNodeMachineLearningInfo
/// <summary>
/// Rating of confidence
/// </summary>
public int ConfidenceScore { get; set; }
public double ConfidenceScore { get; set; }
/// <summary>
/// Indicates if the Node is part of ML result per use
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions src/DynamoCoreWpf/App.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="MLNodeAutocomplete" value="https://dev.autocomplete.dynamobim.org/autocomplete"/>
reddyashish marked this conversation as resolved.
Show resolved Hide resolved
<add key="token" value="eyJhbGciOiJSUzI1NiIsImtpZCI6IlU3c0dGRldUTzlBekNhSzBqZURRM2dQZXBURVdWN2VhIn0.eyJzY29wZSI6WyJkYXRhOnJlYWQiXSwiY2xpZW50X2lkIjoiN3RpUXl2cWtHdmN5M3BYY0NBTW1LbTlldjFHR0FuZGoiLCJhdWQiOiJodHRwczovL2F1dG9kZXNrLmNvbS9hdWQvYWp3dGV4cDYwIiwianRpIjoiQTBrSjZGem8zNTVQTlFtY0hPNFdUYXhleG9ZMDZVM3YzeWZsU25UMkI0OFU3enpSZ3RJczZ1aTQ5UEZZWXRaRiIsImV4cCI6MTY2ODAwNDA3Nn0.Q_yhMnWR9IyQaKgbDyfEXQgRjDlc57MMVLAhWi-5_n905XxGdzqR5KwZbSVirfrJQ70R-9XaaXbOLIdTZmMGcQlU4D8U3anMsg8O7tXns1HmZ3lRTDQSXW_KpSBw9AWA2CUFOogKmoCa_xz0PMw-hQWoX6Uw_ER_wB9UrAR5P_A_fwhkLhAgCtbR2JrQmiuJ-Pl3YxXTCKtW7y7t_trImgo98k2BnsyI20jiVn6bEuVZJcZEWJGqtgawDECzI67lg4ivUE2m22B2lxpljmLq5sCphOu4LueNbmuZunbieDrFxTvWOQqPNi5-733Y-PIfOWoT5GJ0TG_Uy9mMVKBwcA"/>
reddyashish marked this conversation as resolved.
Show resolved Hide resolved
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
</TextBlock>
</StackPanel>
</StackPanel>
<StackPanel x:Name="LowConfidenceSpace" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,10,0,10"
<StackPanel x:Name="LowConfidenceSpace" MouseLeftButtonUp="ShowLowConfidenceResults" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,10,0,10"
reddyashish marked this conversation as resolved.
Show resolved Hide resolved
Visibility="{Binding Path=DisplayLowConfidence, Converter={StaticResource BooleanToVisibilityConverter}}">
<Image HorizontalAlignment="Center"
Height="14"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ private void DisplaySuggestions(object sender, RoutedEventArgs e)
cm.IsOpen = true;
}

private void ShowLowConfidenceResults(object sender, RoutedEventArgs e)
{
ViewModel.ShowLowConfidenceResults();
}

private void OnSuggestion_Click(object sender, RoutedEventArgs e)
{
MenuItem selectedSuggestion = sender as MenuItem;
Expand Down
30 changes: 15 additions & 15 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using Dynamo.Graph.Workspaces;
using Dynamo.Logging;
using Dynamo.PackageManager;
using Dynamo.Search.SearchElements;
using SearchElements = Dynamo.Search.SearchElements;
reddyashish marked this conversation as resolved.
Show resolved Hide resolved
using Dynamo.UI;
using Dynamo.UI.Controls;
using Dynamo.Updates;
Expand Down Expand Up @@ -2722,30 +2722,30 @@ public class ElementTypeToShortConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var type = (ElementTypes)value;
var type = (SearchElements.ElementTypes)value;

switch (type)
{
case ElementTypes.Packaged:
case SearchElements.ElementTypes.Packaged:
return Resources.PackageTypeShortString;

case ElementTypes.Packaged | ElementTypes.ZeroTouch:
case SearchElements.ElementTypes.Packaged | SearchElements.ElementTypes.ZeroTouch:
return Resources.PackageTypeShortString;

case ElementTypes.Packaged | ElementTypes.CustomNode:
case SearchElements.ElementTypes.Packaged | SearchElements.ElementTypes.CustomNode:
return Resources.PackageTypeShortString;

case ElementTypes.Packaged | ElementTypes.ZeroTouch | ElementTypes.CustomNode:
case SearchElements.ElementTypes.Packaged | SearchElements.ElementTypes.ZeroTouch | SearchElements.ElementTypes.CustomNode:
return Resources.PackageTypeShortString;

case ElementTypes.ZeroTouch:
case SearchElements.ElementTypes.ZeroTouch:
return Resources.ZeroTouchTypeShortString;

case ElementTypes.CustomNode:
case SearchElements.ElementTypes.CustomNode:
return Resources.CustomNodeTypeShortString;

case ElementTypes.BuiltIn:
case ElementTypes.None:
case SearchElements.ElementTypes.BuiltIn:
case SearchElements.ElementTypes.None:
default:
return string.Empty;
}
Expand Down Expand Up @@ -3155,22 +3155,22 @@ public class ElementGroupToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (!(value is SearchElementGroup))
if (!(value is SearchElements.SearchElementGroup))
{
return null;
}

var type = (SearchElementGroup)value;
var type = (SearchElements.SearchElementGroup)value;

var resourceDictionary = SharedDictionaryManager.DynamoColorsAndBrushesDictionary;

switch (type)
{
case SearchElementGroup.Create:
case SearchElements.SearchElementGroup.Create:
return resourceDictionary["CreateMembersColor"] as SolidColorBrush;
case SearchElementGroup.Action:
case SearchElements.SearchElementGroup.Action:
return resourceDictionary["ActionMembersColor"] as SolidColorBrush;
case SearchElementGroup.Query:
case SearchElements.SearchElementGroup.Query:
return resourceDictionary["QueryMembersColor"] as SolidColorBrush;
default:
return null;
Expand Down
Loading