public void TestCase() { ElizaMain eliza = new ElizaMain(); foreach (var s in new string[] {"Hello", "Well, and you?", "I'm implementing some weird project.", "Yes, can you give me technical advice?", "Thank you.", "Bye."}) { Console.WriteLine("> {0}", s); Console.WriteLine("< {0}", eliza.ProcessInput(s)); } }
public void TestCase() { var eliza = new ElizaMain(); foreach (var s in new string[] { "Hello", "Well, and you?", "I'm implementing some weird project.", "Yes, can you give me technical advice?", "Thank you.", "Bye." }) { Console.WriteLine("> {0}", s); Console.WriteLine("< {0}", eliza.ProcessInput(s)); } }
public Task <string> Respond(MuteCommandContext context, bool containsMention, CancellationToken ct) { return(Task.Run(() => { lock (_eliza) { var response = _eliza.ProcessInput(context); IsComplete = _eliza.Finished; return response; } }, ct)); }
static void Main(string[] args) { ElizaMain eliza = new ElizaMain(); while (true) { var input = System.Console.ReadLine(); var output = eliza.ProcessInput(input); System.Console.WriteLine(output); } }
protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken) { var conversationStateAccessors = ConversationState.CreateProperty <ConversationData>(nameof(ConversationData)); var conversationData = await conversationStateAccessors.GetAsync(turnContext, () => new ConversationData()); // If we have not yet started recording, ask the user the wait. if ((turnContext.Activity.ChannelId == "telephony") && (conversationData.RecordingState == RecordingState.Uninitialized)) { var waitText = $"Please wait"; await turnContext.SendActivityAsync( VoiceFactory.TextAndVoice(waitText, InputHints.IgnoringInput), cancellationToken); return; } // Recording is either started, resumed or paused. // We are ready to reply to the bot var userText = turnContext.Activity.Text; if (string.IsNullOrWhiteSpace(userText)) { return; } // Echo what the caller says //var replyText = $"You said {userText}"; var replyText = eliza.ProcessInput(userText); await turnContext.SendActivityAsync( VoiceFactory.TextAndVoice(replyText, InputHints.IgnoringInput), cancellationToken); // Simple command to test pausing the recording if (userText == "pause") { // Pause only if the recording is active. Ignore the command otherwise. if (conversationData.RecordingState == RecordingState.Recording) { await RecordingHelpers.TryPauseRecording(turnContext, cancellationToken); } } // Simple command to test resuming the recording if (userText == "resume") { // Resume only if the recording is paused. Ignore the command otherwise. if (conversationData.RecordingState == RecordingState.Paused) { await RecordingHelpers.TryResumeRecording(turnContext, cancellationToken); } } }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <Message> Post([FromBody] Message message) { if (message.Type == "Message") { var repl = Eliza.ProcessInput(message.Text); return(message.CreateReplyMessage(repl)); } else { return(HandleSystemMessage(message)); } }