|
import streamlit as st |
|
from langchain_openai import OpenAI |
|
from langchain.prompts import PromptTemplate |
|
from langchain.chains import LLMChain |
|
from dotenv import load_dotenv |
|
import json |
|
import re |
|
|
|
|
|
|
|
load_dotenv() |
|
|
|
def getWebsiteLink(company_name): |
|
llm = OpenAI(temperature=0.0, model="gpt-3.5-turbo-instruct") |
|
|
|
prompt = PromptTemplate( |
|
input_variables=["company"], |
|
template=""" |
|
Official website URL of {company} is |
|
|
|
RESPONSE: |
|
""", |
|
) |
|
|
|
chain = LLMChain(llm=llm, prompt=prompt) |
|
|
|
response = chain.run(company_name) |
|
|
|
urls = re.findall(r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', response) |
|
|
|
if urls: |
|
|
|
response_json = json.dumps({"website_link": urls[0]}, indent=4) |
|
else: |
|
|
|
response_json = json.dumps({"website_link": "Not found"}, indent=4) |
|
|
|
return response_json |
|
|
|
|
|
|
|
st.set_page_config(page_title="Website URL Generator", page_icon='π', layout='centered') |
|
|
|
st.header("Website URL Generator") |
|
|
|
company_name = st.text_area('Enter the company name', height=150) |
|
|
|
submit = st.button("Generate official website") |
|
|
|
if submit: |
|
company_link = getWebsiteLink(company_name) |
|
st.write("Generate official website:") |
|
st.code(company_link, language='json') |
|
|
|
|