Skip to content

Commit

Permalink
Add what's new command
Browse files Browse the repository at this point in the history
  • Loading branch information
QilongTang committed Mar 8, 2024
1 parent 65d37ea commit 8dd6381
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/DynamoAssistantViewExtension/DynamoAssistantWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@
Height="50"
Background="#2d2d2d"
Foreground="White"
Grid.Row="6"/>
Grid.Row="6"
Click="WhatsNewButton_Click"/>
</Grid>

<Grid Name="TextInput"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,10 @@ private void OptimizeGraphButton_Click(object sender, RoutedEventArgs e)
{
ViewModel.OptimizeGraph();
}

private void WhatsNewButton_Click(object sender, RoutedEventArgs e)
{
ViewModel.WhatsNew();
}
}
}
19 changes: 17 additions & 2 deletions src/DynamoAssistantViewExtension/DynamoAssistantWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public DynamoAssistantWindowViewModel(ReadyParams p)
chatGPTClient = new OpenAIAPI(new APIAuthentication(apikey));
// ChatGPT lets you start a new chat.
conversation = chatGPTClient.Chat.CreateConversation();
conversation.Model = Model.GPT4_Turbo;
conversation.Model = Model.GPT4;
// Adjust this value for more or less "creativity" in the response
conversation.RequestParameters.Temperature = 0.1;
// Display a welcome message
Expand Down Expand Up @@ -102,11 +102,17 @@ internal async void DescribeGraph()
{
// Set Dynamo file location
string filePath = readyParams.CurrentWorkspaceModel.FileName;
if (filePath == null)
{
// Alternatively, export Json from current workspace model to continue
Messages.Add("Copilot:\nPlease save the workspace first.\n");
return;
}

//Read the file
string jsonData = File.ReadAllText(filePath);

var msg = "This is my Dynamo project JSON structure." + jsonData;
var msg = "This is my Dynamo project JSON structure.\n" + jsonData;

// Send the user's input to the ChatGPT API and receive a response
conversation?.AppendUserInput(DescribePreInstruction + msg);
Expand All @@ -133,6 +139,15 @@ internal async void OptimizeGraph()
Messages.Add("Copilot:\n" + response + "\n");
}

internal async void WhatsNew()
{
// Send the user's input to the ChatGPT API and receive a response
conversation?.AppendUserInput("What's new in Dynamo 3.0?");
string response = await conversation.GetResponseFromChatbotAsync();
// Display the chatbot's response
Messages.Add("Copilot:\n" + response + "\n");
}

/// <summary>
/// Create a python node in Dynamo, use latest Nuget package for this
/// </summary>
Expand Down

0 comments on commit 8dd6381

Please sign in to comment.