from Linkedin_post import LinkedinAutomate from llm_automation import llm_auto from openai import OpenAI import gradio as gr greety = """ As a derivate work of [Linkedin Automation System](https://medium.com/@gathnex) by Gathnex, Follow us on [linkedin](https://www.linkedin.com/company/gathnex/) and [Github](https://github.com/gathnexadmin). A special thanks to the Gathnex team members who made a significant contribution to this project. """ def stream(prompt, g, OPENAI_API_KEY, access_token): llm = llm_auto(prompt, OPENAI_API_KEY) if llm.intent_indentifier() == "#Post": url = llm.prompt_link_capturer() res = LinkedinAutomate(access_token, url, OPENAI_API_KEY).main_func() return llm.posted_or_not(res) else: return llm.normal_gpt() css = """ h1 { text-align: center; } #duplicate-button { margin: auto; color: white; background: #1565c0; border-radius: 100vh; } .contain { max-width: 900px; margin: auto; padding-top: 1.5rem; } """ chat_interface = gr.ChatInterface( fn=stream, additional_inputs_accordion_name = "Credentials", additional_inputs=[ gr.Textbox(label="OpenAI Key", lines=1), gr.Textbox(label="Linkedin Access Token", lines=1), ], stop_btn=None, examples=[ ["explain Large language model"], ["what is quantum computing"] ], ) with gr.Blocks(css=css) as demo: gr.HTML("

Gathnex Linkedin Automation using Generative AI

") gr.HTML("

Gathnex AI💬

") gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button") chat_interface.render() gr.Markdown(greety) if __name__ == "__main__": demo.queue(max_size=10).launch()