Code Monkey home page Code Monkey logo

ipython_llm's Introduction

ipython_llm

The ipython_llm is a library built to integrate the services of OpenAI's Large Language Model (LLM) within the IPython environment. It allows the user to directly i niti ate and maintain a conversation with the model from an IPython interface.

Installation

To install the library, run:

pip install ipython_llm

Setup

To setup:

  1. Install the library.
  2. Get your OpenAI API key and set it as an environment variable.
export OPENAI_API_KEY=your_api_key_goes_here

Usage

After setting up, load the extension in IPython:

%load_ext ipython_llm

Once the extension has been loaded, a couple of magics are offered:

Line magic: %llm_prompt

This magic sends a prompt to the LLM in a single IPython line.

To use the line magic, format :

%llm_prompt [optional parameters] your_prompt_here

The optional parameters include:

  • -t, or --temperature, adjusts the output's randomness. The values range between 0 (fully deterministic) and 1 (maximum randomness).
  • -c, or --clear, resets the conversation status with the model.
  • -m, or --model, specifies another model alias to use.

Example:

%llm_prompt -t 0.5 -c Code to convert list to string in Python

Cell magic: %%llm_prompt_cell - to be implemented

The cell magic allows extended inputs spanning multiple lines.

To use the cell magic, write your prompt across several lines:

%%llm_prompt_cell
Your prompt here.
It can span multiple lines.

You can also include the optional parameters in the first line:

%%llm_prompt_cell -t 0.5 -c
Your prompt goes here.
It can span multiple lines.

In both the line and cell magic, if the LLM's response contains code (formatted with python), it is returned in a new IPython cell, ready to be executed. If there's no code, the model's plain text response is printed.

Version

Current version is 0.0.1

ipython_llm's People

Contributors

dmtr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.