Adr740's picture
Update app.py
5a8f86f verified
import gradio as gr
import os
from functools import partial
import gdown
import pandas as pd
from logs import save_logs
import gdown
import time
import pandas as pd
from config import logs_folder_id, json_url_id
from ice_cold import get_refresher
from web_scrapping_engine import get_linkedin_profile
choices = ["sofwareAG"]
title = """"""
def stream(company):
linkedin_extracted_info = get_linkedin_profile(company)
linkedin_extracted_info["profile"]["similar_companies"] = ""
resp = get_refresher(linkedin_extracted_info)
answer = "*(Latest update as per Linkedin)*\n"
for chunk in resp:
if chunk.choices[0].delta.content is not None:
answer = answer + chunk.choices[0].delta.content
yield answer
answer_to_save = answer + "\n============\n" + str(linkedin_extracted_info)
save_logs(company, answer_to_save, folder_id=logs_folder_id)
download_url = f'https://drive.google.com/uc?id={json_url_id}'
output = 'secret_google_service_account.json'
gdown.download(download_url, output, quiet=False)
with gr.Blocks(title=title,theme='nota-ai/theme',css="footer {visibility: hidden}") as demo:
gr.Markdown(f"## {title}")
with gr.Row():
with gr.Column(scale=6):
with gr.Row():
with gr.Column(scale=3):
chat_input = gr.Textbox(placeholder="Company Name", lines=1, label="Get instant refresher on any company")
chat_submit_button = gr.Button(value="Submit ▶")
with gr.Column(scale=6):
chat_output = gr.Markdown("Waiting for company...")
fn_chat = stream
chat_submit_button.click(fn=fn_chat, inputs=[chat_input], outputs=[chat_output])
demo.launch(max_threads=40)