bash
Build your own chatbot using CentML Platform and an example from Codex
CentML Serverless Chat
This Bash script interacts with the LLaMA model via CentML’s serverless API to create a simple real-time chat interface. The assistant provides helpful responses to user inputs, allowing you to have a back-and-forth conversation.
Features
-
Continuously streams responses from the CentML API.
-
Keeps track of the conversation history between the user and the assistant.
-
Supports dynamic interaction and real-time updates with each message.
Prerequisites
Before running the script, ensure that you have:
- A valid CentML API key.
- jq installed on your system (for JSON manipulation). You can install it using:
Getting Started
- Directory
enter the chat-apps/bash directory
- Make the Script Executable
Make the script executable by running the following command:
- Set Your CentML API Key
Export your CentML API key as an environment variable:
Replace “your-api-key” with your actual CentML API key.
- Run the Chat Script
Now you’re ready to run the chat script. Start the chat session by executing:
- Exit the Chat
To exit the chat, simply type exit at any prompt, and the session will end.
Example Chat Session
Troubleshooting
- API Errors: If the script fails to fetch responses, check your API key and ensure it is valid.
- Response Formatting: The script includes basic string formatting to clean up the assistant’s responses, removing unnecessary spaces before punctuation.
- Missing jq: Make sure you have jq installed. If not, the script will fail when handling JSON responses.