· last year · Nov 07, 2023, 02:10 PM
1#!/data/data/com.termux/files/use/bin/bash
2
3# Set the API key and prompt
4API_KEY="AIzaSyBCjs52Ge752uS0_jwhONKt-fSB82jG1lE"
5
6while true; do
7 # Prompt the user for a conversation prompt
8 read -p "Enter a conversation prompt: " PROMPT
9
10 # Send the prompt to the Bard AI API and get the response
11 RESPONSE=$(curl -X POST https://api.bard.ai/v1/chatbot \
12 -H "Authorization: Bearer $API_KEY" \
13 -H "Content-Type: application/json" \
14 -d "{\"prompt\":\"$PROMPT\"}" \
15 | jq -r '.response.messages[0].text')
16
17 # Print the response to the console
18 echo "$RESPONSE"
19
20 # Prompt the user to continue the chat
21 read -p "Continue chatting? (y/n) " CONTINUE
22
23 if [[ $CONTINUE ! = "y" ]]; then
24 break
25 fi
26done
27