IamVicky111 commited on
Commit
66b76c7
·
verified ·
1 Parent(s): 8b741f1

Rename app (1).py to app.py

Browse files
Files changed (1) hide show
  1. app (1).py → app.py +10 -10
app (1).py → app.py RENAMED
@@ -6,7 +6,7 @@ from langchain_community.llms import HuggingFaceEndpoint
6
  from langchain_community.embeddings import HuggingFaceInferenceAPIEmbeddings
7
  import gradio as gr
8
  import subprocess
9
-
10
  # Ensure Playwright installs required browsers and dependencies
11
  subprocess.run(["playwright", "install"])
12
  #subprocess.run(["playwright", "install-deps"])
@@ -20,7 +20,7 @@ repo_id = "mistralai/Mistral-7B-Instruct-v0.2"
20
  llm_model_instance = HuggingFaceEndpoint(
21
  repo_id=repo_id, max_length=128, temperature=0.5, token=HUGGINGFACEHUB_API_TOKEN
22
  )
23
-
24
  embedder_model_instance = HuggingFaceInferenceAPIEmbeddings(
25
  api_key=HUGGINGFACEHUB_API_TOKEN, model_name="sentence-transformers/all-MiniLM-l6-v2"
26
  )
@@ -29,7 +29,7 @@ graph_config = {
29
  "llm": {"model_instance": llm_model_instance},
30
  "embeddings": {"model_instance": embedder_model_instance}
31
  }
32
-
33
  def scrape_and_summarize(prompt, source):
34
  smart_scraper_graph = SmartScraperGraph(
35
  prompt=prompt,
@@ -40,24 +40,24 @@ def scrape_and_summarize(prompt, source):
40
  exec_info = smart_scraper_graph.get_execution_info()
41
  return result, prettify_exec_info(exec_info)
42
 
43
- # Gradio interface
44
  with gr.Blocks() as demo:
45
  gr.Markdown("# Scrape websites, no-code version")
46
  gr.Markdown("""Easily scrape and summarize web content using advanced AI models on the Hugging Face Hub without writing any code. Input your desired prompt and source URL to get started.
47
  This is a no-code version of the excellent lib [ScrapeGraphAI](https://github.com/VinciGit00/Scrapegraph-ai).
48
  It's a basic demo and a work in progress. Please contribute to it to make it more useful!""")
49
-
50
  with gr.Row():
51
  with gr.Column():
52
 
53
- model_dropdown = gr.Textbox(label="Model", value="Mistral-7B-Instruct-v0.2")
54
- prompt_input = gr.Textbox(label="Prompt", value="List me all the press releases with their headlines and urls.")
55
- source_input = gr.Textbox(label="Source URL", value="https://www.whitehouse.gov/")
56
- scrape_button = gr.Button("Scrape and Summarize")
57
 
58
  with gr.Column():
59
  result_output = gr.JSON(label="Result")
60
- exec_info_output = gr.Textbox(label="Execution Info")
61
 
62
  scrape_button.click(
63
  scrape_and_summarize,
 
6
  from langchain_community.embeddings import HuggingFaceInferenceAPIEmbeddings
7
  import gradio as gr
8
  import subprocess
9
+ #Using Mistral Modal
10
  # Ensure Playwright installs required browsers and dependencies
11
  subprocess.run(["playwright", "install"])
12
  #subprocess.run(["playwright", "install-deps"])
 
20
  llm_model_instance = HuggingFaceEndpoint(
21
  repo_id=repo_id, max_length=128, temperature=0.5, token=HUGGINGFACEHUB_API_TOKEN
22
  )
23
+ #Calling Sentence Transformer
24
  embedder_model_instance = HuggingFaceInferenceAPIEmbeddings(
25
  api_key=HUGGINGFACEHUB_API_TOKEN, model_name="sentence-transformers/all-MiniLM-l6-v2"
26
  )
 
29
  "llm": {"model_instance": llm_model_instance},
30
  "embeddings": {"model_instance": embedder_model_instance}
31
  }
32
+ #To Scrape the data and summarize it
33
  def scrape_and_summarize(prompt, source):
34
  smart_scraper_graph = SmartScraperGraph(
35
  prompt=prompt,
 
40
  exec_info = smart_scraper_graph.get_execution_info()
41
  return result, prettify_exec_info(exec_info)
42
 
43
+ # Gradio User interface
44
  with gr.Blocks() as demo:
45
  gr.Markdown("# Scrape websites, no-code version")
46
  gr.Markdown("""Easily scrape and summarize web content using advanced AI models on the Hugging Face Hub without writing any code. Input your desired prompt and source URL to get started.
47
  This is a no-code version of the excellent lib [ScrapeGraphAI](https://github.com/VinciGit00/Scrapegraph-ai).
48
  It's a basic demo and a work in progress. Please contribute to it to make it more useful!""")
49
+ #(https://github.com/VinciGit00/Scrapegraph-ai) is suggested by the tutor
50
  with gr.Row():
51
  with gr.Column():
52
 
53
+ model_dropdown = gr.Textbox(label="Model", value="Mistral-7B-Instruct-v0.2, As all-MiniLM-l6-v2")
54
+ prompt_input = gr.Textbox(label="Prompt", value="List me all the doctors name and their timing")
55
+ source_input = gr.Textbox(label="Source URL", value="https://www.yelp.com/search?find_desc=dentist&find_loc=San+Francisco%2C+CA")
56
+ scrape_button = gr.Button("Scrape the data")
57
 
58
  with gr.Column():
59
  result_output = gr.JSON(label="Result")
60
+ exec_info_output = gr.Textbox(label="Output Info")
61
 
62
  scrape_button.click(
63
  scrape_and_summarize,