Koomemartin commited on
Commit
cd4ad00
Β·
verified Β·
1 Parent(s): 652a180

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -75,7 +75,7 @@ def get_links(url):
75
  return json.loads(result)
76
 
77
  #all the content required to generate information from user about the website
78
- @st.cache_resource
79
  def get_all_details(url):
80
  result = "Home page:\n"
81
  result += Website(url).get_contents()
@@ -102,7 +102,7 @@ def get_brochure_user_prompt(company_name, url):
102
  user_prompt = f"You are looking at a company called: {company_name}\n"
103
  user_prompt += f"Here are the contents of its landing page and other relevant pages; use this information to build a short brochure of the company in markdown and provide usable links in the contacts areas \n"
104
  user_prompt += get_all_details(url)
105
- user_prompt = user_prompt[:20_000] # Truncate if more than 20,000 characters
106
  return user_prompt
107
 
108
  # Initialize Groq client
@@ -112,7 +112,7 @@ client = Groq(api_key=api_key)
112
 
113
  # Streamlit UI
114
  st.title("AI Brochures πŸŽ¨πŸ“Œ")
115
- st.write("Create a captivating brochure of your company or institution by only using information from your website!!")
116
 
117
  # Input fields
118
  system= st.text_input("Modify the model response using a custom system prompt if not satisfied with generated response:" , " " )
@@ -150,11 +150,7 @@ if user_query:
150
  st.error(f"Failed to process query to model: {e}")
151
  response = ""
152
  try:
153
- # for chunk in chat_streaming:
154
- # content = chunk.choices[0].delta.content
155
- # if content: # Ensure content is not None
156
  response=chat_streaming.choices[0].message.content
157
- # response += content
158
  st.write("πŸ€–:")
159
  st.write(response)
160
  except Exception as e:
 
75
  return json.loads(result)
76
 
77
  #all the content required to generate information from user about the website
78
+ @st.cache_resource # use the cached data to resond to the second query rather than scraping the website again
79
  def get_all_details(url):
80
  result = "Home page:\n"
81
  result += Website(url).get_contents()
 
102
  user_prompt = f"You are looking at a company called: {company_name}\n"
103
  user_prompt += f"Here are the contents of its landing page and other relevant pages; use this information to build a short brochure of the company in markdown and provide usable links in the contacts areas \n"
104
  user_prompt += get_all_details(url)
105
+ user_prompt = user_prompt[:30_000] # Truncate if more than 30,000 characters
106
  return user_prompt
107
 
108
  # Initialize Groq client
 
112
 
113
  # Streamlit UI
114
  st.title("AI Brochures πŸŽ¨πŸ“Œ")
115
+ st.write("Create a captivating brochure for your company or institution by only using information from your website!!")
116
 
117
  # Input fields
118
  system= st.text_input("Modify the model response using a custom system prompt if not satisfied with generated response:" , " " )
 
150
  st.error(f"Failed to process query to model: {e}")
151
  response = ""
152
  try:
 
 
 
153
  response=chat_streaming.choices[0].message.content
 
154
  st.write("πŸ€–:")
155
  st.write(response)
156
  except Exception as e: