XmlDocument doc = new XmlDocument(); doc.LoadXml(message); XmlNode root = doc.SelectSingleNode("/message"); string type = root["type"].InnerText; string text = root["text"].InnerText; string name = root["name"].InnerText;
.JsonIgnoreProperties({ ignoreUnknown: true }) public class Message { public string Type { get; set; } public string Text { get; set; } public string Name { get; set; } public Message(string type, string text, string name) { Type = type; Text = text; Name = name; } }
Comments
2Talkior-RCEUMRWS
23/11/2024
酐OnInit = async (props) => { const [data, setData] = useState({ type: 'greetings', text: 'Hi! I am Damian. What is your name?', }); const [botText, setBotText] = useState(''); const handleChange = (event) => { setBotText(event.target.value); }; const handleSubmit = async (event) => { event.preventDefault(); if (botText.trim().length === 0) { return; } const newMsg = { type: 'user', text: botText }; setData((prevState) => ({ ...prevState, text: '', type: 'messages' })); setMessages((messages) => [...messages, newMsg]); try { const response = await fetch('***', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ text: botText, name: name, }), }); if (response.ok) { const data = await response.json(); const newMsg = { type: 'assistant', text: data.text, name: name, }; setData((prevState) => ({ ...prevState, text: '', type: 'messages' })); setMessages((messages) => [...messages, newMsg]); }
XmlDocument doc = new XmlDocument(); doc.LoadXml(message); XmlNode root = doc.SelectSingleNode("/message"); string type = root["type"].InnerText; string text = root["text"].InnerText; string name = root["name"].InnerText;
.JsonIgnoreProperties({ ignoreUnknown: true }) public class Message { public string Type { get; set; } public string Text { get; set; } public string Name { get; set; } public Message(string type, string text, string name) { Type = type; Text = text; Name = name; } }
From the memory
3 Memories