Skip to content

Commit

Permalink
CopilotChat: Only allow submit when chat message is not empty (micros…
Browse files Browse the repository at this point in the history
…oft#517)

### Motivation and Context
Submitting empty chat messages confuses the AI.

### Description
- CopilotChat WebApp won't submit if there is not text to submit
- CopilotChat WebApi will successfully return nothing when nothing is
submitted
  • Loading branch information
adrianwyatt committed Apr 19, 2023
1 parent e5b3934 commit c42dbeb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {

const handleSubmit = (data: string) => {
try {
if (data.trim() === '') {
return; // only submit if data is not empty
}
onSubmit(data);
setPreviousValue(data);
setValue('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public SemanticKernelController(IServiceProvider serviceProvider, IConfiguration
{
this._logger.LogDebug("Received call to invoke {SkillName}/{FunctionName}", skillName, functionName);

if (string.IsNullOrWhiteSpace(ask.Input))
{
return this.BadRequest("Input is required.");
}

string semanticSkillsDirectory = this._configuration.GetSection(CopilotChatApiConstants.SemanticSkillsDirectoryConfigKey).Get<string>();
if (!string.IsNullOrWhiteSpace(semanticSkillsDirectory))
{
Expand Down

0 comments on commit c42dbeb

Please sign in to comment.