Things I want to do
We will use Google’s generative AI, Gemini, with NodeJS.
implementation
Creating an API key
Access the following page to obtain your API key.
Project creation
Here, I created a NodeJS + Vite project using the following article.
Next, run the following command to install generative-ai.
npm install @google/generative-aiCreating HTML
Create an index.html file in the Src folder.
The content is as follows:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Gemini</title>
</head>
<body>
<script type="module" src="main.js"></script>
</body>
</html>Creating JavaScript
Create a main.js file in the Src folder, the same file that is loaded in index.html.
The content is as follows. Please replace ‘Your API key’ with the API key you obtained.
Also, do not write the API key in a visible location (i.e., in the script). It is hardcoded here for testing purposes. It is better to obtain it from environment variables.
let api_key = "Your API key"
import { GoogleGenerativeAI } from "@google/generative-ai";
const genAI = new GoogleGenerativeAI(api_key);
const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash" });
const prompt = "GoogleのAIのGeminiに関して教えて。";
const result = await model.generateContent(prompt);
console.log(result.response.text());Result
Execute the following and run it in your browser
npm run devThe following was logged to the console. (This may take several seconds to several tens of seconds.)
## GoogleのAI、Geminiについて
Geminiは、Googleが開発中の次世代AIシステムです。Bardの後継であり、Googleの最新のAI技術を搭載し、より高度な能力を持つとされています。
**Geminiの特徴:**
* **マルチモーダル:** テキスト、画像、音声、動画など、さまざまな種類の情報を理解し、処理できる能力を備えています。
* **高度な言語理解力:** 自然言語処理能力が向上し、複雑な文脈を理解し、人間に近い自然な文章を生成できます。
* **推論能力:** 複雑な問題を分析し、論理的な推論を行い、適切な回答を導き出すことができます。
* **コード生成能力:** プログラミングコードの理解、生成、修正など、ソフトウェア開発に役立つ機能も備えています。
**現時点での情報:**
* **まだ開発段階:** Geminiは現在開発中で、正式なリリース日は未定です。
* **具体的な機能:** 公開されている情報は限られており、具体的な機能の詳細や性能については不明です。
* **競合との比較:** Geminiは、OpenAIのChatGPTやMicrosoftのBing AIなどの競合サービスと比較され、性能や機能面で優位性を競うことになるでしょう。
**期待される影響:**
* **様々な分野への応用:** Geminiは、翻訳、情報検索、顧客サポート、教育など、さまざまな分野で活用されることが期待されています。
* **より高度なAI体験:** 人間とAIのインタラクションがより自然になり、より高度なAIサービスが提供される可能性があります。
* **技術革新への貢献:** Geminiの開発は、AI技術のさらなる発展と革新に貢献する可能性があります。
**今後の動向:**
* Geminiの開発状況やリリース時期に関する情報は、Googleの公式発表を待ちましょう。
* 今後、より詳細な情報や具体的な機能が公開されることが期待されます。
**まとめ:**
Geminiは、Googleが開発中の次世代AIシステムで、マルチモーダル、高度な言語理解力、推論能力、コード生成能力などを備えています。正式なリリースは未定ですが、今後AI技術の発展に大きく貢献する可能性を秘めています。The GUI will be created in the article below.
Websites I used as references



コメント