【完全無料】WindowsでOpen Interpreter~みんなのPCにAI導入!Open Interpreterとおしゃべりしながら、プログラミングをしよう~【Llama2】

AI

はじめに

こんにちは、未来のPC操作を体験しませんか?今回は、AI技術「Open Interpreter」を利用して、PCとおしゃべりしながらプログラムを書く方法をご紹介します。初心者の方でも手軽に始められるよう、手順を丁寧に解説いたします。

Open Interpreter

Open Interpreter(オープンインタープリター)は、大規模言語モデル(LLM)をローカルのコンピュータ上でコードを実行するツールです。具体的には、PythonやJavascript、Shellなどのコードが実行できます。

インストール後、ターミナルで$ interpreterと入力することで、ChatGPTのようなインターフェースが表示され、Open Interpreterと"おしゃべり"ができるようになります。

このOpen Interpreterの魅力は、自分のコンピュータの機能を自然言語、つまり、普段の言葉で指示することができる点です。具体的には以下のようなことが可能です:

  1. 画像、動画、PDFの作成や編集: 通常のソフトウェアを使わずとも、Open Interpreterに指示を出すことで、これらのメディアの作成や編集が行えます。
  2. Chromeブラウザの制御: Open Interpreterを使って、Chromeブラウザを操作し、情報収集やリサーチが行えます。
  3. 大量のデータの分析: データセットの可視化やクリーニング、分析など、データ関連の作業もOpen Interpreterで手軽に実行できます。

これらの機能を利用することで、プログラミング初心者でも簡単に多様なタスクをPython上で行うことができます。Open Interpreterは、コンピュータとの新しいコミュニケーション方法を提供してくれる便利なツールと言えるでしょう。---

GitHub - KillianLucas/open-interpreter: OpenAI's Code Interpreter in your terminal, running locally
OpenAI's Code Interpreter in your terminal, running locally - GitHub - KillianLucas/open-interpreter: OpenAI's Code Interpreter in your terminal, running locall...

Visual Studio 2022の導入

なぜ必要なのか?
Open Interpreterを使うためには、llama-cpp-pythonというパッケージが必要です。このパッケージのインストールには「Visual Studio 2022」が必須となります。

手順:

  1. Visual Studio公式ページ を開きます。
  2. 「Visual Studio 2022」をダウンロードし、インストールを行います。

仮想環境の構築

なぜ必要なのか?
プログラムを安全に実行するため、仮想環境を構築します。この環境内で必要なパッケージをインストールし、プログラムを実行します。

手順:

  1. ターミナルまたはコマンドプロンプトを開きます。
  2. 以下のコマンドを入力し、Enterキーを押します。

conda create -n open-interpreter

これで、open-interpreterという名前の仮想環境が作成されます。

必要なパッケージのインストール

手順:

  1. 先ほど作成した仮想環境をアクティブにします。

conda activate open-interpreter
  1. 次に、以下のコマンドを入力して、必要なパッケージをインストールします。

pip install open-interpreter
pip install llama-cpp-python

サンプルの実行

手順:

  1. Pythonのインタラクティブシェルを開きます。
  2. 以下のコードを入力し、Enterキーを押します。

import interpreter
interpreter.chat("art パッケージの tprint を使用して hello world を表示します。また、日本語で説明してください。")

(open-inter) E:\Prj\WinOpenInt>python open_interpreter.py

Welcome to Open Interpreter.

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

▌ OpenAI API key not found

To use GPT-4 (recommended) please provide an OpenAI API key.

To use Code-Llama (free but less capable) press enter.

OpenAI API key:

▌ Switching to Code-Llama...

Tip: Run interpreter --local to automatically use Code-Llama.

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Open Interpreter will use Code Llama for local execution. Use your arrow keys to set up the model.

[?] Parameter count (smaller is faster, larger is more capable): 34B
   7B
   13B
 > 34B

[?] Quality (smaller is faster, larger is more capable): Large | Size: 33.4 GB, Estimated RAM usage: 35.9 GB
   Small | Size: 13.2 GB, Estimated RAM usage: 15.7 GB
   Medium | Size: 18.8 GB, Estimated RAM usage: 21.3 GB
 > Large | Size: 33.4 GB, Estimated RAM usage: 35.9 GB
   See More

[?] Use GPU? (Large models might crash on GPU, but will run more quickly) (Y/n): n

Model found at C:\Users\harum\AppData\Local\Open Interpreter\Open Interpreter\models\codellama-34b-instruct.Q8_0.gguf

▌ Model set to TheBloke/CodeLlama-34B-Instruct-GGUF

Open Interpreter will require approval before running code. Use interpreter -y to bypass this.

