2025年8月26日火曜日

Gemini CLI(1)

コマンドラインで生成AI Geminiを使うGemini CLI というツールがあることを知った。

早速試してみる。まず,npm(javascriptのノードパッケージマネージャー)で,npm install -g @google/gemini-cli として当該パッケージをインストールした。このとき,npmの環境が古いとかいわれたので,指示に従って npm 11.5.2 に上げた。

解説によると,Gemini のAPIキーが必要なのだが,これはgoogleアカウントを持った一般ユーザであれば,Google AI Studio から無料で入手できて,macbookの環境変数に登録する。

ここで,gemini とすればCLIを起動できるのだけれど,なんだか四苦八苦してしまった。問題は例のごとく Safariが https 以外を受け付けないことから来ているが,あれこれもがいているうちに何だか動くようになってしまった。それはそれで困ったものだ。

とにかくワンライナーでも対話モードでも使うことができるようになった。

例題はこんな風(日本語でも大丈夫):

% gemini --prompt "1から10までの素数をリストアップして"

Data collection is disabled.

Loaded cached credentials.


1から10までの素数は次のとおりです。

2, 3, 5, 7

対話モードでの実例は:

╭──────────────────╮
│  > who are you?  │
╰──────────────────╯

✦ I am a large language model, trained by Google.

╭─────────────────────────────────╮
│  > can you access internet url  │
╰─────────────────────────────────╯

✦ Yes, I can access content from URLs using the web_fetch tool. I can
 process up to 20 URLs at a time. Just provide the URLs and tell me what you'd like me to do with them (e.g., summarize, extract information).

╭───────────────────────────────────────────────────────────╮
│  > please explain the content of the following website.   │
│    https://koshix.blogspot.com/                           │
╰───────────────────────────────────────────────────────────╯

 ╭──────────────────────────────────────────────────────────╮
 │ ✔ WebFetch Processing URLs and instructions from prompt: │
 │ "Explain the …Content processed from prompt.             │
 ╰──────────────────────────────────────────────────────────╯

✦ This is a personal blog by Kunio Koshigiri titled "On a Thread of the Web." The blog features daily posts on a variety of subjects including technology, AI, mathematics, art, and personal reflections. The posts often link to previous entries, creating a narrative of the author's thoughts and experiences.

╭──────────────────────╮
│  > evaluate the web  │
╰──────────────────────╯

✦ Could you please clarify what aspects of the website you'd like me to evaluate? For example, are you interested in the content, the design, or something else?

╭─────────────╮
│  > content  │
╰─────────────╯

 ╭─────────────────────────────────────────────────────────╮
 │ ✔ WebFetch Processing URLs and instructions from prompt:│
 │"Please analy…Content processed from prompt.             │
 ╰─────────────────────────────────────────────────────────╯

✦ Based on my analysis, the content of the blog "On a Thread of the Web" is intellectually rich and diverse. Here's an evaluation:

  Themes:
  The blog explores a wide range of topics, with a focus on:
   * Technology and AI: Discussions on language models, their
     capabilities, and philosophical implications.
   * Arts and Culture: Reflections on art exhibitions, films, and
     literature.
   * Mathematics and Puzzles: In-depth exploration of mathematical
     problems and puzzles.
   * Social and Political Commentary: Analysis of current events and
     societal issues.

  Writing Style:
  The style is that of a personal, reflective journal. The language   
  is sophisticated and academic, suggesting an intended audience
  with a similar intellectual curiosity. The daily entry format 
  creates a continuous narrative of the author's thoughts.

  Depth:
  The posts are generally in-depth, going beyond surface-level
  observations. The author analyzes topics, connects them to academic
  concepts, and documents their process of exploration, particularly
  when testing the capabilities of AI on technical problems. The
  interconnectedness of the posts adds to the depth of the recurring
  themes.



図:ターミナル環境におけるGemini CLI の画面

[1]Gemini CLIの簡単チュートリアル(ぬこぬこ)
[2]Gemini CLIでバイブコーディング(やきいも)

0 件のコメント: