Skip to content

Commit

Permalink
Merge pull request #96 from ClickHouse/streamlit-app
Browse files Browse the repository at this point in the history
simple readme for app
  • Loading branch information
gingerwizard authored Feb 16, 2024
2 parents ff5bc6a + a2752a4 commit 19f5521
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
48 changes: 48 additions & 0 deletions blog-examples/llama-index/hacknernews_app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Hackbot - A Streamlit chatbot πŸ’¬ for Hacker News powered by LlamaIndex πŸ¦™ and ClickHouse πŸš€

Simple chatbot app that uses LllamaIndex, ClickHouse, Hacker News posts, and Stack Overflow survey results to allow an LLM (chatbot v4.0) to provide answers on people's opinions on technology.

Answers are based on two sources held in ClickHouse:
- Hacker News posts with vector embeddings generated by the `sentence-transformers/all-MiniLM-L6-v2` model.
- Stack Overflow survey results allowing statistics to be looked up, e.g., What is the most popular web development framework? These facts are used to provide additional context for querying posts and requesting a response from the LLM.

For example, users can query for:

"What are people's opinions on the most popular database?"

This requires:

1. Establish the most popular database through a SQL query to ClickHouse. Answer: Postgresql.
2. Query the posts with "What are people's opinions on Postgresql."
3. Provide context to LLM (Chatgpt 4.0) by asking, "What are people's opinions on Postgresql?"

This relies on Llama index to control the flow via the [`SQLAutoVectorQueryEngine`]() engine.


## Requirements

- ClickHouse 24.1
- Python 3.11+

## Data

### Table schemas



### Loading

Hacker News post are for the period upto 2021. Stack Overflow survey results are also for 2021.

## Run application

We recommend using a [virtual environment]().

```
pip install -r requirements.txt
streamlit run hacker_insights.py
```

## Other capabilities

4 changes: 2 additions & 2 deletions blog-examples/llama-index/hacknernews_app/hacker_insights.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
database = st.secrets.clickhouse.database

st.set_page_config(
page_title="Get summaries of Hacker News posts enriched with Stackoverflow survey results, powered by LlamaIndex and CLickHouse",
page_title="Get summaries of Hacker News posts enriched with Stackoverflow survey results, powered by LlamaIndex and ClickHouse",
page_icon="πŸ¦™πŸš€", layout="centered", initial_sidebar_state="auto", menu_items=None)
st.title("πŸ’¬HackBot powered by LlamaIndex πŸ¦™ and ClickHouse πŸš€")
st.info(
"Check out the full [blog post](https://blog.streamlit.io/build-a-chatbot-with-custom-data-sources-powered-by-llamaindex/) for this app",
icon="πŸ“ƒ")
st.caption("A streamlit chatbot for Hacker News powered by πŸ’¬πŸ¦™ and ClickHouse πŸš€")
st.caption("A Streamlit chatbot πŸ’¬ for Hacker News powered by LlamaIndex πŸ¦™ and ClickHouse πŸš€")


@st.cache_resource
Expand Down

0 comments on commit 19f5521

Please sign in to comment.