Skip to content

An interactive Q&A tool that uses an LLM (via OpenAI API) to answer user questions in real-time, utilizing streaming responses for a dynamic, chat-like experience.

Notifications You must be signed in to change notification settings

MrSpecks/QnA-code-assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Q&A Bot (Streamlit)

An interactive Q&A tool that uses the OpenAI API to answer questions in real-time with streaming, built on Streamlit's native chat components.

Features

  • Real-time token streaming for a live chat feel
  • System prompt customization (bot personality)
  • Model selection (e.g., GPT-3.5, GPT-4 family)
  • Conversation history persisted in session state

Requirements

  • Python 3.9+
  • OpenAI API key

Setup

  1. Install dependencies:
    pip install -r requirements.txt
  2. Create a secrets file:
    # .streamlit/secrets.toml
    OPENAI_API_KEY = "sk-..."
  3. Run locally:
    streamlit run streamlit_app.py

Environment Variables (secrets)

  • OPENAI_API_KEY: Your OpenAI API key. Loaded via st.secrets['OPENAI_API_KEY'].

Usage

  1. Open the app URL shown in the terminal after starting Streamlit.
  2. Configure the System Prompt and Model in the sidebar.
  3. Ask a question via the chat input; the assistant streams the answer.

Deployment

  • Streamlit Community Cloud: push this repo and add OPENAI_API_KEY under App Secrets.
  • Other platforms: ensure .streamlit/secrets.toml or environment-backed secrets are configured and that the port/network settings allow Streamlit to serve the app.

Notes

  • Streaming is enabled by default and handled with st.write_stream.
  • Each interaction is a fresh API call; no caching is used.

About

An interactive Q&A tool that uses an LLM (via OpenAI API) to answer user questions in real-time, utilizing streaming responses for a dynamic, chat-like experience.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages