ChatGPT.nvim icon indicating copy to clipboard operation
ChatGPT.nvim copied to clipboard

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

Open jumski opened this issue 2 years ago • 2 comments

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

jumski avatar Feb 20 '24 10:02 jumski

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

rameshsanth avatar Mar 19 '24 04:03 rameshsanth

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

jumski avatar Mar 20 '24 21:03 jumski