diff --git a/cache.json b/cache.json index dd404aa012..f94e18f7d4 100644 --- a/cache.json +++ b/cache.json @@ -1 +1 @@ -{"cache":[["chatgpt:877fa732-116c-4df3-a446-ced5a7639e0e",{"value":"{\"value\":{\"messages\":[{\"id\":\"d9fa21b0-f415-46e8-ac55-017230309868\",\"parentMessageId\":\"91e5f322-fea2-4eba-8e18-ae3c9e5f0c81\",\"role\":\"User\",\"message\":\"Explain quantum computing in simple terms\"},{\"id\":\"df9ad7f4-053d-4f18-8e64-95575276ec07\",\"parentMessageId\":\"d9fa21b0-f415-46e8-ac55-017230309868\",\"role\":\"ChatGPT\",\"message\":\"Quantum computing is a type of computing that uses quantum mechanics, a branch of physics, to perform operations. Unlike classical computers that use bits (0s or 1s) to represent information, quantum computers use quantum bits, or qubits, which can be both 0 and 1 at the same time. This property, called superposition, allows quantum computers to perform many calculations simultaneously, making them faster and more powerful than classical computers for certain types of problems.\\n\\nIn simpler terms, quantum computing is like a new way of computing that can solve complex problems much faster than traditional computers by using the strange rules of quantum physics.\"}],\"createdAt\":1676242182091},\"expires\":null}"}],["chatgpt:ca09a41a-496b-4529-bbe0-56632d7e1142",{"value":"{\"value\":{\"messages\":[{\"id\":\"d5a5295d-f9b1-4b60-8d44-3f402eb80f0f\",\"parentMessageId\":\"68226ad3-f2d8-4a3e-b5f2-42bc355e3af5\",\"role\":\"User\",\"message\":\"Explain quantum computing in simple terms\"},{\"id\":\"a1fb49a6-5757-42fb-bb69-589ab9595fa0\",\"parentMessageId\":\"d5a5295d-f9b1-4b60-8d44-3f402eb80f0f\",\"role\":\"ChatGPT\",\"message\":\"Quantum computing is a type of computing that uses quantum-mechanical phenomena, such as superposition and entanglement, to perform operations on data. Unlike traditional computers, which use bits to store and process information, quantum computers use quantum bits, or qubits, which can exist in multiple states simultaneously. This allows quantum computers to perform certain types of computations much faster than traditional computers.\\n\\nIn simple terms, quantum computing is a new way of computing that harnesses the properties of quantum mechanics to solve complex problems faster than classical computers.\"}],\"createdAt\":1676242739431},\"expires\":null}"}],["chatgpt:afc546db-12ed-4c5b-99b1-f89452a4251f",{"value":"{\"value\":{\"messages\":[{\"id\":\"a5d6259b-662f-4de9-a525-80ca28bd2038\",\"parentMessageId\":\"175b4456-bd94-4e89-8dfc-d6fd9bc89ecf\",\"role\":\"User\",\"message\":\"Explain quantum computing in simple terms\"},{\"id\":\"f667fb43-ea90-4922-87bb-625388f55d59\",\"parentMessageId\":\"a5d6259b-662f-4de9-a525-80ca28bd2038\",\"role\":\"ChatGPT\",\"message\":\"Quantum computing is a field of computing that uses the principles of quantum mechanics to perform operations. Unlike classical computers, which use binary digits (bits) to store and process information, quantum computers use quantum bits, or qubits, which can exist in multiple states at once. This allows quantum computers to perform certain tasks much faster than classical computers. For example, quantum computers can quickly solve problems that would take classical computers years or even centuries to solve. However, quantum computing is still a relatively new field and there is much that we don't yet understand about it.\"}],\"createdAt\":1676243060875},\"expires\":null}"}],["chatgpt:2c80b11c-7bd7-4ac4-83db-c828e733b900",{"value":"{\"value\":{\"messages\":[{\"id\":\"edb31b64-26d3-4b05-9487-3e83740620b6\",\"parentMessageId\":\"ae12cd02-e017-45f4-bbbe-70bc51f1a9fc\",\"role\":\"User\",\"message\":\"Got any creative ideas for a 10 year old's birthday?\"},{\"id\":\"23788dac-7ca2-4846-9d15-707bfb062160\",\"parentMessageId\":\"edb31b64-26d3-4b05-9487-3e83740620b6\",\"role\":\"ChatGPT\",\"message\":\"Of course! Here are a few creative birthday party ideas for a 10-year-old:\\n\\n1. Science experiment party: Set up a series of fun and interactive science experiments for the kids to enjoy.\\n\\n2. Movie marathon: Pick out a series of their favorite movies and have a movie marathon birthday party.\\n\\n3. Craft party: Have a craft party where the kids can make their own unique creations.\\n\\n4. Escape room: Create a mini escape room for the kids to solve together.\\n\\n5. Gaming party: Set up a gaming party with their favorite video games, board games, or outdoor games.\\n\\n6. Cooking party: Teach the kids how to make their favorite dishes or try out new recipes together.\\n\\n7. Adventure party: Have an adventure party with outdoor activities like hiking, rock climbing, or a scavenger hunt.\\n\\n8. Karaoke party: Have a karaoke party and let the kids take turns singing their favorite songs.\\n\\nThese are just a few ideas to get you started. I'm sure you'll come up with something amazing that the 10-year-old will love!\"}],\"createdAt\":1676244503763},\"expires\":null}"}],["chatgpt:eb56bdbe-e8b6-4541-8e6d-a01b7113e513",{"value":"{\"value\":{\"messages\":[{\"id\":\"eb994224-e29f-44ce-adb8-77f476d377e8\",\"parentMessageId\":\"33b427e5-78e8-4159-b3cc-91abd4319bb1\",\"role\":\"User\",\"message\":\"How do I make an HTTP request in Javascript?\"},{\"id\":\"8129a632-ba96-4db2-b8a3-e881564e0302\",\"parentMessageId\":\"eb994224-e29f-44ce-adb8-77f476d377e8\",\"role\":\"ChatGPT\",\"message\":\"There are several ways to make HTTP requests in JavaScript, but here are the most common ones:\\n\\n1. XMLHttpRequest (XHR) API: This is an API available in modern browsers that allows you to make HTTP requests from JavaScript. Here's an example:\\n\\n```\\nvar xhr = new XMLHttpRequest();\\nxhr.open(\\\"GET\\\", \\\"https://www.example.com\\\", true);\\nxhr.onreadystatechange = function() {\\n if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {\\n console.log(xhr.responseText);\\n }\\n};\\nxhr.send();\\n```\\n\\n2. Fetch API: This is a more modern API that was introduced in modern browsers and is similar to the XHR API, but with a cleaner syntax. Here's an example:\\n\\n```\\nfetch(\\\"https://www.example.com\\\")\\n .then(response => response.text())\\n .then(text => console.log(text))\\n .catch(error => console.error(error));\\n```\\n\\n3. Third-party libraries: There are also several popular third-party libraries such as Axios, jQuery, and SuperAgent that provide a higher-level API for making HTTP requests in JavaScript. For example, using Axios:\\n\\n```\\naxios.get(\\\"https://www.example.com\\\")\\n .then(response => console.log(response.data))\\n .catch(error => console.error(error));\\n```\"}],\"createdAt\":1676244675109},\"expires\":null}"}],["chatgpt:19296b4b-8bae-43bb-bdc7-385603556c14",{"value":"{\"value\":{\"messages\":[{\"id\":\"49325160-ba0a-47dc-9e2b-c4a214812692\",\"parentMessageId\":\"04205bea-a5cb-4c0a-984b-77adc0126cea\",\"role\":\"User\",\"message\":\"Got any creative ideas for a 10 year old's birthday?\"},{\"id\":\"d111ea84-596c-4a93-9c96-0e4e139354dc\",\"parentMessageId\":\"49325160-ba0a-47dc-9e2b-c4a214812692\",\"role\":\"ChatGPT\",\"message\":\"Yes, here are a few creative birthday ideas for a 10-year-old:\\n\\n1. A backyard camping adventure, complete with a bonfire, s'mores, and ghost stories.\\n\\n2. A science-themed birthday party, with experiments, hands-on activities, and a visit to a local museum or planetarium.\\n\\n3. A movie night at home, with a homemade popcorn bar, a cozy blanket fort, and a lineup of the birthday boy or girl's favorite films.\\n\\n4. A game day, with a tournament of their favorite games, like video games, board games, or sports games.\\n\\n5. A cooking class, where they can learn how to make their favorite dishes and snacks, or try something new.\\n\\n6. A DIY craft day, with supplies for painting, drawing, or building something unique.\\n\\n7. A treasure hunt, with clues and puzzles leading to a special birthday surprise.\\n\\n8. A virtual escape room, where they can use their problem-solving skills to solve a series of challenges.\\n\\n9. A virtual field trip, to visit a place they've always wanted to see, like a famous landmark, animal habitat, or historical site.\\n\\n10. A birthday sleepover, with friends, games, snacks, and a movie marathon.\\n\\nI hope these ideas give you some inspiration for a fun and memorable birthday celebration!\"}],\"createdAt\":1676244866277},\"expires\":null}"}],["chatgpt:fd5a5183-dd69-4562-8d99-f5de0def3cb7",{"value":"{\"value\":{\"messages\":[{\"id\":\"60aac67d-86dc-4a74-9f66-d702112cac13\",\"parentMessageId\":\"959207ef-d9e4-48c1-98fc-5ad5593eae27\",\"role\":\"User\",\"message\":\"How do I make an HTTP request in Javascript?\"},{\"id\":\"605d1373-a601-4fe9-8a6f-f3cb11b4febd\",\"parentMessageId\":\"60aac67d-86dc-4a74-9f66-d702112cac13\",\"role\":\"ChatGPT\",\"message\":\"There are several ways to make an HTTP request in JavaScript, here are the most common ones:\\n\\n1. `XMLHttpRequest` (XHR) - This is an API available in modern browsers that allows you to send HTTP requests from JavaScript. It's a low-level API and can be a bit verbose, but it's supported in all major browsers.\\n\\nHere's an example of making a GET request using `XMLHttpRequest`:\\n\\n```\\nvar xhr = new XMLHttpRequest();\\nxhr.open(\\\"GET\\\", \\\"https://api.example.com/data\\\", true);\\nxhr.onreadystatechange = function() {\\n if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {\\n console.log(xhr.responseText);\\n }\\n};\\nxhr.send();\\n```\\n\\n2. `fetch` - This is a more modern API that's available in modern browsers and has a simpler, cleaner syntax. It's built on top of `XMLHttpRequest` and provides a higher-level API for making HTTP requests.\\n\\nHere's an example of making a GET request using `fetch`:\\n\\n```\\nfetch(\\\"https://api.example.com/data\\\")\\n .then(response => response.text())\\n .then(data => console.log(data))\\n .catch(error => console.error(error));\\n```\\n\\n3. Third-party libraries like Axios, jQuery, and SuperAgent - If you need to support older browsers or need more advanced features like automatic retries, request canceling, and more, you can use a third-party library. These libraries provide a higher-level API for making HTTP requests and abstract away the differences between different browsers.\\n\\nHere's an example of making a GET request using Axios:\\n\\n```\\naxios.get(\\\"https://api.example.com/data\\\")\\n .then(response => console.log(response.data))\\n .catch(error => console.error(error));\\n```\"}],\"createdAt\":1676257081150},\"expires\":null}"}],["chatgpt:31acc66c-3fef-4213-b142-ccd019cf7353",{"value":"{\"value\":{\"messages\":[{\"id\":\"1728330b-d75a-4e5a-8e7c-712f08ac2a57\",\"parentMessageId\":\"0ecf6a3d-5780-4f82-88c5-3dcf29cee865\",\"role\":\"User\",\"message\":\"how are you today?\"},{\"id\":\"d25fde48-7ecb-4648-8fb0-c067a6cc42ce\",\"parentMessageId\":\"1728330b-d75a-4e5a-8e7c-712f08ac2a57\",\"role\":\"ChatGPT\",\"message\":\"As an AI language model, I don't have emotions, but I am functioning properly. How can I assist you today?\"}],\"createdAt\":1676257433014},\"expires\":null}"}],["chatgpt:7c227791-ab5e-4e96-9a00-39f045f5504a",{"value":"{\"value\":{\"messages\":[{\"id\":\"938bc159-f71b-4ebb-bc16-4d691ffe6464\",\"parentMessageId\":\"037c4951-7796-4244-b3f8-3ba184f7cc02\",\"role\":\"User\",\"message\":\"How do I make an HTTP request in Javascript?\"},{\"id\":\"a0884bc2-c781-46c1-8e81-95471d4e3b1a\",\"parentMessageId\":\"938bc159-f71b-4ebb-bc16-4d691ffe6464\",\"role\":\"ChatGPT\",\"message\":\"There are several ways to make an HTTP request in JavaScript, but the most common method is using the `XMLHttpRequest` object or using the `fetch` API.\\n\\nHere's an example of using `XMLHttpRequest`:\\n\\n```\\nconst xhr = new XMLHttpRequest();\\nxhr.open(\\\"GET\\\", \\\"https://www.example.com\\\", true);\\nxhr.onreadystatechange = function() {\\n if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {\\n console.log(xhr.responseText);\\n }\\n};\\nxhr.send();\\n```\\n\\nAnd here's an example of using the `fetch` API:\\n\\n```\\nfetch(\\\"https://www.example.com\\\")\\n .then(response => response.text())\\n .then(data => console.log(data))\\n .catch(error => console.error(error));\\n```\\n\\nBoth methods allow you to make HTTP requests, but `fetch` is newer and has a more modern syntax. Note that `fetch` returns a Promise, so you need to use `.then` and `.catch` to handle the response.\"}],\"createdAt\":1676257577788},\"expires\":null}"}],["chatgpt:3a1c7a0b-af46-43a5-abe6-8219d5420c8c",{"value":"{\"value\":{\"messages\":[{\"id\":\"28ad537e-d389-4a9e-8928-894188b3ae22\",\"parentMessageId\":\"7ecd6c1c-bcfa-4634-8860-0b1ecebc7dab\",\"role\":\"User\",\"message\":\"Hi, what is your favorite poem?\"},{\"id\":\"4f3e8e13-4979-4a4c-a81b-c7eee9263c82\",\"parentMessageId\":\"28ad537e-d389-4a9e-8928-894188b3ae22\",\"role\":\"ChatGPT\",\"message\":\"As an AI language model, I don't have personal opinions or emotions, but I can tell you about some popular poems that many people enjoy. One of the most well-known poems is William Blake's \\\"The Tyger.\\\" Another classic is William Butler Yeats' \\\"The Second Coming.\\\" Another popular poem is Robert Frost's \\\"The Road Not Taken.\\\" These are just a few examples, and there are many more poems that people love.\"},{\"id\":\"f0103ff7-d348-4fbf-9109-b359cd7f8eb6\",\"parentMessageId\":\"4f3e8e13-4979-4a4c-a81b-c7eee9263c82\",\"role\":\"User\",\"message\":\"What are some others?\"},{\"id\":\"d75847d6-7035-4c45-9e6f-f16f8bf139c7\",\"parentMessageId\":\"f0103ff7-d348-4fbf-9109-b359cd7f8eb6\",\"role\":\"ChatGPT\",\"message\":\"Sure, here are a few more popular poems:\\n- \\\"Ode to a Nightingale\\\" by John Keats\\n- \\\"If\\\" by Rudyard Kipling\\n- \\\"Annabel Lee\\\" by Edgar Allan Poe\\n- \\\"Do Not Go Gentle into That Good Night\\\" by Dylan Thomas\\n- \\\"Sonnet 18\\\" by William Shakespeare\\n- \\\"The Waste Land\\\" by T.S. Eliot\\n- \\\"Howl\\\" by Allen Ginsberg\\n\\nThese are just a few examples of the many beloved poems that people enjoy. Poetry can be appreciated for its beauty, its emotion, its use of language, and its ability to convey complex ideas in a concise and powerful way.\"}],\"createdAt\":1676257679187},\"expires\":null}"}],["chatgpt:f04d9662-3e8b-40e2-8fa0-11de39e2c9d7",{"value":"{\"value\":{\"messages\":[{\"id\":\"b70a6ce3-ff33-4e07-9af3-b03c87526423\",\"parentMessageId\":\"eb1f84ef-8eca-43ca-9242-d5bde50c63c3\",\"role\":\"User\",\"message\":\"should i buy a 62 dollar dress when i have a 50 giftcard? today is free shipping. I am so indecisive. I am a saver but i do not make too many purchases. but i dont want to give myself an excuse.\"},{\"id\":\"06363410-7763-4002-9e18-78e19c971748\",\"parentMessageId\":\"b70a6ce3-ff33-4e07-9af3-b03c87526423\",\"role\":\"ChatGPT\",\"message\":\"If you have a $50 gift card, and a dress costs $62, then you will have to pay $12 out of your own money. If you think the dress is worth the price and you'll get good use out of it, then it may be worth making the purchase. However, it's important to remember that you are a saver and that today's free shipping may not be available in the future. Ultimately, the decision to buy the dress or not is up to you and what you feel is best for your financial situation.\"},{\"id\":\"2e7d13dc-21e4-4bda-bf40-167898a3825f\",\"parentMessageId\":\"06363410-7763-4002-9e18-78e19c971748\",\"role\":\"User\",\"message\":\"thank you\"},{\"id\":\"d079833c-95f9-46d0-a131-b4a3e1f19707\",\"parentMessageId\":\"2e7d13dc-21e4-4bda-bf40-167898a3825f\",\"role\":\"ChatGPT\",\"message\":\"You're welcome! If you have any other questions or concerns, feel free to ask.\"}],\"createdAt\":1676259237223},\"expires\":null}"}],["chatgpt:02de769c-bc15-4551-9b07-034be9f4c8ff",{"value":"{\"value\":{\"messages\":[{\"id\":\"2f96c6eb-fe3d-4e08-8109-dcf1da528b77\",\"parentMessageId\":\"ff892e53-0981-4fe7-8dc1-a98376514dbc\",\"role\":\"User\",\"message\":\"Explain quantum computing in simple terms\"},{\"id\":\"622e44b3-e153-46fc-9db7-a6ef0d1b5556\",\"parentMessageId\":\"2f96c6eb-fe3d-4e08-8109-dcf1da528b77\",\"role\":\"ChatGPT\",\"message\":\"Quantum computing is a type of computing that uses quantum mechanics principles to perform computations and solve problems. In classical computing, information is processed using bits, which can be either 0 or 1. In quantum computing, information is processed using quantum bits, or qubits, which can be both 0 and 1 at the same time. This allows quantum computers to perform certain tasks much faster than classical computers.\\n\\nQuantum computing has the potential to revolutionize fields like cryptography, drug discovery, and financial modeling, but it is still in its early stages of development.\"}],\"createdAt\":1676259624944},\"expires\":null}"}],["chatgpt:92398e60-80d3-4946-9a62-8dcd02c510ce",{"value":"{\"value\":{\"messages\":[{\"id\":\"ca7295ee-b882-4a2a-a6d5-63adfbab0563\",\"parentMessageId\":\"b6c3f6a5-3201-4c19-b200-3b52fba9cdfa\",\"role\":\"User\",\"message\":\"Got any creative ideas for a 10 year old's birthday?\"},{\"id\":\"58df49a3-f9b8-4c9d-982f-0eff28c66892\",\"parentMessageId\":\"ca7295ee-b882-4a2a-a6d5-63adfbab0563\",\"role\":\"ChatGPT\",\"message\":\"Sure, here are a few creative ideas for a 10-year-old's birthday party:\\n\\n1. Have a movie night at home with all of their friends, and make it a sleepover!\\n\\n2. Plan a scavenger hunt around the neighborhood or park, with clues leading to the birthday celebration.\\n\\n3. Have an art or craft party, where each child gets to create their own unique project to take home as a souvenir.\\n\\n4. Host a science experiment party, where the kids can learn and experiment with different scientific concepts.\\n\\n5. Organize a game tournament, where the kids can compete in various games like video games, board games, and outdoor games.\\n\\n6. Have a cooking or baking party, where the kids can learn to make their favorite dishes and sweets.\\n\\n7. Plan a trip to a local amusement park, aquarium, or museum for a fun day out.\\n\\n8. Host a talent show or karaoke party, where the kids can show off their singing, dancing, and other talents.\\n\\nRemember, the most important thing is to make the birthday child feel special and have a fun and memorable celebration!\"}],\"createdAt\":1676259741776},\"expires\":null}"}],["chatgpt:c4f320d1-6a38-439e-8ebe-b5438efd6ca7",{"value":"{\"value\":{\"messages\":[{\"id\":\"d3aa66e2-e140-4579-84cf-ee505d0aa47f\",\"parentMessageId\":\"fdf3eb71-6a4d-4442-ab24-903b68c6e198\",\"role\":\"User\",\"message\":\"hello\"},{\"id\":\"914c5f9e-f506-436d-98ad-1ddcda894c6f\",\"parentMessageId\":\"d3aa66e2-e140-4579-84cf-ee505d0aa47f\",\"role\":\"ChatGPT\",\"message\":\"Hello! How can I assist you today?\"},{\"id\":\"831c5c07-b6a4-4310-beef-479dacc9b054\",\"parentMessageId\":\"914c5f9e-f506-436d-98ad-1ddcda894c6f\",\"role\":\"User\",\"message\":\"you can assist me?\"},{\"id\":\"09f7487c-be8e-4507-a979-5c5c2bd96da8\",\"parentMessageId\":\"831c5c07-b6a4-4310-beef-479dacc9b054\",\"role\":\"ChatGPT\",\"message\":\"Yes, I am here to assist you with any questions or information you need. Just ask!\"}],\"createdAt\":1676260004793},\"expires\":null}"}],["chatgpt:aee231b7-aac0-46d7-b5b1-6f9775d82175",{"value":"{\"value\":{\"messages\":[{\"id\":\"19a50731-d4e9-4f9c-a793-788a24f00682\",\"parentMessageId\":\"c1925d5f-3722-493d-ad68-322bc2af9542\",\"role\":\"User\",\"message\":\"hello\"},{\"id\":\"6b4c4067-5081-46d8-a2d7-de9a1c60db4a\",\"parentMessageId\":\"19a50731-d4e9-4f9c-a793-788a24f00682\",\"role\":\"ChatGPT\",\"message\":\"Hello! How can I help you today?\"}],\"createdAt\":1676260400447},\"expires\":null}"}],["chatgpt:f65f9b34-fd6a-4274-b59d-0d954987bf7d",{"value":"{\"value\":{\"messages\":[{\"id\":\"e57c1bc4-e9a0-4c6d-91db-18c677a0fbfb\",\"parentMessageId\":\"3e006108-2aa4-48a0-b468-9cfe124e1b4d\",\"role\":\"User\",\"message\":\"how are you?\"},{\"id\":\"22900ae8-88dd-4dc2-9948-0bf322db7142\",\"parentMessageId\":\"e57c1bc4-e9a0-4c6d-91db-18c677a0fbfb\",\"role\":\"ChatGPT\",\"message\":\"Hello! As an AI language model, I don't have emotions or feelings, but I'm here to help answer any questions you may have. How may I assist you today?\"},{\"id\":\"e984204f-2300-4d6d-b98d-080c4ff7a675\",\"parentMessageId\":\"22900ae8-88dd-4dc2-9948-0bf322db7142\",\"role\":\"User\",\"message\":\"testing\"},{\"id\":\"c18884a3-1c27-4781-a8d1-ac2070f84484\",\"parentMessageId\":\"e984204f-2300-4d6d-b98d-080c4ff7a675\",\"role\":\"ChatGPT\",\"message\":\"I'm here to help answer any questions or provide information you may be seeking. Can you please provide more context or clarify what you'd like to know?\"}],\"createdAt\":1676260511690},\"expires\":null}"}],["chatgpt:144b42cf-5166-4d88-bf97-361dff2335bc",{"value":"{\"value\":{\"messages\":[{\"id\":\"54445d69-e040-47fb-b2cc-a435e6d52113\",\"parentMessageId\":\"3b1f609d-0f34-4366-81de-4a7543c2fb6b\",\"role\":\"User\",\"message\":\"Explain quantum computing in simple terms\"},{\"id\":\"9d7c0c8d-e215-4f35-afca-9bb3d9b9ef31\",\"parentMessageId\":\"54445d69-e040-47fb-b2cc-a435e6d52113\",\"role\":\"ChatGPT\",\"message\":\"Quantum computing is a type of computing that uses quantum mechanics to process information. Unlike traditional computers that use bits to represent information as either a 0 or 1, quantum computers use quantum bits or \\\"qubits.\\\" These qubits can exist in multiple states at the same time, making quantum computers incredibly powerful at solving certain types of problems. This is because quantum computers can perform many calculations simultaneously, whereas classical computers can only perform one calculation at a time. \\n\\nIn simple terms, quantum computing is a type of computing that uses the principles of quantum mechanics to process information. It has the potential to be much faster and more powerful than traditional computers for certain types of problems.\"}],\"createdAt\":1676300397781},\"expires\":null}"}],["chatgpt:31436246-2acf-4ad0-aeb8-30a941e1604f",{"value":"{\"value\":{\"messages\":[{\"id\":\"83948b1e-a0e3-485a-ae1b-1d5c3c9c1e30\",\"parentMessageId\":\"e2e7b0bd-ac3d-45ec-aea5-66941634ece5\",\"role\":\"User\",\"message\":\"Hello there\"},{\"id\":\"aa313dd1-f7bf-454a-82a7-25b392f6e32e\",\"parentMessageId\":\"83948b1e-a0e3-485a-ae1b-1d5c3c9c1e30\",\"role\":\"ChatGPT\",\"message\":\"Hello! How can I help you today?\"}],\"createdAt\":1676300648846},\"expires\":null}"}],["chatgpt:67609842-6aae-4607-b433-c3ce0cb7b938",{"value":"{\"value\":{\"messages\":[{\"id\":\"da800007-96fe-4869-b7fb-5e830e5d0cbf\",\"parentMessageId\":\"3e12f228-88e4-4c0e-898f-324995a1e8e3\",\"role\":\"User\",\"message\":\"hello there\"},{\"id\":\"da529a09-7131-46ec-a91e-aead697fc34f\",\"parentMessageId\":\"da800007-96fe-4869-b7fb-5e830e5d0cbf\",\"role\":\"ChatGPT\",\"message\":\"Hello! How can I help you today?\"}],\"createdAt\":1676300921397},\"expires\":null}"}],["chatgpt:080dcb7b-6ef9-4c50-9a35-6e4f79d3da89",{"value":"{\"value\":{\"messages\":[{\"id\":\"ac1de307-0b0e-4332-aa68-7f234bb418e8\",\"parentMessageId\":\"92bdfdf6-0405-4eaf-8a41-5a9defd4da6b\",\"role\":\"User\",\"message\":\"Hello there\"},{\"id\":\"425d3690-dce8-4589-8650-3a9e3830a728\",\"parentMessageId\":\"ac1de307-0b0e-4332-aa68-7f234bb418e8\",\"role\":\"ChatGPT\",\"message\":\"Hello! How can I help you today?\"}],\"createdAt\":1676301050894},\"expires\":null}"}]],"lastExpire":1676242182090} \ No newline at end of file +{"cache":[["chatgpt:717552b6-8705-4c84-967e-dab4a5d8ac36",{"value":"{\"value\":{\"messages\":[{\"id\":\"c1bca391-e16c-45ee-9adc-732bb4dca429\",\"parentMessageId\":\"5509a303-a673-4927-885c-9af93e6ade8a\",\"role\":\"User\",\"message\":\"Write me a haiku about microsoft bing\"},{\"id\":\"21a764a8-abce-4eb9-b3e6-c80d82107e70\",\"parentMessageId\":\"c1bca391-e16c-45ee-9adc-732bb4dca429\",\"role\":\"ChatGPT\",\"message\":\"Bing searches the web,\\nSilent, swift, and always fast.\\nFinds what we seek.\"},{\"id\":\"ed1a217f-96c1-4421-9728-e6d5c25638ae\",\"parentMessageId\":\"21a764a8-abce-4eb9-b3e6-c80d82107e70\",\"role\":\"User\",\"message\":\"what would you title your haiku?\"},{\"id\":\"4ac0cd08-8198-40fc-a157-48f7e99ee186\",\"parentMessageId\":\"ed1a217f-96c1-4421-9728-e6d5c25638ae\",\"role\":\"ChatGPT\",\"message\":\"\\\"The Search Engine's Song\\\"\"}],\"createdAt\":1676312828824},\"expires\":null}"}]],"lastExpire":1676312828824} \ No newline at end of file diff --git a/server/routes/ask.js b/server/routes/ask.js index db9c61db89..2f09d59122 100644 --- a/server/routes/ask.js +++ b/server/routes/ask.js @@ -6,18 +6,25 @@ const { askClient } = require('../../app/chatgpt-client'); const { saveMessage, deleteMessages } = require('../../models/Message'); const { saveConvo } = require('../../models/Conversation'); +const handleError = (res, errorMessage) => { + res.status(500).write(`event: error\ndata: ${errorMessage}`); + res.end(); +}; + +const sendMessage = (res, message) => { + res.write(`event: message\ndata: ${JSON.stringify(message)}\n\n`); +}; + router.post('/', async (req, res) => { const { text, parentMessageId, conversationId } = req.body; if (!text.trim().includes(' ') && text.length < 5) { - res.status(500).write('Prompt empty or too short'); - res.end(); - return; + return handleError(res, 'Prompt empty or too short'); } const userMessageId = crypto.randomUUID(); let userMessage = { id: userMessageId, sender: 'User', text }; - console.log('ask log', userMessage); + console.log('ask log', { ...userMessage, parentMessageId, conversationId }); res.writeHead(200, { Connection: 'keep-alive', @@ -35,71 +42,58 @@ router.post('/', async (req, res) => { userMessage.parentMessageId = parentMessageId ? parentMessageId : partial.id; userMessage.conversationId = conversationId ? conversationId : partial.conversationId; await saveMessage(userMessage); - res.write( - `event: message\ndata: ${JSON.stringify({ ...partial, initial: true })}\n\n` - ); + sendMessage(res, { ...partial, initial: true }); i++; } if (typeof partial === 'object') { - const data = JSON.stringify({ ...partial, message: true }); - res.write(`event: message\ndata: ${data}\n\n`); + sendMessage(res, { ...partial, message: true }); } else { tokens += partial; - res.write(`event: message\ndata: ${JSON.stringify({ text: tokens, message: true })}\n\n`); + sendMessage(res, { text: tokens, message: true }); } }; - let gptResponse = await askClient(text, progressCallback, { parentMessageId, conversationId }); + let gptResponse = await askClient(text, progressCallback, { + parentMessageId, + conversationId + }); console.log('CLIENT RESPONSE', gptResponse); - if (!!parentMessageId) { - gptResponse = { ...gptResponse, parentMessageId }; - } else { + if (!parentMessageId) { gptResponse.title = await titleConvo(text, gptResponse.text); } - if (!gptResponse.parentMessageId && !parentMessageId) { - userMessage.parentMessageId = gptResponse.messageId; - gptResponse.parentMessageId = gptResponse.messageId; - userMessage.conversationId = gptResponse.conversationId; - } - - const response = gptResponse.text || gptResponse.response; - - if (gptResponse.response) { - await saveMessage(userMessage); + if (!gptResponse.parentMessageId) { gptResponse.text = gptResponse.response; gptResponse.id = gptResponse.messageId; + gptResponse.parentMessageId = gptResponse.messageId; + userMessage.parentMessageId = parentMessageId ? parentMessageId : gptResponse.messageId; + userMessage.conversationId = conversationId ? conversationId : gptResponse.conversationId; + await saveMessage(userMessage); delete gptResponse.response; } if ( - (response.includes('2023') && !response.trim().includes(' ')) || - response.toLowerCase().includes('no response') || - response.toLowerCase().includes('no answer') + (gptResponse.text.includes('2023') && !gptResponse.text.trim().includes(' ')) || + gptResponse.text.toLowerCase().includes('no response') || + gptResponse.text.toLowerCase().includes('no answer') ) { - res.status(500).write('event: error\ndata: Prompt empty or too short'); - res.end(); - return; + return handleError(res, 'Prompt empty or too short'); } gptResponse.sender = 'GPT'; gptResponse.final = true; - // console.log('gptResponse', gptResponse); - await saveMessage(gptResponse); await saveConvo(gptResponse); - - res.write(`event: message\ndata: ${JSON.stringify(gptResponse)}\n\n`); + sendMessage(res, gptResponse); res.end(); } catch (error) { console.log(error); await deleteMessages({ id: userMessageId }); - res.status(500).write('event: error\ndata: ' + error.message); - res.end(); + handleError(res, error.message); } }); -module.exports = router; +module.exports = router; \ No newline at end of file diff --git a/src/App.jsx b/src/App.jsx index 06a56fdc67..ef8676d344 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,13 +1,14 @@ import React from 'react'; -import { useSelector } from 'react-redux'; import Messages from './components/main/Messages'; import TextChat from './components/main/TextChat'; import Nav from './components/Nav'; import MobileNav from './components/Nav/MobileNav'; +import { useSelector } from 'react-redux'; const App = () => { + const { messages } = useSelector((state) => state.messages); - const { title } = useSelector((state) => state.convo); + const convo = useSelector((state) => state.convo); return (
@@ -15,10 +16,8 @@ const App = () => {
- - + +
diff --git a/src/components/Nav/ClearConvos.jsx b/src/components/Nav/ClearConvos.jsx index 9908b877cb..328fb3426a 100644 --- a/src/components/Nav/ClearConvos.jsx +++ b/src/components/Nav/ClearConvos.jsx @@ -1,5 +1,6 @@ import React from 'react'; import TrashIcon from '../svg/TrashIcon'; +import { useSWRConfig } from "swr" import manualSWR from '~/utils/fetchers'; import { useDispatch } from 'react-redux'; import { setConversation } from '~/store/convoSlice'; @@ -7,6 +8,7 @@ import { setMessages } from '~/store/messageSlice'; export default function ClearConvos() { const dispatch = useDispatch(); + const { mutate } = useSWRConfig() const { trigger, isMutating } = manualSWR( 'http://localhost:3050/convos/clear', @@ -14,6 +16,7 @@ export default function ClearConvos() { () => { dispatch(setMessages([])); dispatch(setConversation({ error: false, conversationId: null, parentMessageId: null })); + mutate('http://localhost:3050/convos'); } ); diff --git a/src/components/main/Message.jsx b/src/components/main/Message.jsx index b370a592c5..7626a47388 100644 --- a/src/components/main/Message.jsx +++ b/src/components/main/Message.jsx @@ -14,6 +14,8 @@ export default function Message({ sender, text, last = false, error = false }) { 'w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-100 dark:bg-[#444654]'; } + const blinker = isSubmitting && last && sender === 'GPT'; + return (
@@ -32,7 +34,7 @@ export default function Message({ sender, text, last = false, error = false }) {
{!!error ? ( -
+
{text}
@@ -40,7 +42,7 @@ export default function Message({ sender, text, last = false, error = false }) { ) : ( {text} - {isSubmitting && last && sender === 'GPT' && } + {blinker && } )}
diff --git a/src/components/main/Messages.jsx b/src/components/main/Messages.jsx index e274563bb7..dc0dba9e7a 100644 --- a/src/components/main/Messages.jsx +++ b/src/components/main/Messages.jsx @@ -1,9 +1,11 @@ import React, { useEffect, useRef } from 'react'; +import { useSelector } from 'react-redux'; import useDocumentTitle from '~/hooks/useDocumentTitle'; +import useDidMountEffect from '~/hooks/useDidMountEffect'; import Message from './Message'; import Landing from './Landing'; -export default function Messages({ messages, title }) { +export default function Messages({ title, messages }) { if (messages.length === 0) { return ; } @@ -18,9 +20,11 @@ export default function Messages({ messages, title }) { // this useEffect triggers the following warning: // Warning: Internal React error: Expected static flag was missing. - useEffect(() => { - scrollToBottom(); - }, [messages]); + // useEffect(() => { + // scrollToBottom(); + // }, [messages]); + + useDidMountEffect(() => scrollToBottom(), [messages]); return (
diff --git a/src/components/main/TextChat.jsx b/src/components/main/TextChat.jsx index fc4f806446..692e93c442 100644 --- a/src/components/main/TextChat.jsx +++ b/src/components/main/TextChat.jsx @@ -10,7 +10,7 @@ import { setMessages } from '~/store/messageSlice'; import { setSubmitState } from '~/store/submitSlice'; import { setText } from '~/store/textSlice'; -export default function TextChat({ messages, reloadConvos }) { +export default function TextChat({ messages }) { const [errorMessage, setErrorMessage] = useState(''); const dispatch = useDispatch(); const convo = useSelector((state) => state.convo); diff --git a/src/store/convoSlice.js b/src/store/convoSlice.js index 00cb14b7c5..ed74618635 100644 --- a/src/store/convoSlice.js +++ b/src/store/convoSlice.js @@ -1,4 +1,4 @@ -import { createSlice } from '@reduxjs/toolkit'; +import { createSlice, current } from '@reduxjs/toolkit'; const initialState = { error: false, diff --git a/src/store/index.js b/src/store/index.js index b7d1dcec76..1c4a9950ea 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -11,5 +11,6 @@ export const store = configureStore({ messages: messageReducer, text: textReducer, submit: submitReducer, - } + }, + devTools: true, }); \ No newline at end of file diff --git a/src/style.css b/src/style.css index beda89edea..ac14d504b3 100644 --- a/src/style.css +++ b/src/style.css @@ -587,4 +587,23 @@ body,html { .dark .disabled\:dark\:hover\:text-gray-400:hover:disabled { --tw-text-opacity:1; color:rgba(172,172,190,var(--tw-text-opacity)) + } + +/* .result-streaming>:not(ol):not(ul):not(pre):last-child:after, +.result-streaming>ol:last-child li:last-child:after, +.result-streaming>pre:last-child code:after, +.result-streaming>ul:last-child li:last-child:after { + -webkit-animation:blink 1s steps(5,start) infinite; + animation:blink 1s steps(5,start) infinite; + content:"▋"; + margin-left:.25rem; + vertical-align:baseline +} */ + +.result-streaming { + -webkit-animation:blink 1s steps(5,start) infinite; + animation:blink 1s steps(5,start) infinite; + /* content:"▋"; */ + margin-left:.25rem; + vertical-align:baseline } \ No newline at end of file