update quick start

This commit is contained in:
jinli.yl 2025-06-17 20:07:16 +08:00
parent b1cf4b7dd3
commit bfd867f277

View file

@ -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).