Press CTRL-C to exit.

  import art                                                      
  art.tprint("Hello World")                                                      

  Would you like to run this code? (y/n)

  y

  import art                                                      
  art.tprint("Hello World")                                                      

  _   _        _  _         __        __              _      _
  | | | |  ___ | || |  ___   \ \      / /  ___   _ __ | |  __| |
  | |_| | / _ \| || | / _ \   \ \ /\ / /  / _ \ | '__|| | / _` |
  |  _  ||  __/| || || (_) |   \ V  V /  | (_) || |   | || (_| |
  |_| |_| \___||_||_| \___/     \_/\_/    \___/ |_|   |_| \__,_|

  The output is a simple ASCII art representation of the phrase "Hello World" in Japanese. The text is displayed using the tprint function from the art package, which allows for printing text with different fonts and styles. In this case, the font used is the default one provided by     
  the art package.

このコードを実行すると、tprintを使用して「hello world」と表示されるサンプルを体験できます。

株価情報の取得

Open Interpreterを使うと、具体的な要求に応じて様々な操作ができます。例として、Appleの株価をグラフ表示し、それを保存する方法を紹介します。

手順:

  1. Pythonのインタラクティブシェルに戻り、以下のコードを入力して実行します。

import interpreter
interpreter.chat("Apple の株価を取得してグラフにして保存して")

(open-inter) E:\Prj\WinOpenInt>python open_interpreter.py

Welcome to Open Interpreter.

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

▌ OpenAI API key not found

To use Code-Llama (free but less capable) press enter.

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

OpenAI API key:

▌ Switching to Code-Llama...

Tip: Run interpreter --local to automatically use Code-Llama.

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Open Interpreter will use Code Llama for local execution. Use your arrow keys to set up the model.

[?] Parameter count (smaller is faster, larger is more capable): 34B
   7B
   13B
 > 34B

[?] Quality (smaller is faster, larger is more capable): Large | Size: 33.4 GB, Estimated RAM usage: 35.9 GB
   Small | Size: 13.2 GB, Estimated RAM usage: 15.7 GB
   Medium | Size: 18.8 GB, Estimated RAM usage: 21.3 GB
 > Large | Size: 33.4 GB, Estimated RAM usage: 35.9 GB
   See More

[?] Use GPU? (Large models might crash on GPU, but will run more quickly) (Y/n): n

Model found at C:\Users\harum\AppData\Local\Open Interpreter\Open Interpreter\models\codellama-34b-instruct.Q8_0.gguf

▌ Model set to TheBloke/CodeLlama-34B-Instruct-GGUF

Open Interpreter will require approval before running code. Use interpreter -y to bypass this.

Press CTRL-C to exit.

  import yfinance as yf                                                                                              
  import matplotlib.pyplot as plt                                                                                    

  # Get Apple's stock price                                                                                          
  apple_stock = yf.download('AAPL', start='2010-01-01', end='2023-02-26')                                            

  # Plot the stock price                                                                                             
  plt.plot(apple_stock['Close'])                                                                                     
  plt.title('Apple Stock Price')                                                                                     
  plt.xlabel('Date')                                                                                                 
  plt.ylabel('Price (USD)')                                                                                          
  plt.show()                                                                                                         

  Would you like to run this code? (y/n)

  y

  import yfinance as yf                                                                                              
  import matplotlib.pyplot as plt                                                                                    

  # Get Apple's stock price                                                                                          
  apple_stock = yf.download('AAPL', start='2010-01-01', end='2023-02-26')                                            

  # Plot the stock price                                                                                             
  plt.plot(apple_stock['Close'])                                                                                     
  plt.title('Apple Stock Price')                                                                                     
  plt.xlabel('Date')                                                                                                 
  plt.ylabel('Price (USD)')                                                                                          
  plt.show()█                                                                                                        

  [*********************100%%**********************]  1 of 1 completed                                               
  [<matplotlib.lines.Line2D object at 0x0000020F8698CCD0>]                                                           
  Text(0.5, 1.0, 'Apple Stock Price')                                                                                
  Text(0.5, 0, 'Date')                                                                                               
  Text(0, 0.5, 'Price (USD)')                                                                                        

file

これで、Appleの株価のグラフが生成され、ファイルとして保存されます。

おわりに

これで、Open Interpreterの基本的な導入と使用方法を学ぶことができました。AIの力を活用して、新しいプログラミング体験を楽しんでください。

解説動画

@maki.sunwood.ai.labs

【完全無料】WindowsでOpen Interpreter~みんなのPCにAI導入!Open Interpreterとおしゃべりしながら、プログラミングをしよう~【Llama2】 #OpenInterpreter #Windows #動画配信 #AI #人工知能 #便利ソフト #Llama2 #CodeLlama

♬ オリジナル楽曲 Maki@sunwood.ai.labs

コメント

タイトルとURLをコピーしました