Tonic's picture
Update app.py
907a5fe
raw
history blame
1.28 kB
import gradio as gr
import semantic_kernel
from plugins.sk_bing_plugin import BingPlugin
from plugins.sk_web_pages_plugin import WebPagesPlugin
from planning.autogen_planner import AutoGenPlanner
# Configure your credentials here
bing_api_key = "..." # Replace with your Bing API key
llm_config = {
"type": "openai", # "azure" or "openai"
"openai_api_key": "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", # OpenAI API Key
"azure_deployment": "", # Azure OpenAI deployment name
"azure_api_key": "", # Azure OpenAI API key in the Azure portal
"azure_endpoint": "" # Endpoint URL for Azure OpenAI, e.g. https://contoso.openai.azure.com/
}
kernel = semantic_kernel.Kernel()
kernel.import_skill(BingPlugin(bing_api_key))
kernel.import_skill(WebPagesPlugin())
sk_planner = AutoGenPlanner(kernel, llm_config)
assistant = sk_planner.create_assistant_agent("Assistant")
def get_response(question, max_auto_reply):
worker = sk_planner.create_user_agent("Worker", max_auto_reply=max_auto_reply, human_input="NEVER")
worker.initiate_chat(assistant, message=question)
return worker.get_response()
iface = gr.Interface(fn=get_response, inputs=["text", "number"], outputs="text", inputs_label=["Question", "Max Auto Reply"])
iface.launch()