Skip to content

Commit

Permalink
chore: lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Jun 26, 2024
1 parent b83c14c commit 2d9303b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 19 deletions.
2 changes: 1 addition & 1 deletion langchain/src/experimental/chrome_ai/app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ yarn install # install the dependencies
yarn start # start the application
```

Then, open your browser and navigate to [`http://127.0.0.1:8080/src/chrome_ai.html`](http://127.0.0.1:8080/src/chrome_ai.html).
Then, open your browser and navigate to [`http://127.0.0.1:8080/src/chrome_ai.html`](http://127.0.0.1:8080/src/chrome_ai.html).
36 changes: 28 additions & 8 deletions langchain/src/experimental/chrome_ai/app/src/chrome_ai.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
text-align: center;
}
button {
background-color: #4CAF50;
background-color: #4caf50;
border: none;
color: white;
padding: 10px 20px;
Expand All @@ -34,7 +34,7 @@
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
input[type="text"] {
width: 100%;
Expand All @@ -48,7 +48,7 @@
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
margin-top: 20px;
}
.stats {
Expand All @@ -71,21 +71,41 @@ <h1>LangChain.js🦜🔗 - ChatChromeAI Example</h1>

<form id="inputForm">
<label for="inputField">Enter your input:</label><br />
<input type="text" id="inputField" name="inputField" autocomplete="off" /><br />
<input
type="text"
id="inputField"
name="inputField"
autocomplete="off"
/><br />
<button type="submit">Submit</button>
</form>

<div id="responseContainer">
<div id="responseText"></div>
<div id="statsContainer">
<div class="stats">
<span class="stat-pill" style="background-color: #3498db;" id="firstTokenTime">First Token: -- ms</span>
<span class="stat-pill" style="background-color: #2ecc71;" id="totalTime">Total Time: -- ms</span>
<span class="stat-pill" style="background-color: #e74c3c;" id="totalTokens">Total Tokens: --</span>
<span
class="stat-pill"
style="background-color: #3498db"
id="firstTokenTime"
>First Token: -- ms</span
>
<span
class="stat-pill"
style="background-color: #2ecc71"
id="totalTime"
>Total Time: -- ms</span
>
<span
class="stat-pill"
style="background-color: #e74c3c"
id="totalTokens"
>Total Tokens: --</span
>
</div>
</div>
</div>

<script src="../dist/bundle.js"></script>
</body>
</html>
</html>
12 changes: 9 additions & 3 deletions langchain/src/experimental/chrome_ai/app/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ inputForm.addEventListener("submit", async (event) => {
console.log(`First Token: ${Math.round(timeToFirstTokenMs)} ms`);
console.log(`Total Time: ${Math.round(totalTimeMs)} ms`);
console.log(`Total Tokens: ${numTokens}`);
document.getElementById("firstTokenTime").textContent = `First Token: ${Math.round(timeToFirstTokenMs)} ms`;
document.getElementById("totalTime").textContent = `Total Time: ${Math.round(totalTimeMs)} ms`;
document.getElementById("totalTokens").textContent = `Total Tokens: ${numTokens}`;
document.getElementById(
"firstTokenTime"
).textContent = `First Token: ${Math.round(timeToFirstTokenMs)} ms`;
document.getElementById("totalTime").textContent = `Total Time: ${Math.round(
totalTimeMs
)} ms`;
document.getElementById(
"totalTokens"
).textContent = `Total Tokens: ${numTokens}`;
});
12 changes: 6 additions & 6 deletions langchain/src/experimental/chrome_ai/app/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const path = require('path');
const path = require("path");

module.exports = {
entry: './src/index.js',
entry: "./src/index.js",
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
filename: "bundle.js",
path: path.resolve(__dirname, "dist"),
},
mode: 'development',
};
mode: "development",
};
2 changes: 1 addition & 1 deletion langchain/src/experimental/chrome_ai/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class ChatChromeAI extends SimpleChatModel<ChromeAICallOptions> {
throw new Error("ChatChromeAI can only be used in the browser.");
}

const ai: AI = (window as any).ai;
const {ai} = window as any;
const canCreateTextSession = await ai.canCreateTextSession();
if (canCreateTextSession === AIModelAvailability.No) {
throw new Error("The AI model is not available.");
Expand Down

0 comments on commit 2d9303b

Please sign in to comment.