import gradio as gr from langchain.agents.openai_assistant import OpenAIAssistantRunnable from openai import OpenAI import os #sk assit_public = = os.getenv('assit_public') Secret = = os.getenv('Secret') assit_Public_to_Compliance == os.getenv('assit_Public_to_Compliance') Confidential_HR_Director = = os.getenv('Confidential_HR_Director') apikey =os.getenv('openAI') #apikey = os.getenv('openAI') #key from client #agentkey = os.getenv('asstID') os.environ["OPENAI_API_KEY"] = apikey # assit_public # Secret # assit_Public_to_Compliance # Confidential_HR_Director def get_answer(selected_knowledge_base, question): if selected_knowledge_base == "Public": assist = assit_public # Lyft tool elif selected_knowledge_base == "Secret": assist = Secret # Uber tool elif selected_knowledge_base == "Public_to_Compliance": assist = assit_Public_to_Compliance # Uber tool elif selected_knowledge_base == "HR_Director": assist = Confidential_HR_Director # Uber tool else: return "Invalid knowledge base selected." # # Use the selected tool to get the answer # response = agent.chat(question) #, tools=[selected_tool] interpreter_assistant = OpenAIAssistantRunnable(assistant_id= assist) output = interpreter_assistant.invoke({"content": question}) response = output[0].content[0].text.value return response gr.Interface( fn=get_answer, css=css, js = js_func, theme="soft", # base. citrus. soft glass. ocean inputs=[ gr.Dropdown( choices=["Public", "Secret", "Public_to_Compliance","HR_Director"], label="Select Knowledge Base" ), gr.Textbox(label="Enter your question", lines=3) ], outputs="text", title="Finance Companies Control System", description="Ask questions related to the Finance Companies Control System.", ).launch(debug = True)