chatter

You, dev
Back

An interactive command-line tool built using Python that enables you to have a conversation with any of OpenAI's CHAT-GPT models, directly from your terminal.

Why chatter?

Since the release of chatGPT and GPT4 by OpenAI, I've been using the gui interface a lot, but there is often downtime when the servers are overloaded. I wanted to have a way to chat with the models without having to wait for the gui to load. And having it in the terminal really speeds up the process. Especially when integrating local files and other scripts, instead of copy pasting to the gui.

How does chatter work?

Chatter is built with Typer, a python library that allows you to build command-line interfaces. It uses the OpenAI API to send requests to the models. Currently models 3.5 and 4 are supported.

By installing a symlink to chatter, you can call chatter from anywhere in your terminal. Like this:

How to call chatter?

chatter

Then you will be prompted to enter your question.

Please enter your question: 
How do I write a recursive function in python?
A recursive function is a function that calls itself as a part of its execution. To write a recursive function in Python, you need to define the function with a base case and a recursive case. The base case is a condition under which the function stops calling itself, and the recursive case is where the function calls itself with an altered input. Here's an example of a recursive function to calculate the factorial of a number:

def factorial(n):
    # Base case: if n is 0 or 1, return 1
    if n == 0 or n == 1:
        return 1

    # Recursive case: return n multiplied by the factorial of n-1
    else:
        return n * factorial(n-1)

# Example usage:
print(factorial(5))  # Output: 120


In this example, the base case is when n is 0 or 1, in which case the function returns 1. The recursive case is when the function returns n times the factorial of n-1, which is a call to the same function with an input of n-1.

After you enter your question, chatter will send a request to the model and return the response. You can then enter another question and the process repeats.

Are you satisfied with the answer? (yes/no):

How to use chatter?

Clone the repository and follow the instructions in the readme.

What's next?

I'm planning of adding more features that let's chatter modify existing files and scripts. I will also spend some time on improving the output so that it's easy to read and understand, especially when the model spits out code.

Contributing

If you have any ideas or suggestions, feel free to open an issue or a pull request.

© Magnus Friberg.RSS