Skip to content

Commit

Permalink
Update to v2.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac0511 committed Sep 8, 2024
1 parent 3930fcf commit 28ac740
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 21 deletions.
59 changes: 42 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,25 +201,50 @@
const input = document.querySelector("#messageInput");
message = message || input.value.trim();
console.log("Message sent to Puter AI");

if (message) {
addMessage(message, true);
input.value = '';
toggleLoadingSpinner(true);
// Record the message in array of messages
messages.push({ content: message, role: 'user' });
// Call the AI chat function
puter.ai.chat(messages).then(response => {
addMessage(response, false);
messages.push(response.message);
toggleLoadingSpinner(false);
console.log("AI response received");
}).catch(error => {
console.error("AI response error:", error);
alert("An error occured, please try again.");
toggleLoadingSpinner(false);
});
addMessage(message, true); // Add user message to chat history
input.value = ''; // Clear input field

toggleLoadingSpinner(true); // Show loading indicator

// Create messages array with context for the AI
const messages = [
{
// Gives the AI important info about how it needs to awnser
role: 'system',
content: "You are the AI of a PWA named 'Puter AI PWA' developed by 'Zac0511'.The PWA is powered by Puter.js, allowing websites to use AI for free. You need to remember that Zac0511 is not the one who created you, he only made the PWA which interacts with you thanks to Puter.js, your creator is a company called 'Puter'. Puter is web based operationg system, entierly running in the browser, its creators are only 3 persons, but the projects grows fast as its open source, and more 2000 users contributed to it (including Zac0511, the creator of this PWA). Puter.js is Puter's API, allwoing websites to store files on the user's Puter filesystem, and access AI, which is why your creator is Puter. Your name is 'Puter AI'. Do NOT use Markdown formatting, the PWA in which you run doesn't support markdown."
},
{
// Complementary informations about Puter that the AI could need for some questions
role: 'system',
content: "The following is complementary informations about Puter: The URL to access Puter is 'https://puter.com'. Puter is web-based OS running entierly in the browser. You have been created by Puter. Puter is made by only 3 persons, but grows fast because it is open source. The URL to join Puter's Discord server is 'https://discord.gg/PQcx7Teh8u'"
},
{
// Complementary informations about the Puter AI PWA
role: 'system',
content: "The following is complementary informations about the Puter AI PWA: The current version of the Puter AI PWA is version 2.2.2. The creator of the Puter AI PWA is 'Zac0511'. The Puter AI PWA can be installed on computer and mobile, but it can also be runned (without being installed) on any device with a recent browser (such as computers, phones, consoles, TVs, etc...). The Puter AI PWA can be used without a Puter account, but the user will have less message credits. The user can check how many messages credits are left on his Puter account by opening Puter, clicking the Puter logo in the top left corner (it will open settings), clicking 'Usage' in the settings, and checking the bar named 'puter-chat-completion (complete):'. The Puter AI PWA is also available as a Puter app at the URL 'https://puter.com/app/ai-chat'. The UI of the Puter AI PWA is using Google Material Design V3. The PWA cannot be used offline, as the AI is stored on Puter servers (trying to open the app when offline will show a custom error message). If the user encounters any problem with the Puter AI PWA, or ask for a new feature, he can create an issue at the URL 'https://github.com/Zac0511/Puter-AI-PWA/issues/new/choose'."
},
{
role: 'user',
content: message // User's actual message
}
}
];

// Call the AI chat function with the messages array
puter.ai.chat(messages)
.then(response => {
addMessage(response, false); // Add AI response to chat history
toggleLoadingSpinner(false); // Hide loading indicator
console.log("AI response received");
})
.catch(error => {
console.error("AI response error:", error);
alert("An error occured, please try again. If the error persists, please create an issue on the GitHub repository (you can access it by clicking the button with a 'code' icon)");
toggleLoadingSpinner(false); // Hide loading indicator in case of error
});
}
}

function getQueryParam(param) {
const urlParams = new URLSearchParams(window.location.search);
Expand Down
2 changes: 1 addition & 1 deletion settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h2>Puter account settings</h2>
<div id="container">
<div id="infos">
<h3>Infos</h3>
<p>Puter AI PWA - v2.2.1</p>
<p>Puter AI PWA - v2.2.2</p>
<p>Copyright © Zac0511 - 2024</p>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://puter-ai.puter.site/index.html</loc>
<lastmod>2024-08-06</lastmod>
<lastmod>2024-09-08</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://puter-ai.puter.site/settings.html</loc>
<lastmod>2024-09-05</lastmod>
<lastmod>2024-09-08</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
</urlset>
</urlset>

0 comments on commit 28ac740

Please sign in to comment.