Skip to content

Commit

Permalink
Merge commit 'refs/pull/271/head' of https://github.com/PaddlePaddle/…
Browse files Browse the repository at this point in the history
…ERNIE-Bot-SDK into update_system
  • Loading branch information
shiyutang committed Jan 8, 2024
2 parents c0c5446 + 7ca89b9 commit fbe3ea7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion erniebot-agent/applications/rpg_game/rpg_game_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from erniebot_agent.agents.agent import Agent
from erniebot_agent.agents.schema import AgentResponse
from erniebot_agent.chat_models.erniebot import ERNIEBot
from erniebot_agent.file.base import File
from erniebot_agent.file import File
from erniebot_agent.memory.messages import AIMessage, HumanMessage
from erniebot_agent.memory.sliding_window_memory import SlidingWindowMemory
from erniebot_agent.tools.base import BaseTool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,24 @@ async def test_functional_agent_with_retrieval_run_retrieval(identity_tool):
assert response.chat_history[0].content == "Hello, world!"
# AIMessage
assert response.chat_history[1].content == "Text response"


@pytest.mark.asyncio
async def test_function_agent_with_retrieval_system():
knowledge_base_name = "test"
access_token = "your access token"
knowledge_base_id = 111
with mock.patch("requests.post") as my_mock:
search_db = BaizhongSearch(
knowledge_base_name=knowledge_base_name,
access_token=access_token,
knowledge_base_id=knowledge_base_id if knowledge_base_id != "" else None,
)
agent = FunctionAgentWithRetrieval(
llm=FakeSimpleChatModel(), tools=[], system="You are a helpful bot.", knowledge_base=search_db
)
with mock.patch("requests.post") as my_mock:
my_mock.return_value = MagicMock(status_code=200, json=lambda: EXAMPLE_RESPONSE)
response = await agent.run("Run!")

assert "Recieved system message" in response.text

0 comments on commit fbe3ea7

Please sign in to comment.