From bfd867f2778a1d82aa35bbf751b6c06a4adf5e81 Mon Sep 17 00:00:00 2001 From: "jinli.yl" Date: Tue, 17 Jun 2025 20:07:16 +0800 Subject: [PATCH] update quick start --- cookbook/simple_agent/quick_start.md | 34 +++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/cookbook/simple_agent/quick_start.md b/cookbook/simple_agent/quick_start.md index bd5a877d..294b8b08 100644 --- a/cookbook/simple_agent/quick_start.md +++ b/cookbook/simple_agent/quick_start.md @@ -38,7 +38,7 @@ Here is an [example code](./your_own_agent.py) with [prompt](./your_own_agent_pr export DASHSCOPE_API_KEY="sk-xxx" ``` -### Step1: Start Experience Maker Http Service +### Step1: Start ExperienceMaker Http Service - Install dependencies. ```shell pip install . @@ -55,3 +55,35 @@ python -m experiencemaker.em_service \ --context_generator='{"backend": "simple"}' \ --summarizer='{"backend": "simple"}' ``` + +### Step2: Enhance Your Own Agent + +Call the capabilities of ContextGenerator and Summarizer through `EMClient`. + +```python +from experiencemaker.em_client import EMClient + +em_client = EMClient(base_url="http://0.0.0.0:8001") +``` + +Assume you have a list of messages generated by an agent; you can use the summarizer to generate experiences from them. + +```python +request = SummarizerRequest( + trajectories=[Trajectory(query=query, steps=messages, answer=messages[-1].content, done=True)], + workspace_id="w_1234") +response = em_client.call_summarizer(request) +for experience in response.experiences: + print(experience.model_dump_json()) +``` + +Assume you have a query; you can use the context generator to generate a new query from the query and the related +experiences. + +```python +request = ContextGeneratorRequest(trajectory=Trajectory(query=query), retrieve_top_k=1, workspace_id="w_1234") +response = em_client.call_context_generator(request) +new_query = f"{response.context_msg.content}\n\nUser Question\n{query}" +``` + +The complete code can be found in the implementation of [YourOwnAgentEnhanced](./your_own_agent_enhanced.py).