Rahul Bhoyar commited on
Commit
91dad81
0 Parent(s):

Initial Commit

Browse files
Files changed (4) hide show
  1. .github/workflows/sync_with_hf.yml +18 -0
  2. .gitignore +1 -0
  3. app.py +53 -0
  4. requirements.txt +9 -0
.github/workflows/sync_with_hf.yml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync to Hugging Face hub
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ workflow_dispatch:
6
+
7
+ jobs:
8
+ sync-to-hub:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v3
12
+ with:
13
+ fetch-depth: 0
14
+ lfs: true
15
+ - name: Push to Hugging face hub
16
+ env:
17
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
18
+ run: git push --force https://rahul-bhoyar-1995:$HF_TOKEN@huggingface.co/spaces/rahul-bhoyar-1995/Webpage-Querier main
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ venv/
app.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ from llama_index import VectorStoreIndex, download_loader, ServiceContext
4
+ from llama_index.embeddings import HuggingFaceEmbedding
5
+ from llama_index.llms import Gemini, HuggingFaceInferenceAPI, OpenAI
6
+
7
+ # Create Streamlit web app
8
+ def main():
9
+ st.title("Webpage Querier by Rahul Bhoyar")
10
+ # Sidebar for customizations
11
+ with st.sidebar:
12
+ st.subheader("Customize Settings")
13
+ loader = download_loader("BeautifulSoupWebReader")()
14
+ hf_token = st.text_input("Enter your Hugging Face token:")
15
+ llm = HuggingFaceInferenceAPI(model_name="HuggingFaceH4/zephyr-7b-alpha", token=hf_token)
16
+
17
+ # Main content area
18
+ st.markdown("Query your Web page data with using this chatbot")
19
+
20
+ # User input: Web page link
21
+ url = st.text_input("Enter the URL of the web page:")
22
+
23
+ # Create Service Context
24
+ embed_model_uae = HuggingFaceEmbedding(model_name="WhereIsAI/UAE-Large-V1")
25
+ service_context = ServiceContext.from_defaults(llm=llm, chunk_size=800, chunk_overlap=20, embed_model=embed_model_uae)
26
+
27
+ # Load documents
28
+ if url:
29
+ documents = loader.load_data(urls=[url])
30
+ st.success("Documents loaded successfully!")
31
+ with st.spinner('Creating Vector Embeddings...'):
32
+ # Create Vector Store Index
33
+ index = VectorStoreIndex.from_documents(documents, service_context=service_context, show_progress=True)
34
+
35
+ # Persist Storage Context
36
+ index.storage_context.persist()
37
+
38
+ # Create Query Engine
39
+ query_engine = index.as_query_engine()
40
+
41
+ # User input: Query
42
+ query = st.text_input("Ask a question:")
43
+ if query:
44
+ # Run Query
45
+ response = query_engine.query(query)
46
+
47
+ # Display Result
48
+ st.markdown(f"**Response:** {response}")
49
+ else:
50
+ st.warning("Please enter a valid URL.")
51
+
52
+ if __name__ == "__main__":
53
+ main()
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ llama-index
2
+ streamlit
3
+ transformers[torch]
4
+ huggingface_hub[inference]
5
+ transformers
6
+ beautifulsoup4
7
+ unstructured
8
+ watchdog
9
+ transformers