jackMort / ChatGPT.nvim

ChatGPT Neovim Plugin: Effortless Natural Language Generation with OpenAI's ChatGPT API
Apache License 2.0
3.71k stars 310 forks source link

How to call api_key_cmd interactively so one can fill prompt for a password? #392

Open jumski opened 7 months ago

jumski commented 7 months ago

I have written a simple script that i want to use to get OpenAI API key from bitwarden vault using bitwarden-cli:

#!/bin/bash

bw get item OpenAI | jq --raw-output '.fields[] | select(.name == "cli_token") | .value'

it is correctly called (verified by logging date from this script to a tmp log file) but given the session is noninteractive, Bitwarden CLI does not prompt for a password and just silently fails without printing on stdout.

Is there a way in ChatGPT.nvim to make api_key_cmd be called interactively so user can input a password?

It is relevant to #322

rameshsanth commented 6 months ago

PR #407 will allow user to provide a Lua function to obtain the key. I've included an example of which uses a http request to obtain the key. Maybe you can whip up a Lua function that can create interactive session and obtain the key. Good luck

jumski commented 6 months ago

@rameshsanth that sounds great, it will definitely allow me to solve it elegantly. Thank you