Back to Llama Index

Load the Plugin

llama-index-integrations/tools/llama-index-tools-chatgpt-plugin/examples/chatgpt_plugin.ipynb

0.14.211.1 KB
Original Source
python
import os

os.environ["OPENAI_API_KEY"] = "sk-your-key"

from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
python
# Load the Plugin
import requests
import yaml

f = requests.get(
    "https://raw.githubusercontent.com/sisbell/chatgpt-plugin-store/main/manifests/today-currency-converter.oiconma.repl.co.json"
).text
manifest = yaml.safe_load(f)
python
from llama_index.tools.chatgpt_plugin.base import ChatGPTPluginToolSpec
from llama_index.tools.requests.base import RequestsToolSpec

requests_spec = RequestsToolSpec()
plugin_spec = ChatGPTPluginToolSpec(manifest)
# OR
plugin_spec = ChatGPTPluginToolSpec(
    manifest_url="https://raw.githubusercontent.com/sisbell/chatgpt-plugin-store/main/manifests/today-currency-converter.oiconma.repl.co.json"
)
python
agent = FunctionAgent(
    tools=[*plugin_spec.to_tool_list(), *requests_spec.to_tool_list()], 
    llm=Openai(model="gpt-4.1")
)
python
print(await agent.run("Can you give me info on the OpenAPI plugin that was loaded"))
python
print(await agent.run("Can you convert 100 euros to CAD"))