Skip to content

Commit

Permalink
[Plugins]Enable plugins (PaddlePaddle#269)
Browse files Browse the repository at this point in the history
* enable_plugins_valid

* update

* fix_lint

* Update agent.py
  • Loading branch information
shiyutang authored Jan 11, 2024
1 parent 94fc4b1 commit e9655d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
4 changes: 0 additions & 4 deletions erniebot-agent/src/erniebot_agent/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,7 @@ def __init__(
else:
self._callback_manager = CallbackManager(callbacks)
self._file_manager = file_manager or get_default_file_manager()
if plugins is not None:
raise ValueError("Currently, plugins are not supported.")
self._plugins = plugins
if plugins is not None:
raise NotImplementedError("The use of plugins is not supported yet.")
self._init_file_needs_url()

@final
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from erniebot_agent.memory import AIMessage, HumanMessage, Message
from erniebot_agent.memory.sliding_window_memory import SlidingWindowMemory
from erniebot_agent.tools.base import Tool
from erniebot_agent.tools.calculator_tool import CalculatorTool
from erniebot_agent.tools.schema import ToolParameterView


Expand Down Expand Up @@ -106,22 +105,41 @@ def examples(self) -> List[Message]:
]


class get_current_weatherInputView(ToolParameterView):
location: str = Field(description="省,市名,例如:河北省,石家庄")
unit: str = Field(description="重复次数")


class get_current_weather(Tool):
description: str = "获得指定地点的天气"
input_type: Type[ToolParameterView] = get_current_weatherInputView

async def __call__(self, location, unit: int = None) -> None:
return None


# TODO(shiyutang): replace this when model is online
llm = ERNIEBot(model="ernie-3.5", api_type="custom")
llm = ERNIEBot(model="ernie-3.5", api_type="custom", enable_multi_step_tool_call=True)
memory = SlidingWindowMemory(max_round=1)
# plugins = ["ChatFile", "eChart"]
plugins: List[str] = []
plugins = ["ChatFile", "eChart"]
# plugins: List[str] = []
agent = FunctionAgent(
llm=llm,
tools=[TextRepeaterTool(), TextRepeaterNoFileTool(), CalculatorTool()],
tools=[
get_current_weather(),
],
memory=memory,
callbacks=get_no_ellipsis_callback(),
plugins=plugins,
)


async def run_agent():
file_manager = GlobalFileManagerHandler().get()
await GlobalFileManagerHandler().configure(
enable_remote_file=True,
access_token="your-access-token",
)
file_manager = await GlobalFileManagerHandler().get()

docx_file = await file_manager.create_file_from_path(
file_path="浅谈牛奶的营养与消费趋势.docx",
Expand Down

0 comments on commit e9655d3

Please sign in to comment.