Skip to content

Commit 13de958

Browse files
authored
Update readme examples and news (#117)
2 parents 47729d0 + ae10459 commit 13de958

File tree

1 file changed

+80
-46
lines changed

1 file changed

+80
-46
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 80 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -139,55 +139,89 @@ from camel.models import ModelFactory
139139
from camel.types import ModelPlatformType, ModelType
140140

141141
import oasis
142-
from oasis import ActionType, EnvAction, SingleAction
142+
from oasis import (ActionType, LLMAction, ManualAction,
143+
generate_reddit_agent_graph)
143144

144145

145146
async def main():
146-
# Define the model for the agents
147-
openai_model = ModelFactory.create(
148-
model_platform=ModelPlatformType.OPENAI,
149-
model_type=ModelType.GPT_4O_MINI,
150-
)
151-
152-
# Define the available actions for the agents
153-
available_actions = [
154-
ActionType.LIKE_POST,
155-
ActionType.CREATE_POST,
156-
ActionType.CREATE_COMMENT,
157-
ActionType.FOLLOW
158-
]
159-
160-
# Make the environment
161-
env = oasis.make(
162-
platform=oasis.DefaultPlatformType.REDDIT,
163-
database_path="reddit_simulation.db",
164-
agent_profile_path="./data/reddit/user_data_36.json",
165-
agent_models=openai_model,
166-
available_actions=available_actions,
167-
)
168-
169-
# Run the environment
170-
await env.reset()
171-
172-
action = SingleAction(
173-
agent_id=0,
174-
action=ActionType.CREATE_POST,
175-
args={"content": "Welcome to the OASIS World!"}
176-
)
177-
178-
env_actions = EnvAction(
179-
activate_agents=list(range(10)), # activate the first 10 agents
180-
intervention=[action]
181-
)
182-
183-
# Apply interventions to the environment, refresh the recommendation system, and LLM agent perform actions
184-
await env.step(env_actions)
185-
186-
# Close the environment
187-
await env.close()
147+
# Define the model for the agents
148+
openai_model = ModelFactory.create(
149+
model_platform=ModelPlatformType.OPENAI,
150+
model_type=ModelType.GPT_4O_MINI,
151+
)
152+
153+
# Define the available actions for the agents
154+
available_actions = [
155+
ActionType.LIKE_POST,
156+
ActionType.DISLIKE_POST,
157+
ActionType.CREATE_POST,
158+
ActionType.CREATE_COMMENT,
159+
ActionType.LIKE_COMMENT,
160+
ActionType.DISLIKE_COMMENT,
161+
ActionType.SEARCH_POSTS,
162+
ActionType.SEARCH_USER,
163+
ActionType.TREND,
164+
ActionType.REFRESH,
165+
ActionType.DO_NOTHING,
166+
ActionType.FOLLOW,
167+
ActionType.MUTE,
168+
]
169+
170+
agent_graph = await generate_reddit_agent_graph(
171+
profile_path="./data/reddit/user_data_36.json",
172+
model=openai_model,
173+
available_actions=available_actions,
174+
)
175+
176+
# Define the path to the database
177+
db_path = "./data/reddit_simulation.db"
178+
179+
# Delete the old database
180+
if os.path.exists(db_path):
181+
os.remove(db_path)
182+
183+
# Make the environment
184+
env = oasis.make(
185+
agent_graph=agent_graph,
186+
platform=oasis.DefaultPlatformType.REDDIT,
187+
database_path=db_path,
188+
)
189+
190+
# Run the environment
191+
await env.reset()
192+
193+
actions_1 = {}
194+
actions_1[env.agent_graph.get_agent(0)] = [
195+
ManualAction(action_type=ActionType.CREATE_POST,
196+
action_args={"content": "Hello, world!"}),
197+
ManualAction(action_type=ActionType.CREATE_COMMENT,
198+
action_args={
199+
"post_id": "1",
200+
"content": "Welcome to the OASIS World!"
201+
})
202+
]
203+
actions_1[env.agent_graph.get_agent(1)] = ManualAction(
204+
action_type=ActionType.CREATE_COMMENT,
205+
action_args={
206+
"post_id": "1",
207+
"content": "I like the OASIS world."
208+
})
209+
await env.step(actions_1)
210+
211+
actions_2 = {
212+
agent: LLMAction()
213+
for _, agent in env.agent_graph.get_agents()
214+
}
215+
216+
# Perform the actions
217+
await env.step(actions_2)
218+
219+
# Close the environment
220+
await env.close()
221+
188222

189223
if __name__ == "__main__":
190-
asyncio.run(main())
224+
asyncio.run(main())
191225
```
192226

193227
<br>
@@ -210,14 +244,14 @@ To discover how to create profiles for large-scale users, as well as how to visu
210244
> We welcome community contributions! Join us in building these exciting features.
211245
212246
- [Support Multi Modal Platform](https://github.com/camel-ai/oasis/issues/47)
213-
- [Connect to the Real World](https://github.com/camel-ai/oasis/issues/79)
214247

215248
<!-- - Public release of our dataset on Hugging Face (November 05, 2024) -->
216249

217250
### Latest Updates
218251

219-
πŸ“’ Refactor into the OASIS environment, publish camel-oasis on PyPI, and release the documentation. - πŸ“† April 24, 2025
252+
πŸ“’ Add a new feature to customize each agent's models, tools, and prompts, and refactor the interface to follow the PettingZoo style. - πŸ“† May 22, 2025
220253

254+
- Refactor into the OASIS environment, publish camel-oasis on PyPI, and release the documentation. - πŸ“† April 24, 2025
221255
- Support OPENAI Embedding model for Twhin-Bert Recommendation System. - πŸ“† March 25, 2025
222256
- Updated social media links and QR codes in the README! Join OASIS & CAMEL on WeChat, X, Reddit, and Discord. - πŸ“† March 24, 2025
223257
- Add multi-threading support to speed up LLM inference by 13x - πŸ“† March 4, 2025

0 commit comments

Comments
Β (0)