-
-
Notifications
You must be signed in to change notification settings - Fork 19
Add first mesa-llm model tutorial #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @colinfrisch, I’ve created a Mesa LLM tutorial to help newcomers. Would appreciate you taking a look! |
|
Thanks a lot for your contribution, it's a very good start ! Could you make a model (and tutorial that would go with it) that would showcase the reasoning part a little more ? Looking forward to review and merge this PR :) |
|
Hi @colinfrisch That makes sense — I’ll extend the model slightly to make the reasoning step more explicit (e.g. by prompting agents to reason about the situation before deciding on an action) and update the tutorial accordingly. I’ll push an update shortly. Thanks again! |
colinfrisch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Essentially, you have not used any code from the mesa-llm library here, please try to build a working model yourself to check out how this library works before contributing as this is supposed to be a tutorial for mesa-llm. Also please be careful what tools you use. An excessive use of AI can result in a temporary ban for the mesa ecosystem and have definitive consequences on GSoC.
docs/first_model.md
Outdated
| * OpenAI | ||
| * Anthropic | ||
| * xAI | ||
| * Huggingface | ||
| * Ollama | ||
| * OpenRouter | ||
| * NovitaAI | ||
| * Gemini |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary here, supported models are already in the docs
docs/first_model.md
Outdated
| ```python | ||
| import mesa_llm | ||
| import mesa | ||
| import ollama |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will add ollama dependency directly in mesa-llm. No need to put it here
docs/first_model.md
Outdated
| The generated response is treated as the agent’s reasoning output and printed directly, allowing us to observe how different agents interpret the same simulation context. | ||
| The LanguageAgent class is created with the following code: | ||
| ```python | ||
| class LanguageAgent(mesa.Agent): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole point of this tutorial is to use LLMAgent. Please refer to the existing example models to build your tutorial (also please do not use AI)
|
Hi @colinfrisch |
|
Thank you, this is starting to look good ! Last step would be to make this a model that has a small purpose. What I suggest would be a small (and tutorial friendly) version of the negotiation model that you can find in the example folder of this repo Of course, if you find something else that still showcases mesa-llm well and stays simple while being useful, I'm open to ideas :) |
|
Thank you for the feedback. I’ll go with a negotiation model, since I’m already familiar with this setup from the existing example and feel confident using it to clearly demonstrate how LLM agents reason and interact. I’ll keep the model small and tutorial-friendly while focusing on clarity and purpose |
|
Hi @colinfrisch Can I work on issue #31 while you review my PR? |
|
Yes of course, you can work on any subject you like (you can check out some prs that were opened and merged on #31). I'll review this one asap |
colinfrisch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's starting to look like something we could merge ! Little suggestions down below. Also, for the negotiation tutorial, I think that it would be the right place to demonstrate the messaging system between agents : if you can manage to make use of it and make it tutorial friendly, it would be great !
Last thing also : when you write code in your tutorials, don't hesitate to add a lot of comments to explain directly in the code the role of each function/method/attribute, etc.
docs/first_model.md
Outdated
| # Creating Your First mesa-llm Model | ||
|
|
||
| ## Tutorial Overview | ||
| This tutorial introduces mesa-llm by walking through the construction of a simple language-driven agent model built on top of Mesa. Mesa-llm enables agents to reason using natural language while preserving Mesa’s standard execution model. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| This tutorial introduces mesa-llm by walking through the construction of a simple language-driven agent model built on top of Mesa. Mesa-llm enables agents to reason using natural language while preserving Mesa’s standard execution model. | |
| This tutorial introduces mesa-llm by walking through the construction of a simple language-driven agent model built on top of Mesa. Mesa-llm enables agents to reason using natural language while preserving Mesa’s standard execution model. If it's your first time using mesa, we suggest starting with the classic [creating your first model tutorials](https://mesa.readthedocs.io/latest/tutorials/0_first_model.html) before diving into mesa-llm. |
docs/first_model.md
Outdated
| selected_tools=[] | ||
| ) | ||
|
|
||
| print(plan) | ||
| ``` | ||
| **Note on `selected_tools`:** | ||
| In this tutorial, `selected_tools=[]` indicates that the agent is reasoning | ||
| without access to any external tools. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we don't use tools in this tutorial, we don't have to talk about it here. By default it's None so you can simply remove it. We will probably make a whole tutorial dedicated to it.
docs/first_model.md
Outdated
| ## Create the Model | ||
| The model manages agent creation and advances the simulation. | ||
|
|
||
| mesa-llm provides the create_agents() helper, which correctly initializes agents and registers them with Mesa’s internal AgentSet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mesa-LLM does not provide the create_agents() helper, it comes directly from the Mesa base ecosystem. LLMAgent is a wrapper of Agent (that is why we use super().__init__(*args, **kwargs) when initialising our agents). Also please use the ` quotes when you are talking about specific attributes or methods to explicitly show that it's code.
| - In this introductory tutorial, action suggestions are not executed. | ||
| - Actions are shown only as part of the reasoning trace. | ||
| - Environments and action execution are introduced in later tutorials. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you maybe add a small exercise like in the mesa first model tutorial ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! I’ll add a small exercise section at the end of the tutorial, similar to Mesa’s first model tutorial.
|
Thanks for the clarification! I’ve updated the documentation to clearly state that create_agents() comes from Mesa, clarified the relationship between LLMAgent and Agent, and fixed code formatting using backticks. |
This PR adds a new “first model” tutorial for mesa-llm, following the structure and level of detail of Mesa’s Creating Your First Model tutorial, but with content focused specifically on mesa-llm concepts.
What this tutorial covers
Notes
I’ve addressed the feedback from the earlier review by:
I’d appreciate another review when you have time. Thanks!