pritmanvar-bacancy commited on
Commit
d481ea4
·
verified ·
1 Parent(s): 585fb37

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from langchain_community.document_loaders import AsyncHtmlLoader
3
+ from langchain_community.document_transformers import Html2TextTransformer
4
+ import tiktoken
5
+ from langchain_groq import ChatGroq
6
+ import streamlit as st
7
+ from dotenv import load_dotenv
8
+ from pathlib import Path
9
+
10
+ env_path = Path('.') / '.env'
11
+ load_dotenv(dotenv_path=env_path)
12
+
13
+ st.title("AI Sales Executive")
14
+ urls_input = st.text_area("Enter website URLs (comma-separated):")
15
+
16
+ if st.button("Submit"):
17
+ if urls_input:
18
+ urls = [url.strip() for url in urls_input.split(",")]
19
+ loader = AsyncHtmlLoader(urls)
20
+ docs = loader.load()
21
+
22
+ html2text = Html2TextTransformer()
23
+ docs_transformed = html2text.transform_documents(docs)
24
+
25
+ llm = ChatGroq(
26
+ model="llama3-8b-8192",
27
+ temperature=0,
28
+ max_tokens=None,
29
+ timeout=None,
30
+ max_retries=2,
31
+ )
32
+
33
+ enc = tiktoken.encoding_for_model("gpt-3.5-turbo")
34
+
35
+ prompt = """You are a senior sales executive tasked with demonstrating how your expert team of data scientists can significantly enhance this company's growth and optimize their existing products using AI/ML technologies. Provide detailed insights into the specific ways your team can contribute to the company's success, specifically tailored to the company's product and goals. Additionally, include a brief summary of the company based on the following website content:
36
+
37
+ Website content: {content}
38
+ """
39
+ content = """"""
40
+ for doc in docs_transformed:
41
+ content += doc.page_content + "\n\n"
42
+
43
+ with st.spinner("Generating response..."):
44
+ response = llm.invoke(prompt.format(content=content))
45
+ st.write(response.content)