Projects STRLCPY aix Commits e8255156
🤬
  • ■ ■ ■ ■ ■ ■
    .github/dependabot.yml
     1 +# To get started with Dependabot version updates, you'll need to specify which
     2 +# package ecosystems to update and where the package manifests are located.
     3 +# Please see the documentation for all configuration options:
     4 +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
     5 + 
     6 +version: 2
     7 +updates:
     8 + 
     9 + # Maintain dependencies for GitHub Actions
     10 + - package-ecosystem: "github-actions"
     11 + directory: "/"
     12 + schedule:
     13 + interval: "weekly"
     14 + target-branch: "dev"
     15 + commit-message:
     16 + prefix: "chore"
     17 + include: "scope"
     18 + labels:
     19 + - "Type: Maintenance"
     20 + 
     21 + # Maintain dependencies for go modules
     22 + - package-ecosystem: "gomod"
     23 + directory: "/"
     24 + schedule:
     25 + interval: "daily"
     26 + target-branch: "dev"
     27 + commit-message:
     28 + prefix: "chore"
     29 + include: "scope"
     30 + labels:
     31 + - "Type: Maintenance"
     32 + 
     33 + # Maintain dependencies for docker
     34 + - package-ecosystem: "docker"
     35 + directory: "/"
     36 + schedule:
     37 + interval: "weekly"
     38 + target-branch: "dev"
     39 + commit-message:
     40 + prefix: "chore"
     41 + include: "scope"
     42 + labels:
     43 + - "Type: Maintenance"
  • ■ ■ ■ ■ ■ ■
    .github/workflows/build-test.yml
     1 +name: 🔨 Build Test
     2 + 
     3 +on:
     4 + pull_request:
     5 + paths:
     6 + - '**.go'
     7 + - '**.mod'
     8 + workflow_dispatch:
     9 + 
     10 + 
     11 +jobs:
     12 + build:
     13 + name: Test Builds
     14 + runs-on: ${{ matrix.os }}
     15 + strategy:
     16 + matrix:
     17 + os: [ubuntu-latest, windows-latest, macOS-latest]
     18 + steps:
     19 + - name: Set up Go
     20 + uses: actions/setup-go@v4
     21 + with:
     22 + go-version: 1.19
     23 + 
     24 + - name: Check out code
     25 + uses: actions/checkout@v3
     26 + 
     27 + - name: Build
     28 + run: go build .
     29 + working-directory: cmd/aix/
     30 + 
     31 + - name: Test
     32 + run: go test ./...
     33 + working-directory: .
     34 + env:
     35 + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
     36 + 
  • ■ ■ ■ ■ ■ ■
    .github/workflows/codeql-analysis.yml
     1 +name: 🚨 CodeQL Analysis
     2 + 
     3 +on:
     4 + workflow_dispatch:
     5 + pull_request:
     6 + paths:
     7 + - '**.go'
     8 + - '**.mod'
     9 + branches:
     10 + - dev
     11 + 
     12 +jobs:
     13 + analyze:
     14 + name: Analyze
     15 + runs-on: ubuntu-latest-16-cores
     16 + permissions:
     17 + actions: read
     18 + contents: read
     19 + security-events: write
     20 + 
     21 + strategy:
     22 + fail-fast: false
     23 + matrix:
     24 + language: [ 'go' ]
     25 + 
     26 + steps:
     27 + - name: Checkout repository
     28 + uses: actions/checkout@v3
     29 + 
     30 + # Initializes the CodeQL tools for scanning.
     31 + - name: Initialize CodeQL
     32 + uses: github/codeql-action/init@v2
     33 + with:
     34 + languages: ${{ matrix.language }}
     35 + 
     36 + - name: Autobuild
     37 + uses: github/codeql-action/autobuild@v2
     38 + 
     39 + - name: Perform CodeQL Analysis
     40 + uses: github/codeql-action/analyze@v2
  • ■ ■ ■ ■ ■ ■
    .github/workflows/dockerhub-push.yml
     1 +name: 🌥 Docker Push
     2 + 
     3 +on:
     4 + workflow_run:
     5 + workflows: ["🎉 Release Binary"]
     6 + types:
     7 + - completed
     8 + workflow_dispatch:
     9 + 
     10 +jobs:
     11 + docker:
     12 + runs-on: ubuntu-latest-16-cores
     13 + steps:
     14 + - name: Checkout
     15 + uses: actions/checkout@v3
     16 + 
     17 + - name: Get Github tag
     18 + id: meta
     19 + run: |
     20 + curl --silent "https://api.github.com/repos/projectdiscovery/aix/releases/latest" | jq -r .tag_name | xargs -I {} echo TAG={} >> $GITHUB_OUTPUT
     21 + - name: Set up QEMU
     22 + uses: docker/setup-qemu-action@v2
     23 + 
     24 + - name: Set up Docker Buildx
     25 + uses: docker/setup-buildx-action@v2
     26 + 
     27 + - name: Login to DockerHub
     28 + uses: docker/login-action@v2
     29 + with:
     30 + username: ${{ secrets.DOCKER_USERNAME }}
     31 + password: ${{ secrets.DOCKER_TOKEN }}
     32 + 
     33 + - name: Build and push
     34 + uses: docker/build-push-action@v4
     35 + with:
     36 + context: .
     37 + platforms: linux/amd64,linux/arm64,linux/arm
     38 + push: true
     39 + tags: projectdiscovery/aix:latest,projectdiscovery/aix:${{ steps.meta.outputs.TAG }}
  • ■ ■ ■ ■ ■ ■
    .github/workflows/lint-test.yml
     1 +name: 🙏🏻 Lint Test
     2 + 
     3 +on:
     4 + pull_request:
     5 + paths:
     6 + - '**.go'
     7 + - '**.mod'
     8 + workflow_dispatch:
     9 + 
     10 +jobs:
     11 + lint:
     12 + name: Lint Test
     13 + runs-on: ubuntu-latest
     14 + steps:
     15 + - name: Set up Go
     16 + uses: actions/setup-go@v4
     17 + with:
     18 + go-version: 1.19
     19 + - name: Checkout code
     20 + uses: actions/checkout@v3
     21 + - name: Run golangci-lint
     22 + uses: golangci/[email protected]
     23 + with:
     24 + version: latest
     25 + args: --timeout 5m
     26 + working-directory: .
  • ■ ■ ■ ■ ■ ■
    .github/workflows/release-binary.yml
     1 +name: 🎉 Release Binary
     2 + 
     3 +on:
     4 + push:
     5 + tags:
     6 + - '*'
     7 + workflow_dispatch:
     8 + 
     9 +jobs:
     10 + release:
     11 + runs-on: ubuntu-latest-16-cores
     12 + steps:
     13 + - name: "Check out code"
     14 + uses: actions/checkout@v3
     15 + with:
     16 + fetch-depth: 0
     17 +
     18 + - name: "Set up Go"
     19 + uses: actions/setup-go@v4
     20 + with:
     21 + go-version: 1.19
     22 +
     23 + - name: "Create release on GitHub"
     24 + uses: goreleaser/goreleaser-action@v4
     25 + with:
     26 + args: "release --rm-dist"
     27 + version: latest
     28 + workdir: .
     29 + env:
     30 + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
     31 + SLACK_WEBHOOK: "${{ secrets.RELEASE_SLACK_WEBHOOK }}"
     32 + DISCORD_WEBHOOK_ID: "${{ secrets.DISCORD_WEBHOOK_ID }}"
     33 + DISCORD_WEBHOOK_TOKEN: "${{ secrets.DISCORD_WEBHOOK_TOKEN }}"
  • ■ ■ ■ ■ ■ ■
    .gitignore
     1 +# If you prefer the allow list template instead of the deny list, see community template:
     2 +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
     3 +#
     4 +# Binaries for programs and plugins
     5 +*.exe
     6 +*.exe~
     7 +*.dll
     8 +*.so
     9 +*.dylib
     10 + 
     11 +# Test binary, built with `go test -c`
     12 +*.test
     13 + 
     14 +# Output of the go coverage tool, specifically when used with LiteIDE
     15 +*.out
     16 + 
     17 +# Dependency directories (remove the comment below to include it)
     18 +# vendor/
     19 +dist/
     20 +aix
     21 +# Go workspace file
     22 +go.work
     23 + 
     24 +.vscode/*
     25 +!.vscode/settings.json
     26 +!.vscode/tasks.json
     27 +!.vscode/launch.json
     28 +!.vscode/extensions.json
     29 +!.vscode/*.code-snippets
     30 + 
     31 +# Local History for Visual Studio Code
     32 +.history/
     33 + 
     34 +# Built Visual Studio Code Extensions
     35 +*.vsix
     36 + 
     37 +.devcontainer/*
  • ■ ■ ■ ■ ■ ■
    .goreleaser.yml
     1 +before:
     2 + hooks:
     3 + - go mod tidy
     4 + 
     5 +builds:
     6 +- env:
     7 + - CGO_ENABLED=0
     8 + goos:
     9 + - windows
     10 + - linux
     11 + - darwin
     12 + goarch:
     13 + - amd64
     14 + - 386
     15 + - arm
     16 + - arm64
     17 + 
     18 + binary: '{{ .ProjectName }}'
     19 + main: cmd/aix/main.go
     20 + 
     21 +archives:
     22 +- format: zip
     23 + replacements:
     24 + darwin: macOS
     25 + 
     26 +checksum:
     27 + algorithm: sha256
     28 + 
     29 +announce:
     30 + slack:
     31 + enabled: true
     32 + channel: '#release'
     33 + username: GoReleaser
     34 + message_template: 'New Release: {{ .ProjectName }} {{ .Tag }} is published! Check it out at {{ .ReleaseURL }}'
     35 + 
     36 + discord:
     37 + enabled: true
     38 + message_template: '**New Release: {{ .ProjectName }} {{.Tag}}** is published! Check it out at {{ .ReleaseURL }}'
  • ■ ■ ■ ■ ■ ■
    Dockerfile
     1 +# Base
     2 +FROM golang:1.20.2-alpine AS builder
     3 + 
     4 +RUN apk add --no-cache git build-base
     5 +WORKDIR /app
     6 +COPY . /app
     7 +RUN go mod download
     8 +RUN go build ./cmd/aix
     9 + 
     10 +FROM alpine:3.17.2
     11 +RUN apk -U upgrade --no-cache \
     12 + && apk add --no-cache bind-tools ca-certificates
     13 +COPY --from=builder /app/aix /usr/local/bin/
     14 + 
     15 +ENTRYPOINT ["aix"]
  • ■ ■ ■ ■ ■ ■
    LICENSE.md
     1 +MIT License
     2 + 
     3 +Copyright (c) 2023 ProjectDiscovery
     4 + 
     5 +Permission is hereby granted, free of charge, to any person obtaining a copy
     6 +of this software and associated documentation files (the "Software"), to deal
     7 +in the Software without restriction, including without limitation the rights
     8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     9 +copies of the Software, and to permit persons to whom the Software is
     10 +furnished to do so, subject to the following conditions:
     11 + 
     12 +The above copyright notice and this permission notice shall be included in all
     13 +copies or substantial portions of the Software.
     14 + 
     15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     21 +SOFTWARE.
     22 + 
  • ■ ■ ■ ■ ■ ■
    README.md
     1 +<h1 align="center">
     2 + AIx
     3 +<br>
     4 +</h1>
     5 + 
     6 + 
     7 +<p align="center">
     8 +<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-_red.svg"></a>
     9 +<a href="https://goreportcard.com/badge/github.com/projectdiscovery/aix"><img src="https://goreportcard.com/badge/github.com/projectdiscovery/aix"></a>
     10 +<a href="https://pkg.go.dev/github.com/projectdiscovery/aix/pkg/aix"><img src="https://img.shields.io/badge/go-reference-blue"></a>
     11 +<a href="https://github.com/projectdiscovery/aix/releases"><img src="https://img.shields.io/github/release/projectdiscovery/aix"></a>
     12 +<a href="https://twitter.com/pdiscoveryio"><img src="https://img.shields.io/twitter/follow/pdiscoveryio.svg?logo=twitter"></a>
     13 +<a href="https://discord.gg/projectdiscovery"><img src="https://img.shields.io/discord/695645237418131507.svg?logo=discord"></a>
     14 +</p>
     15 + 
     16 +<p align="center">
     17 + <a href="#features">Features</a> •
     18 + <a href="#installation">Installation</a> •
     19 + <a href="#help-menu">Usage</a> •
     20 + <a href="#examples">Running AIx</a> •
     21 + <a href="https://discord.gg/projectdiscovery">Join Discord</a>
     22 + 
     23 +</p>
     24 + 
     25 +<pre align="center">
     26 +<b>
     27 + AIx is a cli tool to interact with Large Language Models (LLM) APIs.
     28 +</b>
     29 +</pre>
     30 + 
     31 +![image](https://user-images.githubusercontent.com/8293321/227775051-440d4ed5-f30e-4ec5-bf1d-10310840ab54.png)
     32 + 
     33 +## Features
     34 +- **AMA with AI** over **CLI**
     35 +- **Query LLM APIs** (OpenAI)
     36 +- Supports **GPT-3.5 and GPT-4.0** models
     37 +- Configurable with OpenAI API key
     38 +- Flexible output options
     39 + 
     40 +## Installation
     41 +To install aix, you need to have Golang 1.19 installed on your system. You can download Golang from [here](https://go.dev/doc/install). After installing Golang, you can use the following command to install aix:
     42 + 
     43 + 
     44 +```bash
     45 +go install github.com/projectdiscovery/aix/cmd/aix@latest
     46 +```
     47 + 
     48 +## Prerequisite
     49 + 
     50 +> **Note**: Before using aix, make sure to set your [OpenAI API key](https://platform.openai.com/account/api-keys) as an environment variable `OPENAI_API_KEY`.
     51 + 
     52 +```bash
     53 +export OPENAI_API_KEY=******
     54 +````
     55 + 
     56 +## Help Menu
     57 +You can use the following command to see the available flags and options:
     58 + 
     59 +```console
     60 +bash
     61 +AIx is a cli tool to interact with Large Language Model (LLM) APIs.
     62 + 
     63 +Usage:
     64 + ./aix [flags]
     65 + 
     66 +Flags:
     67 +INPUT:
     68 + -p, -prompt string prompt to query (input: stdin,string,file)
     69 + 
     70 +MODEL:
     71 + -g3, -gpt3 use GPT-3.5 model (default true)
     72 + -g4, -gpt4 use GPT-4.0 model
     73 + 
     74 +CONFIG:
     75 + -ak, -openai-api-key string openai api key token (input: string,file,env)
     76 + 
     77 +UPDATE:
     78 + -up, -update update aix to latest version
     79 + -duc, -disable-update-check disable automatic aix update check
     80 + 
     81 +OUTPUT:
     82 + -o, -output string file to write output to
     83 + -j, -jsonl write output in json(line) format
     84 + -v, -verbose verbose mode
     85 + -silent display silent output
     86 + -nc, -no-color disable colors in cli output
     87 + -version display project version
     88 +```
     89 + 
     90 +## Examples
     91 + 
     92 +You can use aix to interact with LLM (OpenAI) APIs to query anything and everything in your CLI by specifying the prompts. Here are some examples:
     93 + 
     94 +### Example 1: Query LLM with a prompt
     95 + 
     96 +```bash
     97 +aix -p "What is the capital of France?"
     98 +```
     99 + 
     100 +### Example 2: Query with GPT-4.0 model
     101 +```bash
     102 +aix -p "How to install Linux?" -g4
     103 +```
     104 + 
     105 +### Example 3: Query LLM API with a prompt with STDIN input
     106 + 
     107 +```console
     108 +echo list top trending web technologies | aix
     109 + 
     110 + ___ _____ __
     111 + / _ | / _/ |/_/
     112 + / __ |_/ /_> <
     113 +/_/ |_/___/_/|_| Powered by OpenAI
     114 + 
     115 + projectdiscovery.io
     116 + 
     117 +[INF] Current aix version v0.0.1 (latest)
     118 +1. Artificial Intelligence (AI) and Machine Learning (ML)
     119 +2. Internet of Things (IoT)
     120 +3. Progressive Web Apps (PWA)
     121 +4. Voice search and virtual assistants
     122 +5. Mobile-first design and development
     123 +6. Blockchain and distributed ledger technology
     124 +7. Augmented Reality (AR) and Virtual Reality (VR)
     125 +8. Chatbots and conversational interfaces
     126 +9. Serverless architecture and cloud computing
     127 +10. Cybersecurity and data protection
     128 +11. Mobile wallets and payment gateways
     129 +12. Responsive web design and development
     130 +13. Social media integration and sharing options
     131 +14. Accelerated Mobile Pages (AMP)
     132 +15. Content Management Systems (CMS) and static site generators
     133 + 
     134 +Note: These technologies are constantly changing and evolving, so this list is subject to change over time.
     135 +```
     136 + 
     137 +### Example 3: Query LLM API with a prompt and save the output to a file in JSONLine format.
     138 +```console
     139 +aix -p "What is the capital of France?" -jsonl -o output.txt | jq .
     140 + 
     141 + ___ _____ __
     142 + / _ | / _/ |/_/
     143 + / __ |_/ /_> <
     144 +/_/ |_/___/_/|_| Powered by OpenAI
     145 + 
     146 + projectdiscovery.io
     147 + 
     148 +[INF] Current aix version v0.0.1 (latest)
     149 +{
     150 + "timestamp": "2023-03-26 17:55:42.707436 +0530 IST m=+1.512222751",
     151 + "prompt": "What is the capital of France?",
     152 + "completion": "Paris.",
     153 + "model": "gpt-3.5-turbo"
     154 +}
     155 +```
     156 + 
     157 +### Example 3: Query LLM API in verbose mode
     158 +```console
     159 +aix -p "What is the capital of France?" -v
     160 + 
     161 + ___ _____ __
     162 + / _ | / _/ |/_/
     163 + / __ |_/ /_> <
     164 +/_/ |_/___/_/|_| Powered by OpenAI
     165 + 
     166 + projectdiscovery.io
     167 + 
     168 +[INF] Current aix version v0.0.1 (latest)
     169 +[VER] [prompt] What is the capital of France?
     170 +[VER] [completion] The capital of France is Paris.
     171 +```
     172 + 
     173 +For more information on the usage of aix, please refer to the help menu with the `aix -h` flag.
     174 + 
     175 +## Acknowledgements
     176 + 
     177 +- [OpenAI](https://platform.openai.com/docs/introduction) for publishing LLM APIs.
     178 +- [sashabaranov](https://github.com/sashabaranov) for building and maintaining [go-openai](https://github.com/sashabaranov/go-openai) library.
     179 + 
     180 +--------
     181 + 
     182 +<div align="center">
     183 + 
     184 +**aix** is made with ❤️ by the [projectdiscovery](https://projectdiscovery.io) team and distributed under [MIT License](LICENSE.md).
     185 + 
     186 + 
     187 +<a href="https://discord.gg/projectdiscovery"><img src="https://raw.githubusercontent.com/projectdiscovery/nuclei-burp-plugin/main/static/join-discord.png" width="300" alt="Join Discord"></a>
     188 + 
     189 +</div>
     190 + 
  • ■ ■ ■ ■ ■ ■
    cmd/aix/main.go
     1 +package main
     2 + 
     3 +import (
     4 + "fmt"
     5 + "os"
     6 + "os/signal"
     7 + "syscall"
     8 + 
     9 + "github.com/logrusorgru/aurora"
     10 + "github.com/projectdiscovery/aix/internal/runner"
     11 + "github.com/projectdiscovery/gologger"
     12 +)
     13 + 
     14 +func main() {
     15 + options := runner.ParseOptions()
     16 + aixRunner, err := runner.NewRunner(options)
     17 + if err != nil {
     18 + gologger.Fatal().Msgf("Could not create runner: %s\n", err)
     19 + }
     20 + 
     21 + result, err := aixRunner.Run()
     22 + if err != nil {
     23 + gologger.Fatal().Msgf("Could not run aix: %s\n", err)
     24 + }
     25 + 
     26 + if options.Jsonl {
     27 + gologger.DefaultLogger.Print().Msg(result.JSON())
     28 + if options.Output != "" {
     29 + if err := os.WriteFile(options.Output, []byte(result.JSON()), 0644); err != nil {
     30 + gologger.Error().Msgf("failed to save output to file %v got %v", options.Output, err)
     31 + }
     32 + return
     33 + }
     34 + } else if options.Verbose {
     35 + aurora := aurora.NewAurora(!options.NoColor)
     36 + gologger.DefaultLogger.Print().Msgf("[%v] %v", aurora.BrightYellow("Prompt"), result.Prompt)
     37 + gologger.DefaultLogger.Print().Msgf("[%v] %v", aurora.BrightGreen("Completion"), result.Completion)
     38 + } else {
     39 + gologger.DefaultLogger.Print().Msg(result.Completion)
     40 + }
     41 + if options.Output != "" {
     42 + if err := os.WriteFile(options.Output, []byte(result.Completion), 0644); err != nil {
     43 + gologger.Error().Msgf("failed to save output to file %v got %v", options.Output, err)
     44 + }
     45 + }
     46 +}
     47 + 
     48 +func init() {
     49 + c := make(chan os.Signal, 1)
     50 + signal.Notify(c, os.Interrupt, syscall.SIGTERM)
     51 + // Setup close handler
     52 + go func() {
     53 + <-c
     54 + fmt.Println("\r- Ctrl+C pressed in Terminal, Exiting...")
     55 + os.Exit(0)
     56 + }()
     57 +}
     58 + 
  • ■ ■ ■ ■ ■ ■
    go.mod
     1 +module github.com/projectdiscovery/aix
     2 + 
     3 +go 1.19
     4 + 
     5 +require (
     6 + github.com/logrusorgru/aurora v2.0.3+incompatible
     7 + github.com/projectdiscovery/goflags v0.1.8
     8 + github.com/projectdiscovery/gologger v1.1.8
     9 + github.com/projectdiscovery/utils v0.0.17
     10 + github.com/sashabaranov/go-openai v1.5.7
     11 +)
     12 + 
     13 +require (
     14 + aead.dev/minisign v0.2.0 // indirect
     15 + github.com/Masterminds/semver/v3 v3.2.0 // indirect
     16 + github.com/VividCortex/ewma v1.2.0 // indirect
     17 + github.com/alecthomas/chroma v0.10.0 // indirect
     18 + github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
     19 + github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
     20 + github.com/aymerick/douceur v0.2.0 // indirect
     21 + github.com/charmbracelet/glamour v0.6.0 // indirect
     22 + github.com/cheggaaa/pb/v3 v3.1.2 // indirect
     23 + github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 // indirect
     24 + github.com/dlclark/regexp2 v1.8.1 // indirect
     25 + github.com/dsnet/compress v0.0.1 // indirect
     26 + github.com/fatih/color v1.14.1 // indirect
     27 + github.com/golang/protobuf v1.5.2 // indirect
     28 + github.com/golang/snappy v0.0.1 // indirect
     29 + github.com/google/go-github/v30 v30.1.0 // indirect
     30 + github.com/google/go-querystring v1.1.0 // indirect
     31 + github.com/gorilla/css v1.0.0 // indirect
     32 + github.com/json-iterator/go v1.1.12 // indirect
     33 + github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
     34 + github.com/mattn/go-colorable v0.1.13 // indirect
     35 + github.com/mattn/go-isatty v0.0.17 // indirect
     36 + github.com/mattn/go-runewidth v0.0.14 // indirect
     37 + github.com/mholt/archiver v3.1.1+incompatible // indirect
     38 + github.com/microcosm-cc/bluemonday v1.0.23 // indirect
     39 + github.com/miekg/dns v1.1.50 // indirect
     40 + github.com/minio/selfupdate v0.6.0 // indirect
     41 + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
     42 + github.com/modern-go/reflect2 v1.0.2 // indirect
     43 + github.com/muesli/reflow v0.3.0 // indirect
     44 + github.com/muesli/termenv v0.15.1 // indirect
     45 + github.com/nwaples/rardecode v1.1.0 // indirect
     46 + github.com/olekukonko/tablewriter v0.0.5 // indirect
     47 + github.com/pierrec/lz4 v2.6.0+incompatible // indirect
     48 + github.com/pkg/errors v0.9.1 // indirect
     49 + github.com/rivo/uniseg v0.4.4 // indirect
     50 + github.com/rogpeppe/go-internal v1.9.0 // indirect
     51 + github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
     52 + github.com/ulikunitz/xz v0.5.8 // indirect
     53 + github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
     54 + github.com/yuin/goldmark v1.5.4 // indirect
     55 + github.com/yuin/goldmark-emoji v1.0.1 // indirect
     56 + golang.org/x/crypto v0.7.0 // indirect
     57 + golang.org/x/exp v0.0.0-20221019170559-20944726eadf // indirect
     58 + golang.org/x/mod v0.8.0 // indirect
     59 + golang.org/x/net v0.8.0 // indirect
     60 + golang.org/x/oauth2 v0.5.0 // indirect
     61 + golang.org/x/sys v0.6.0 // indirect
     62 + golang.org/x/tools v0.6.0 // indirect
     63 + google.golang.org/appengine v1.6.7 // indirect
     64 + google.golang.org/protobuf v1.28.1 // indirect
     65 + gopkg.in/djherbis/times.v1 v1.3.0 // indirect
     66 + gopkg.in/yaml.v3 v3.0.1 // indirect
     67 +)
     68 + 
  • ■ ■ ■ ■ ■ ■
    go.sum
     1 +aead.dev/minisign v0.2.0 h1:kAWrq/hBRu4AARY6AlciO83xhNnW9UaC8YipS2uhLPk=
     2 +aead.dev/minisign v0.2.0/go.mod h1:zdq6LdSd9TbuSxchxwhpA9zEb9YXcVGoE8JakuiGaIQ=
     3 +github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g=
     4 +github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
     5 +github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow=
     6 +github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4=
     7 +github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
     8 +github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
     9 +github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ=
     10 +github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
     11 +github.com/aymanbagabas/go-osc52 v1.0.3/go.mod h1:zT8H+Rk4VSabYN90pWyugflM3ZhpTZNC7cASDfUCdT4=
     12 +github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
     13 +github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
     14 +github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
     15 +github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
     16 +github.com/charmbracelet/glamour v0.6.0 h1:wi8fse3Y7nfcabbbDuwolqTqMQPMnVPeZhDM273bISc=
     17 +github.com/charmbracelet/glamour v0.6.0/go.mod h1:taqWV4swIMMbWALc0m7AfE9JkPSU8om2538k9ITBxOc=
     18 +github.com/cheggaaa/pb/v3 v3.1.2 h1:FIxT3ZjOj9XJl0U4o2XbEhjFfZl7jCVCDOGq1ZAB7wQ=
     19 +github.com/cheggaaa/pb/v3 v3.1.2/go.mod h1:SNjnd0yKcW+kw0brSusraeDd5Bf1zBfxAzTL2ss3yQ4=
     20 +github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 h1:ox2F0PSMlrAAiAdknSRMDrAr8mfxPCfSZolH+/qQnyQ=
     21 +github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08/go.mod h1:pCxVEbcm3AMg7ejXyorUXi6HQCzOIBf7zEDVPtw0/U4=
     22 +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
     23 +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
     24 +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
     25 +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
     26 +github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
     27 +github.com/dlclark/regexp2 v1.8.1 h1:6Lcdwya6GjPUNsBct8Lg/yRPwMhABj269AAzdGSiR+0=
     28 +github.com/dlclark/regexp2 v1.8.1/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
     29 +github.com/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q=
     30 +github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5JflhBbQEHo=
     31 +github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
     32 +github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=
     33 +github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg=
     34 +github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY=
     35 +github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
     36 +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
     37 +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
     38 +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
     39 +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
     40 +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
     41 +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
     42 +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
     43 +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
     44 +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
     45 +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
     46 +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
     47 +github.com/google/go-github/v30 v30.1.0 h1:VLDx+UolQICEOKu2m4uAoMti1SxuEBAl7RSEG16L+Oo=
     48 +github.com/google/go-github/v30 v30.1.0/go.mod h1:n8jBpHl45a/rlBUtRJMOG4GhNADUQFEufcolZ95JfU8=
     49 +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
     50 +github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
     51 +github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
     52 +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
     53 +github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
     54 +github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
     55 +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
     56 +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
     57 +github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
     58 +github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
     59 +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
     60 +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
     61 +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
     62 +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
     63 +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
     64 +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
     65 +github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
     66 +github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
     67 +github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
     68 +github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
     69 +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
     70 +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
     71 +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
     72 +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
     73 +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
     74 +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
     75 +github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
     76 +github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
     77 +github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
     78 +github.com/mholt/archiver v3.1.1+incompatible h1:1dCVxuqs0dJseYEhi5pl7MYPH9zDa1wBi7mF09cbNkU=
     79 +github.com/mholt/archiver v3.1.1+incompatible/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU=
     80 +github.com/microcosm-cc/bluemonday v1.0.21/go.mod h1:ytNkv4RrDrLJ2pqlsSI46O6IVXmZOBBD4SaJyDwwTkM=
     81 +github.com/microcosm-cc/bluemonday v1.0.23 h1:SMZe2IGa0NuHvnVNAZ+6B38gsTbi5e4sViiWJyDDqFY=
     82 +github.com/microcosm-cc/bluemonday v1.0.23/go.mod h1:mN70sk7UkkF8TUr2IGBpNN0jAgStuPzlK76QuruE/z4=
     83 +github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA=
     84 +github.com/miekg/dns v1.1.50/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME=
     85 +github.com/minio/selfupdate v0.6.0 h1:i76PgT0K5xO9+hjzKcacQtO7+MjJ4JKA8Ak8XQ9DDwU=
     86 +github.com/minio/selfupdate v0.6.0/go.mod h1:bO02GTIPCMQFTEvE5h4DjYB58bCoZ35XLeBf0buTDdM=
     87 +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
     88 +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
     89 +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
     90 +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
     91 +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
     92 +github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
     93 +github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
     94 +github.com/muesli/termenv v0.13.0/go.mod h1:sP1+uffeLaEYpyOTb8pLCUctGcGLnoFjSn4YJK5e2bc=
     95 +github.com/muesli/termenv v0.15.1 h1:UzuTb/+hhlBugQz28rpzey4ZuKcZ03MeKsoG7IJZIxs=
     96 +github.com/muesli/termenv v0.15.1/go.mod h1:HeAQPTzpfs016yGtA4g00CsdYnVLJvxsS4ANqrZs2sQ=
     97 +github.com/nwaples/rardecode v1.1.0 h1:vSxaY8vQhOcVr4mm5e8XllHWTiM4JF507A0Katqw7MQ=
     98 +github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
     99 +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
     100 +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
     101 +github.com/pierrec/lz4 v2.6.0+incompatible h1:Ix9yFKn1nSPBLFl/yZknTp8TU5G4Ps0JDmguYK6iH1A=
     102 +github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
     103 +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
     104 +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
     105 +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
     106 +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
     107 +github.com/projectdiscovery/goflags v0.1.8 h1:Urhm2Isq2BdRt8h4h062lHKYXO65RHRjGTDSkUwex/g=
     108 +github.com/projectdiscovery/goflags v0.1.8/go.mod h1:Yxi9tclgwGczzDU65ntrwaIql5cXeTvW5j2WxFuF+Jk=
     109 +github.com/projectdiscovery/gologger v1.1.8 h1:CFlCzGlqAhPqWIrAXBt1OVh5jkMs1qgoR/z4xhdzLNE=
     110 +github.com/projectdiscovery/gologger v1.1.8/go.mod h1:bNyVaC1U/NpJtFkJltcesn01NR3K8Hg6RsLVce6yvrw=
     111 +github.com/projectdiscovery/utils v0.0.17 h1:Y/uj8wAI1/a9UtWwDTBCBgsc2RicLUhrhcbCCsC7nrM=
     112 +github.com/projectdiscovery/utils v0.0.17/go.mod h1:Cu216AlQ7rAYa8aDBqB2OgNfu5p24Uj+tG9RxV8Wbfs=
     113 +github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
     114 +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
     115 +github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
     116 +github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
     117 +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
     118 +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
     119 +github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI=
     120 +github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU=
     121 +github.com/sashabaranov/go-openai v1.5.7 h1:8DGgRG+P7yWixte5j720y6yiXgY3Hlgcd0gcpHdltfo=
     122 +github.com/sashabaranov/go-openai v1.5.7/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
     123 +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
     124 +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
     125 +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
     126 +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
     127 +github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
     128 +github.com/ulikunitz/xz v0.5.7/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
     129 +github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ=
     130 +github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
     131 +github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
     132 +github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
     133 +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
     134 +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
     135 +github.com/yuin/goldmark v1.5.2/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
     136 +github.com/yuin/goldmark v1.5.4 h1:2uY/xC0roWy8IBEGLgB1ywIoEJFGmRrX21YQcvGZzjU=
     137 +github.com/yuin/goldmark v1.5.4/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
     138 +github.com/yuin/goldmark-emoji v1.0.1 h1:ctuWEyzGBwiucEqxzwe0SOYDXPAucOrE9NQC18Wa1os=
     139 +github.com/yuin/goldmark-emoji v1.0.1/go.mod h1:2w1E6FEWLcDQkoTE+7HU6QF1F6SLlNGjRIBbIZQFqkQ=
     140 +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
     141 +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
     142 +golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
     143 +golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
     144 +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
     145 +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
     146 +golang.org/x/exp v0.0.0-20221019170559-20944726eadf h1:nFVjjKDgNY37+ZSYCJmtYf7tOlfQswHqplG2eosjOMg=
     147 +golang.org/x/exp v0.0.0-20221019170559-20944726eadf/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
     148 +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
     149 +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
     150 +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
     151 +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
     152 +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
     153 +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
     154 +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
     155 +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
     156 +golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
     157 +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
     158 +golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
     159 +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
     160 +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
     161 +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
     162 +golang.org/x/oauth2 v0.5.0 h1:HuArIo48skDwlrvM3sEdHXElYslAMsf3KwRkkW4MC4s=
     163 +golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I=
     164 +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
     165 +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
     166 +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
     167 +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
     168 +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
     169 +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
     170 +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
     171 +golang.org/x/sys v0.0.0-20210228012217-479acdf4ea46/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
     172 +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
     173 +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
     174 +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
     175 +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
     176 +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
     177 +golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
     178 +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
     179 +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
     180 +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
     181 +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
     182 +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
     183 +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
     184 +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
     185 +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
     186 +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
     187 +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
     188 +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
     189 +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
     190 +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
     191 +golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
     192 +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
     193 +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
     194 +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
     195 +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
     196 +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
     197 +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
     198 +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
     199 +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
     200 +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
     201 +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
     202 +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
     203 +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
     204 +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
     205 +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
     206 +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
     207 +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
     208 +gopkg.in/djherbis/times.v1 v1.3.0 h1:uxMS4iMtH6Pwsxog094W0FYldiNnfY/xba00vq6C2+o=
     209 +gopkg.in/djherbis/times.v1 v1.3.0/go.mod h1:AQlg6unIsrsCEdQYhTzERy542dz6SFdQFZFv6mUY0P8=
     210 +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
     211 +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
     212 +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
     213 +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
     214 + 
  • ■ ■ ■ ■ ■ ■
    internal/runner/banner.go
     1 +package runner
     2 + 
     3 +import (
     4 + "github.com/projectdiscovery/gologger"
     5 + updateutils "github.com/projectdiscovery/utils/update"
     6 +)
     7 + 
     8 +const version = "v0.0.1"
     9 + 
     10 +var banner = (`
     11 + ___ _____ __
     12 + / _ | / _/ |/_/
     13 + / __ |_/ /_> <
     14 +/_/ |_/___/_/|_| Powered by OpenAI
     15 + 
     16 + projectdiscovery.io
     17 +`)
     18 + 
     19 +// showBanner is used to show the banner to the user
     20 +func showBanner() {
     21 + gologger.Print().Msgf("%s\n", banner)
     22 +}
     23 + 
     24 +// GetUpdateCallback returns a callback function that updates aix
     25 +func GetUpdateCallback() func() {
     26 + return func() {
     27 + showBanner()
     28 + updateutils.GetUpdateToolCallback("aix", version)()
     29 + }
     30 +}
     31 + 
  • ■ ■ ■ ■ ■ ■
    internal/runner/options.go
     1 +package runner
     2 + 
     3 +import (
     4 + "io"
     5 + "os"
     6 + "path/filepath"
     7 + "strings"
     8 + 
     9 + "github.com/projectdiscovery/goflags"
     10 + "github.com/projectdiscovery/gologger"
     11 + "github.com/projectdiscovery/gologger/formatter"
     12 + "github.com/projectdiscovery/gologger/levels"
     13 + fileutil "github.com/projectdiscovery/utils/file"
     14 + updateutils "github.com/projectdiscovery/utils/update"
     15 +)
     16 + 
     17 +var (
     18 + // retrieve home directory or fail
     19 + homeDir = func() string {
     20 + home, err := os.UserHomeDir()
     21 + if err != nil {
     22 + gologger.Fatal().Msgf("Failed to get user home directory: %s", err)
     23 + }
     24 + return home
     25 + }()
     26 + 
     27 + defaultConfigLocation = filepath.Join(homeDir, ".config/aix/config.yaml")
     28 +)
     29 + 
     30 +// Options contains the configuration options for tuning the enumeration process.
     31 +type Options struct {
     32 + OpenaiApiKey string `yaml:"openai_api_key"`
     33 + Prompt string `yaml:"prompt"`
     34 + Gpt3 bool `yaml:"gpt3"`
     35 + Gpt4 bool `yaml:"gpt4"`
     36 + Update bool `yaml:"update"`
     37 + DisableUpdateCheck bool `yaml:"disable_update_check"`
     38 + Output string `yaml:"output"`
     39 + Jsonl bool `yaml:"jsonl"`
     40 + Verbose bool `yaml:"verbose"`
     41 + Silent bool `yaml:"silent"`
     42 + NoColor bool `yaml:"no_color"`
     43 + Version bool `yaml:"version"`
     44 +}
     45 + 
     46 +// ParseOptions parses the command line flags provided by a user
     47 +func ParseOptions() *Options {
     48 + options := &Options{}
     49 + 
     50 + flagSet := goflags.NewFlagSet()
     51 + 
     52 + flagSet.SetDescription(`AIx is a cli tool to interact with Large Language Model (LLM) APIs.`)
     53 + 
     54 + flagSet.CreateGroup("input", "Input",
     55 + flagSet.StringVarP(&options.Prompt, "prompt", "p", "", "prompt to query (input: stdin,string,file)"),
     56 + )
     57 + 
     58 + flagSet.CreateGroup("model", "Model",
     59 + flagSet.BoolVarP(&options.Gpt3, "gpt3", "g3", true, "use GPT-3.5 model"),
     60 + flagSet.BoolVarP(&options.Gpt4, "gpt4", "g4", false, "use GPT-4.0 model"),
     61 + )
     62 + 
     63 + flagSet.CreateGroup("config", "Config",
     64 + flagSet.StringVarP(&options.OpenaiApiKey, "openai-api-key", "ak", "", "openai api key token (input: string,file,env)"),
     65 + )
     66 + 
     67 + flagSet.CreateGroup("update", "Update",
     68 + flagSet.BoolVarP(&options.Update, "update", "up", false, "update aix to latest version"),
     69 + flagSet.BoolVarP(&options.DisableUpdateCheck, "disable-update-check", "duc", false, "disable automatic aix update check"),
     70 + )
     71 + 
     72 + flagSet.CreateGroup("output", "Output",
     73 + flagSet.StringVarP(&options.Output, "output", "o", "", "file to write output to"),
     74 + flagSet.BoolVarP(&options.Jsonl, "jsonl", "j", false, "write output in json(line) format"),
     75 + flagSet.BoolVarP(&options.Verbose, "verbose", "v", false, "verbose mode"),
     76 + flagSet.BoolVar(&options.Silent, "silent", false, "display silent output"),
     77 + flagSet.BoolVarP(&options.NoColor, "no-color", "nc", false, "disable colors in cli output"),
     78 + flagSet.BoolVar(&options.Version, "version", false, "display project version"),
     79 + )
     80 + 
     81 + if err := flagSet.Parse(); err != nil {
     82 + gologger.Fatal().Msgf("%s\n", err)
     83 + }
     84 + 
     85 + if fileutil.HasStdin() {
     86 + bin, err := io.ReadAll(os.Stdin)
     87 + if err != nil {
     88 + gologger.Fatal().Msgf("couldn't read stdin: %s\n", err)
     89 + }
     90 + options.Prompt = string(bin)
     91 + }
     92 + 
     93 + if options.Prompt == "" {
     94 + options.Prompt = strings.Join(flagSet.CommandLine.Args(), " ")
     95 + }
     96 + 
     97 + options.configureOutput()
     98 + 
     99 + showBanner()
     100 + 
     101 + if options.Version {
     102 + gologger.Info().Msgf("Current Version: %s\n", version)
     103 + os.Exit(0)
     104 + }
     105 + 
     106 + if options.OpenaiApiKey == "" {
     107 + if key, exists := os.LookupEnv("OPENAI_API_KEY"); exists {
     108 + options.OpenaiApiKey = key
     109 + }
     110 + }
     111 + 
     112 + if options.OpenaiApiKey == "" {
     113 + _ = options.loadConfigFrom(defaultConfigLocation)
     114 + }
     115 + 
     116 + if !options.DisableUpdateCheck {
     117 + latestVersion, err := updateutils.GetVersionCheckCallback("aix")()
     118 + if err != nil {
     119 + if options.Verbose {
     120 + gologger.Error().Msgf("aix version check failed: %v", err.Error())
     121 + }
     122 + } else {
     123 + gologger.Info().Msgf("Current aix version %v %v", version, updateutils.GetVersionDescription(version, latestVersion))
     124 + }
     125 + }
     126 + 
     127 + return options
     128 +}
     129 + 
     130 +// configureOutput configures the output on the screen
     131 +func (options *Options) configureOutput() {
     132 + // If the user desires verbose output, show verbose output
     133 + if options.NoColor {
     134 + gologger.DefaultLogger.SetFormatter(formatter.NewCLI(true))
     135 + }
     136 + if options.Silent {
     137 + gologger.DefaultLogger.SetMaxLevel(levels.LevelSilent)
     138 + }
     139 + if options.Verbose {
     140 + gologger.DefaultLogger.SetMaxLevel(levels.LevelVerbose)
     141 + }
     142 +}
     143 + 
     144 +func (Options *Options) loadConfigFrom(location string) error {
     145 + return fileutil.Unmarshal(fileutil.YAML, []byte(location), Options)
     146 +}
     147 + 
  • ■ ■ ■ ■ ■ ■
    internal/runner/result.go
     1 +package runner
     2 + 
     3 +import "encoding/json"
     4 + 
     5 +type Result struct {
     6 + Timestamp string `json:"timestamp"`
     7 + Prompt string `json:"prompt"`
     8 + Completion string `json:"completion"`
     9 + Model string `json:"model"`
     10 +}
     11 + 
     12 +func (result *Result) JSON() string {
     13 + data, _ := json.Marshal(result)
     14 + return string(data)
     15 +}
     16 + 
  • ■ ■ ■ ■ ■ ■
    internal/runner/runner.go
     1 +package runner
     2 + 
     3 +import (
     4 + "context"
     5 + "fmt"
     6 + "time"
     7 + 
     8 + "github.com/sashabaranov/go-openai"
     9 +)
     10 + 
     11 +// Runner contains the internal logic of the program
     12 +type Runner struct {
     13 + options *Options
     14 +}
     15 + 
     16 +// NewRunner instance
     17 +func NewRunner(options *Options) (*Runner, error) {
     18 + return &Runner{
     19 + options: options,
     20 + }, nil
     21 +}
     22 + 
     23 +// Run the instance
     24 +func (r *Runner) Run() (*Result, error) {
     25 + var model string
     26 + if r.options.OpenaiApiKey == "" {
     27 + return &Result{}, fmt.Errorf("OPENAI_API_KEY is not configured / provided.")
     28 + }
     29 + 
     30 + client := openai.NewClient(r.options.OpenaiApiKey)
     31 + 
     32 + if r.options.Gpt3 {
     33 + model = openai.GPT3Dot5Turbo
     34 + }
     35 + if r.options.Gpt4 {
     36 + model = openai.GPT4
     37 + }
     38 + 
     39 + chatGptResp, err := client.CreateChatCompletion(
     40 + context.Background(),
     41 + openai.ChatCompletionRequest{
     42 + Model: model,
     43 + Messages: []openai.ChatCompletionMessage{
     44 + {
     45 + Role: openai.ChatMessageRoleUser,
     46 + Content: r.options.Prompt,
     47 + },
     48 + },
     49 + },
     50 + )
     51 + if err != nil {
     52 + return &Result{}, err
     53 + }
     54 + 
     55 + if len(chatGptResp.Choices) == 0 {
     56 + return &Result{}, fmt.Errorf("no data on response")
     57 + }
     58 + 
     59 + result := &Result{
     60 + Timestamp: time.Now().String(),
     61 + Model: model,
     62 + Prompt: r.options.Prompt,
     63 + Completion: chatGptResp.Choices[0].Message.Content,
     64 + }
     65 + 
     66 + return result, nil
     67 +}
     68 + 
Please wait...
Page is in error, reload to recover