A minimal yet production-ready folder structure for building a web chat experience powered by the GitHub Copilot Python SDK and Streamlit.
- Streamlit chat UI with persistent conversation state per browser session
- Service layer that formats conversation context before forwarding it to GitHub Copilot
- Configurable model/system prompt via environment variables
F:\Dev\gh-copilot-chat-app
├── README.md
├── requirements.txt
├── .streamlit
│ └── config.toml # Streamlit theme + page defaults
└── src
├── __init__.py
├── app.py # Streamlit entrypoint (streamlit run src/app.py)
├── config.py # Settings + environment helpers
├── copilot
│ ├── __init__.py
│ └── client.py # Thin wrapper around CopilotClient
└── services
├── __init__.py
└── chat_service.py # Conversation orchestration & prompt prep
- Python 3.10+
- GitHub Copilot CLI installed and authenticated:
npm i -g @githubnext/cyclic && copilot login - A valid GitHub Copilot subscription tied to the signed-in account
The app auto-discovers the Copilot CLI path (using
where copiloton Windows), but you can override it by settingCOPILOT_CLI_PATHif the executable lives elsewhere.
cd F:\Dev\gh-copilot-chat-app
python -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txtOptional environment variables:
COPILOT_MODEL=gpt-4o-mini
COPILOT_SYSTEM_PROMPT="You are a friendly AI pair programmer..."
streamlit run src/app.pyThen open the URL shown in the console (defaults to http://localhost:8551/).
- The Streamlit UI collects chat messages and stores them in
st.session_state. ChatServiceassembles a trimmed conversation transcript plus the latest user message.CopilotChatClientspins up the GitHub Copilot CLI via the Python SDK, sends the prompt, waits for the assistant response, and returns it to the UI.
Tweak config.py or add new services/components to evolve this scaffold into a richer Copilot-powered experience.