Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,8 @@ from langchain.tools import AIPluginTool
|
|
| 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"] )
|
|
@@ -30,10 +31,11 @@ with gr.Blocks() as demo:
|
|
| 30 |
gr.HTML(title)
|
| 31 |
prompt = gr.Textbox(label="Prompt", value="what t shirts are available in klarna?")
|
| 32 |
plugin = gr.Textbox(label="Plugin json", info="You need the .json plugin file of the plugin you want to use", value="https://www.klarna.com/.well-known/ai-plugin.json")
|
|
|
|
| 33 |
run_btn = gr.Button("Run")
|
| 34 |
response = gr.Textbox(label="Response")
|
| 35 |
run_btn.click(fn=run,
|
| 36 |
-
inputs=[prompt, plugin],
|
| 37 |
outputs=[response]
|
| 38 |
)
|
| 39 |
demo.launch()
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
+
def run(prompt, plugin_json, openai_api_key):
|
| 12 |
+
os.environ["OPENAI_API_KEY"] = openai_api_key
|
| 13 |
tool = AIPluginTool.from_plugin_url(plugin_json)
|
| 14 |
llm = ChatOpenAI(temperature=0)
|
| 15 |
tools = load_tools(["requests_all"] )
|
|
|
|
| 31 |
gr.HTML(title)
|
| 32 |
prompt = gr.Textbox(label="Prompt", value="what t shirts are available in klarna?")
|
| 33 |
plugin = gr.Textbox(label="Plugin json", info="You need the .json plugin file of the plugin you want to use", value="https://www.klarna.com/.well-known/ai-plugin.json")
|
| 34 |
+
openai_api_key = gr.Textbox(label="OpenAI API Key", type="password")
|
| 35 |
run_btn = gr.Button("Run")
|
| 36 |
response = gr.Textbox(label="Response")
|
| 37 |
run_btn.click(fn=run,
|
| 38 |
+
inputs=[prompt, plugin, openai_api_key],
|
| 39 |
outputs=[response]
|
| 40 |
)
|
| 41 |
demo.launch()
|