This GitHub repo features a Flask chat app using OpenAI's GPT for an intelligent agent. It showcases OpenAI Assistant's retrieval for knowledge-based interactions, delivering nuanced responses. Ideal for developers exploring AI chats, it merges AI with web tech for smart chat interfaces.
AI-ChatFlask-GPT is a Flask-based chat application utilizing OpenAI's GPT models and retrieval capabilities to power an intelligent chat agent. It dynamically creates and updates a knowledge base from Markdown files for accurate project-related responses.
- Sign up at OpenAI to access the API.
- Obtain your API Key from the OpenAI dashboard.
- Review OpenAI's pricing page for ChatGPT-4 costs, typically based on token usage.
Securely authenticate with OpenAI API using an API key either via a .env
file or environment variables directly.
- Create a
.env
at your project's root. - Add
OPENAI_API_KEY=your_api_key_here
. - Ensure your application loads
.env
variables (usepython-dotenv
for Python).
- Windows (CMD):
set OPENAI_API_KEY=your_api_key_here
- Linux/macOS (Terminal):
export OPENAI_API_KEY=your_api_key_here
Security Note: Never upload
.env
or expose your OpenAI API key publicly.
To interact with the agent:
- Install Python and dependencies.
- Run
python app.py
. - Visit
http://localhost:8888
.
Utilize python chat.py create
to assemble the assistant's knowledge base or python chat.py recreate
for updates.
Tailor the assistant by editing Markdown files in the knowledge
folder and adjusting behaviors in the behaviors
directory.
Deploy using Docker with the command:
docker run -e OPENAI_API_KEY=tu_clave_api_aquí -p 8000:8000 ai-chatflask-gpt