File size: 1,682 Bytes
d481ea4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import os
from langchain_community.document_loaders import AsyncHtmlLoader
from langchain_community.document_transformers import Html2TextTransformer
from langchain_groq import ChatGroq
import streamlit as st
from dotenv import load_dotenv
from pathlib import Path
env_path = Path('.') / '.env'
load_dotenv(dotenv_path=env_path)
st.title("AI Sales Executive")
urls_input = st.text_area("Enter website URLs (comma-separated):")
if st.button("Submit"):
if urls_input:
urls = [url.strip() for url in urls_input.split(",")]
loader = AsyncHtmlLoader(urls)
docs = loader.load()
html2text = Html2TextTransformer()
docs_transformed = html2text.transform_documents(docs)
llm = ChatGroq(
model="llama3-8b-8192",
temperature=0,
max_tokens=None,
timeout=None,
max_retries=2,
)
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:
Website content: {content}
"""
content = """"""
for doc in docs_transformed:
content += doc.page_content + "\n\n"
with st.spinner("Generating response..."):
response = llm.invoke(prompt.format(content=content))
st.write(response.content)
|