candenizkocak commited on
Commit
73c998c
·
1 Parent(s): 9d7c695

Initial commit

Browse files
Files changed (3) hide show
  1. README.md +19 -13
  2. app.py +86 -0
  3. requirements.txt +3 -0
README.md CHANGED
@@ -1,13 +1,19 @@
1
- ---
2
- title: Exa Groq Company Website Analysis
3
- emoji: 📊
4
- colorFrom: red
5
- colorTo: green
6
- sdk: streamlit
7
- sdk_version: 1.38.0
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
1
+ # Company Website Analysis Tool with Exa and Groq
2
+
3
+ ## Overview
4
+
5
+ The **Company Website Analysis Tool** is a Streamlit application that uses the Exa and Groq APIs to analyze company websites and provide concise research summaries. This tool is designed for demonstration purposes, showcasing how large language models can summarize web content into a professional overview of a company.
6
+
7
+ ## Features
8
+
9
+ - **Content Analysis**: Extracts and analyzes key content from the company's website.
10
+ - **Research Summarization**: Uses Groq's large language model (llama-3.1-8b-instant) to generate a concise summary of the company's profile and activities.
11
+ - **Customizable Settings**: Allows users to adjust `max_tokens` and `temperature` parameters for the text generation model.
12
+
13
+ ## Getting Started
14
+
15
+ ### Requirements
16
+
17
+ - **Streamlit**: Web application framework for Python.
18
+ - **Exa API Key**: Required to access the Exa API for company analysis.
19
+ - **Groq API Key**: Required to access the Groq API for generating summaries.
app.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from exa_py import Exa
3
+ from groq import Groq
4
+
5
+ # Streamlit App Title
6
+ st.title("Company Website Analysis Tool with Exa and Groq")
7
+
8
+ # Input fields for EXA and GROQ API keys and company URL
9
+ EXA_API_KEY = st.text_input("EXA API Key", type="password")
10
+ GROQ_API_KEY = st.text_input("GROQ API Key - This demo uses llama-3.1-8b-instant", type="password")
11
+ input_url = st.text_input("Company URL", placeholder="huggingface.co")
12
+
13
+ # Sliders for Groq model settings
14
+ max_tokens = st.slider("Max Tokens", min_value=1024, max_value=8000, value=4096, step=256)
15
+ temperature = st.slider("Temperature", min_value=0.1, max_value=2.0, value=1.0, step=0.1)
16
+
17
+ # Button to trigger the analysis
18
+ if st.button("Analyze Company"):
19
+ if EXA_API_KEY and GROQ_API_KEY and input_url:
20
+ try:
21
+ # Initialize EXA client
22
+ exa = Exa(api_key=EXA_API_KEY)
23
+
24
+ # Get 5 similar companies
25
+ search_response = exa.find_similar_and_contents(
26
+ input_url,
27
+ highlights={"num_sentences": 2},
28
+ num_results=5
29
+ )
30
+ companies = search_response.results
31
+
32
+ # Extract the first company's data for demonstration
33
+ c = companies[0]
34
+ all_contents = ""
35
+ search_response = exa.search_and_contents(
36
+ c.url, # Input the company's URL
37
+ type="keyword",
38
+ num_results=3
39
+ )
40
+ research_response = search_response.results
41
+ for r in research_response:
42
+ all_contents += r.text
43
+
44
+ # Initialize GROQ client
45
+ client = Groq(api_key=GROQ_API_KEY)
46
+
47
+ # Define system message and call the Groq API for summarization
48
+ SYSTEM_MESSAGE = (
49
+ "You are a helpful assistant writing a research summary about a company. "
50
+ "Summarize the user's input into multiple paragraphs. Be extremely concise, "
51
+ "professional, and factual as possible. The first paragraph should be an introduction "
52
+ "and summary of the company. The second paragraph should be a detailed summary of the company."
53
+ )
54
+
55
+ # Get the summary from Groq
56
+ completion = client.chat.completions.create(
57
+ model="llama-3.1-8b-instant",
58
+ messages=[
59
+ {"role": "system", "content": SYSTEM_MESSAGE},
60
+ {"role": "user", "content": all_contents},
61
+ ],
62
+ temperature=temperature,
63
+ max_tokens=max_tokens,
64
+ top_p=1,
65
+ stream=False,
66
+ stop=None,
67
+ )
68
+
69
+ # Extract summary content
70
+ summary = completion.choices[0].message.content
71
+
72
+ # Display the summary in Streamlit with markdown formatting for readability
73
+ st.markdown(f"### {c.title}")
74
+ st.markdown(summary)
75
+
76
+ except Exception as e:
77
+ st.error(f"An error occurred: {e}")
78
+ else:
79
+ st.warning("Please provide all inputs: EXA API Key, GROQ API Key, and Company URL.")
80
+
81
+ # Disclaimer Section
82
+ st.markdown("---")
83
+ st.caption(
84
+ "Disclaimer: This tool is built for demonstration purposes only and should not be used as a basis for investment decisions. "
85
+ "The analysis generated by large language models may contain inaccuracies, and the content is not intended as professional financial advice."
86
+ )
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ exa_py
3
+ groq