Skip to content

Instantly share code, notes, and snippets.

@up1
Last active November 3, 2024 15:18
Show Gist options
  • Save up1/f028934118470aff34179fe143055535 to your computer and use it in GitHub Desktop.
Save up1/f028934118470aff34179fe143055535 to your computer and use it in GitHub Desktop.
Google AI API
const a = await ai.languageModel.capabilities()
console.log(a.available);
// ถ้าขึ้นคำว่า readily แสดงว่าเราสามารถใช้งานได้เลย
// แต่ถ้าไม่ ให้ทำการสร้างดังนี้
await ai.languageModel.create();
ทำการตรวจสอบใน browser = chrome://components
* Optimization Guide On Device Model
const {available, defaultTemperature, defaultTopK, maxTopK } = await ai.languageModel.capabilities();
if (available !== "no") {
const session = await ai.languageModel.create();
// Prompt the model and wait for the whole result to come back.
const result = await session.prompt("Hello world");
console.log(result);
}
// ผลการทำงาน
Hello world!
It's great to see your interest in coding. This is a fundamental first step in programming, and it's exciting to see you getting started.
If you'd like to learn more about how the "Hello world" program works, or if you want to explore other programming concepts, feel free to ask! We can cover topics like:
* **Variables and Data Types:** Storing and using different types of information in your programs.
* **Operators:** Performing calculations and manipulating data.
* **Conditional Statements (if, else, elif):** Making decisions based on different conditions.
* **Loops (for, while):** Repeating code blocks.
* **Functions:** Creating reusable blocks of code.
* **Input and Output:** Getting data from the user and displaying it.
I'm here to guide you on your coding journey. Don't hesitate to ask any questions you might have along the way. Let's make this a fun and rewarding learning experience!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment