Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,21 +8,22 @@ from langchain.tools import AIPluginTool
|
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
-
def run(prompt):
|
| 12 |
-
tool = AIPluginTool.from_plugin_url(
|
| 13 |
llm = ChatOpenAI(temperature=0)
|
| 14 |
tools = load_tools(["requests_all"] )
|
| 15 |
tools += [tool]
|
| 16 |
agent_chain = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
|
| 17 |
-
return agent_chain.run(
|
| 18 |
|
| 19 |
with gr.Blocks() as demo:
|
| 20 |
with gr.Column():
|
| 21 |
-
prompt = gr.Textbox()
|
|
|
|
| 22 |
run_btn = gr.Button("Run")
|
| 23 |
-
response = gr.Textbox()
|
| 24 |
run_btn.click(fn=run,
|
| 25 |
-
inputs=[prompt],
|
| 26 |
outputs=[response]
|
| 27 |
)
|
| 28 |
demo.launch()
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
+
def run(prompt, plugin_json):
|
| 12 |
+
tool = AIPluginTool.from_plugin_url(plugin_json)
|
| 13 |
llm = ChatOpenAI(temperature=0)
|
| 14 |
tools = load_tools(["requests_all"] )
|
| 15 |
tools += [tool]
|
| 16 |
agent_chain = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
|
| 17 |
+
return agent_chain.run(prompt)
|
| 18 |
|
| 19 |
with gr.Blocks() as demo:
|
| 20 |
with gr.Column():
|
| 21 |
+
prompt = gr.Textbox(label="Prompt", value="what t shirts are available in klarna?")
|
| 22 |
+
plugin = gr.Textbox(label="Plugin", value="https://www.klarna.com/.well-known/ai-plugin.json")
|
| 23 |
run_btn = gr.Button("Run")
|
| 24 |
+
response = gr.Textbox(label="Response")
|
| 25 |
run_btn.click(fn=run,
|
| 26 |
+
inputs=[prompt, plugin],
|
| 27 |
outputs=[response]
|
| 28 |
)
|
| 29 |
demo.launch()
|