# StacktraceGpt

Helps analyse Elixir/Phoenix stacktraces with help of ChatGPT

## Installation

### Dependencies

If [available in Hex](, the package can be installed
by adding `stacktrace_gpt` to your list of dependencies in `mix.exs`:

def deps do
    {:stacktrace_gpt, "~> 0.1.0", runtime: Mix.env() == :dev, only: :dev}

## Configuration

#### Set OpenAI key in your dev environment

You can get your OpenAI key from, Organization ID you can grab here and set those in your development environment, e.g. in the `.env` file:

  export OPENAI_KEY=sk-...  
then load this file into your environment with `source .env` command.

#### Add Logger backend to dev.exs

config :logger,
  backends: [StacktraceGpt.LoggerBackend, :console]

#### Run mix task


mix stacktrace_gpt.install

This will create `.iex.exs` file in your project root (if doesn't exist) and following code to it:
  # StacktraceGpt - GPT explanation of stacktraces when you have an error in iex console
# just type `gpt` right after you get an error and you will get an explanation from ChatGPT
  defmodule StacktraceGpt.Imports do
    def gpt, do: StacktraceGpt.Server.ask_gpt()
  import StacktraceGpt.Imports
  require Logger"StacktraceGpt is enabled! Type `gpt` after error to get an explanation from ChatGPT")
After this you can run your mix or phoenix project in the interactive console (`iex -S mix` or `iex -S mix phx.server`) and use `gpt` command in your iex console to get an explanation from ChatGPT for the last console error.

Documentation can be generated with [ExDoc](
and published on [HexDocs]( Once published, the docs can
be found at [](

## License

The package is available as open source under the terms of the [MIT License](