How to ask Open AI Chatbot from Windows Terminal

The aim of this page📝 is to duplicate the great idea from “howdoijust instead of curated answers from Stack Overflow, I am using an Open AI chatbot.

Pavol Kutaj
2 min readFeb 23, 2023

Implementation

  • For joining the prompt written in the terminal into a single variable, I’m using a bit of PowerShell in located in $profile
  • that defines the function ask that I call when I need it
function ask {
$prompt = ""
$args | % {$prompt += $_ + " "}
python <path\script.py> $prompt
}

Comparison

  • howdoi works perfectly and deterministically and has proper attributes (use -a to get a full answer from StackOverflow)
  • the following are calls directly from Windows Terminal, but porting this to Mac should be a matter of a few lines in zsh profile
howdoi format date in Postgres to yyyy-mm-dd
>>> SELECT to_char("date", 'DD/MM/YYYY') FROM mytable;
  • openAI gives me a similar answer, though
▶ ask how to format date to YYYY-MM-DD in Redshift
You can use the TO_CHAR function to format a date to YYYY-MM-DD in Redshift. The syntax is as follows:

TO_CHAR(date_expression, 'YYYY-MM-DD')

For example:

SELECT TO_CHAR(CURRENT_DATE, 'YYYY-MM-DD');

LINKS

--

--

No responses yet