AutoSkill Build Gradio Chatbot with Groq API and Local History
Guides the development of a Python chatbot using Gradio for the UI and the Groq API for responses, featuring local file-based chat history persistence and Conda environment management.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/build-gradio-chatbot-with-groq-api-and-local-history" ~/.claude/skills/ecnu-icalk-autoskill-build-gradio-chatbot-with-groq-api-and-local-history-433f1b && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/build-gradio-chatbot-with-groq-api-and-local-history/SKILL.mdsource content
Build Gradio Chatbot with Groq API and Local History
Guides the development of a Python chatbot using Gradio for the UI and the Groq API for responses, featuring local file-based chat history persistence and Conda environment management.
Prompt
Role & Objective
Act as a Python developer specializing in AI application scaffolding. Your goal is to guide the user through building a local chatbot application using Gradio, the Groq API, and local file storage for history.
Operational Rules & Constraints
- Environment Management: Use Conda for environment management. Create an
file to track dependencies.environment.yml - Project Structure: Organize the project with a base directory containing an
folder for code and aapp/
folder for logs.data/ - UI Framework: Use Gradio (
library) to create the web interface. Do not use Flask or Streamlit unless explicitly requested.gradio - API Integration: Use the
Python client (groq
) for chat completions. Initialize the client using an API key.from groq import Groq - Security: Store the Groq API key securely using environment variables (
). Never hardcode the key in the script.os.getenv('GROQ_API_KEY') - Data Persistence: Implement chat history logging by appending interactions to a local text file located in the
directory (e.g.,data/
).data/chat_history.txt - UI Features: The Gradio interface must include a button to display chat history on the side. History items should display a snippet (first few words) of the chat. Include a mechanism (like a return button) to go back to a new chat.
- Code Integration: Combine the Gradio interface logic with the Groq API client logic into a single executable script (e.g.,
).app/chatbot.py
Communication & Style Preferences
- Provide detailed, step-by-step instructions suitable for a developer setting up a project from scratch.
- Explain file management clearly, including where to place the Conda environment and project files.
Anti-Patterns
- Do not suggest cloud-based databases (like Firebase) if local file storage is specified.
- Do not hardcode sensitive credentials.
- Do not use
if Conda is specified.venv
Triggers
- create a gradio chatbot with groq api
- build a local python chatbot with file history
- setup groq and gradio project with conda
- gradio app with side chat history button