mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-03 09:53:45 +00:00
Added the open in collab badge
This commit is contained in:
parent
1494ea5e43
commit
ac284f3f56
1 changed files with 284 additions and 4 deletions
|
|
@ -6,6 +6,8 @@
|
|||
"source": [
|
||||
"# AutoGen + Llama Stack Integration\n",
|
||||
"\n",
|
||||
"[](https://colab.research.google.com/github/meta-llama/llama-stack/blob/main/docs/notebooks/autogen/autogen_llama_stack_integration.ipynb)\n",
|
||||
"\n",
|
||||
"## Overview\n",
|
||||
"\n",
|
||||
"This notebook demonstrates how to use **AutoGen v0.7.5** with **Llama Stack** as the backend.\n",
|
||||
|
|
@ -541,7 +543,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 7,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
|
|
@ -550,7 +552,97 @@
|
|||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ Code review team created\n"
|
||||
"✅ Code review team created\n",
|
||||
"\n",
|
||||
"==================================================\n",
|
||||
"✅ Review completed in 5 message(s)\n",
|
||||
"Stop reason: Text 'LGTM' mentioned\n",
|
||||
"==================================================\n",
|
||||
"\n",
|
||||
"📝 Review Conversation Flow:\n",
|
||||
"1. [user]: Implement a Python function to check if a string is a palindrome. The Developer should implement the function first. The Reviewer should then...\n",
|
||||
"2. [Developer]: ### Initial Implementation ```python def is_palindrome(s: str) -> bool: \"\"\" Checks if a given string is a palindrome. Args: s (st...\n",
|
||||
"3. [CodeReviewer]: ### Code Review Feedback #### Bugs and Edge Cases * The function does not handle non-string inputs. It should raise a `TypeError` when given a non-st...\n",
|
||||
"4. [Developer]: ### Revised Implementation ```python def is_palindrome(s: str, ignore_case: bool = True, ignore_whitespace_and_punctuation: bool = True) -> bool: ...\n",
|
||||
"5. [CodeReviewer]: ### Code Review Feedback The revised implementation has addressed all the concerns raised during the initial code review. Here's a summary of the key...\n",
|
||||
"\n",
|
||||
"==================================================\n",
|
||||
"Final Code (last message):\n",
|
||||
"==================================================\n",
|
||||
"### Code Review Feedback\n",
|
||||
"\n",
|
||||
"The revised implementation has addressed all the concerns raised during the initial code review. Here's a summary of the key points:\n",
|
||||
"\n",
|
||||
"* **Type checking**: The function now correctly raises a `TypeError` if the input is not a string.\n",
|
||||
"* **Optional parameters**: The addition of optional parameters for ignoring case and whitespace/punctuation provides flexibility in how palindromes are checked.\n",
|
||||
"* **Preprocessing**: The preprocessing steps to ignore case and remove non-alphanumeric characters are implemented correctly and efficiently.\n",
|
||||
"* **Efficient palindrome check**: The two-pointer approach used to compare characters from both ends of the string is efficient, with a time complexity of O(n).\n",
|
||||
"* **Documentation and examples**: The docstring has been improved with clear explanations and examples, making it easier for users to understand how to use the function.\n",
|
||||
"\n",
|
||||
"#### Minor Suggestions\n",
|
||||
"\n",
|
||||
"1. **Input Validation**: Consider adding input validation for the optional parameters `ignore_case` and `ignore_whitespace_and_punctuation`. Currently, they are expected to be boolean values, but there is no explicit check for this.\n",
|
||||
"2. **Type Hints for Optional Parameters**: While not required, adding type hints for the optional parameters can improve code readability and help catch potential errors.\n",
|
||||
"\n",
|
||||
"#### Revised Implementation with Minor Suggestions\n",
|
||||
"\n",
|
||||
"```python\n",
|
||||
"def is_palindrome(s: str, ignore_case: bool = True, ignore_whitespace_and_punctuation: bool = True) -> bool:\n",
|
||||
" \"\"\"\n",
|
||||
" Checks if a given string is a palindrome.\n",
|
||||
"\n",
|
||||
" Args:\n",
|
||||
" s (str): The input string to check.\n",
|
||||
" ignore_case (bool): Whether to ignore case when checking for palindromes. Defaults to True.\n",
|
||||
" ignore_whitespace_and_punctuation (bool): Whether to ignore whitespace and punctuation when checking for palindromes. Defaults to True.\n",
|
||||
"\n",
|
||||
" Returns:\n",
|
||||
" bool: True if the string is a palindrome, False otherwise.\n",
|
||||
"\n",
|
||||
" Raises:\n",
|
||||
" TypeError: If s is not a string or if ignore_case/ignore_whitespace_and_punctuation are not boolean values.\n",
|
||||
"\n",
|
||||
" Examples:\n",
|
||||
" >>> is_palindrome(\"radar\")\n",
|
||||
" True\n",
|
||||
" >>> is_palindrome(\"hello\")\n",
|
||||
" False\n",
|
||||
" >>> is_palindrome(\"A man, a plan, a canal: Panama\", ignore_whitespace_and_punctuation=True)\n",
|
||||
" True\n",
|
||||
" \"\"\"\n",
|
||||
" # Check input type\n",
|
||||
" if not isinstance(s, str):\n",
|
||||
" raise TypeError(\"Input must be a string\")\n",
|
||||
" \n",
|
||||
" # Validate optional parameters\n",
|
||||
" if not isinstance(ignore_case, bool) or not isinstance(ignore_whitespace_and_punctuation, bool):\n",
|
||||
" raise TypeError(\"Optional parameters must be boolean values\")\n",
|
||||
"\n",
|
||||
" # Preprocess the string based on options\n",
|
||||
" if ignore_case:\n",
|
||||
" s = s.casefold()\n",
|
||||
" if ignore_whitespace_and_punctuation:\n",
|
||||
" s = ''.join(c for c in s if c.isalnum())\n",
|
||||
"\n",
|
||||
" # Compare characters from both ends of the string, moving towards the center\n",
|
||||
" left, right = 0, len(s) - 1\n",
|
||||
" while left < right:\n",
|
||||
" if s[left] != s[right]:\n",
|
||||
" return False\n",
|
||||
" left += 1\n",
|
||||
" right -= 1\n",
|
||||
" return True\n",
|
||||
"\n",
|
||||
"# Example usage:\n",
|
||||
"if __name__ == \"__main__\":\n",
|
||||
" print(is_palindrome(\"radar\")) # Expected output: True\n",
|
||||
" print(is_palindrome(\"hello\")) # Expected output: False\n",
|
||||
" print(is_palindrome(\"A man, a plan, a canal: Panama\", ignore_whitespace_and_punctuation=True)) # Expected output: True\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"With these minor suggestions addressed, the code is robust and follows best practices for readability, maintainability, and error handling.\n",
|
||||
"\n",
|
||||
"LGTM!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
@ -640,11 +732,199 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 8,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"✅ Documentation team created\n",
|
||||
"\n",
|
||||
"==================================================\n",
|
||||
"Generated Documentation:\n",
|
||||
"==================================================\n",
|
||||
"Turn 1\n",
|
||||
"Create documentation for a hypothetical food recipe:\n",
|
||||
"\n",
|
||||
" Food: `Cheese Pizza`\n",
|
||||
"\n",
|
||||
" Include:\n",
|
||||
" - Description\n",
|
||||
" - Ingredients\n",
|
||||
" - How to make it\n",
|
||||
" - Steps\n",
|
||||
" \n",
|
||||
"Turn 2\n",
|
||||
"**Cheese Pizza Recipe Documentation**\n",
|
||||
"=====================================\n",
|
||||
"\n",
|
||||
"### Description\n",
|
||||
"\n",
|
||||
"A classic Cheese Pizza is a delicious and satisfying dish that consists of a crispy crust topped with a rich tomato sauce, melted mozzarella cheese, and various seasonings. This recipe provides a simple and easy-to-follow guide to making a mouth-watering Cheese Pizza at home.\n",
|
||||
"\n",
|
||||
"### Ingredients\n",
|
||||
"\n",
|
||||
"* **Crust:**\n",
|
||||
"\t+ 2 cups of warm water\n",
|
||||
"\t+ 1 tablespoon of sugar\n",
|
||||
"\t+ 2 teaspoons of active dry yeast\n",
|
||||
"\t+ 3 cups of all-purpose flour\n",
|
||||
"\t+ 1 teaspoon of salt\n",
|
||||
"\t+ 2 tablespoons of olive oil\n",
|
||||
"* **Sauce:**\n",
|
||||
"\t+ 2 cups of crushed tomatoes\n",
|
||||
"\t+ 1/4 cup of olive oil\n",
|
||||
"\t+ 4 cloves of garlic, minced\n",
|
||||
"\t+ 1 teaspoon of dried oregano\n",
|
||||
"\t+ Salt and pepper to taste\n",
|
||||
"* **Toppings:**\n",
|
||||
"\t+ 8 ounces of mozzarella cheese, shredded\n",
|
||||
"\t+ Fresh basil leaves, chopped (optional)\n",
|
||||
"\n",
|
||||
"### How to Make It\n",
|
||||
"\n",
|
||||
"To make a Cheese Pizza, follow these steps:\n",
|
||||
"\n",
|
||||
"#### Steps\n",
|
||||
"\n",
|
||||
"1. **Activate the Yeast:**\n",
|
||||
"\t* In a large bowl, combine the warm water, sugar, and yeast.\n",
|
||||
"\t* Stir gently to dissolve the yeast, and let it sit for 5-10 minutes until frothy.\n",
|
||||
"2. **Make the Crust:**\n",
|
||||
"\t* Add the flour, salt, and olive oil to the bowl with the yeast mixture.\n",
|
||||
"\t* Mix the dough until it comes together in a ball.\n",
|
||||
"\t* Knead the dough on a floured surface for 5-10 minutes until smooth and elastic.\n",
|
||||
"3. **Prepare the Sauce:**\n",
|
||||
"\t* In a separate bowl, combine the crushed tomatoes, olive oil, garlic, oregano, salt, and pepper.\n",
|
||||
"\t* Mix well to create a smooth sauce.\n",
|
||||
"4. **Assemble the Pizza:**\n",
|
||||
"\t* Preheat the oven to 425°F (220°C).\n",
|
||||
"\t* Roll out the dough into a circle or rectangle shape, depending on your preference.\n",
|
||||
"\t* Place the dough on a baking sheet or pizza stone.\n",
|
||||
"\t* Spread the tomato sauce evenly over the dough, leaving a small border around the edges.\n",
|
||||
"5. **Add the Cheese:**\n",
|
||||
"\t* Sprinkle the shredded mozzarella cheese over the sauce.\n",
|
||||
"6. **Bake the Pizza:**\n",
|
||||
"\t* Bake the pizza in the preheated oven for 15-20 minutes until the crust is golden brown and the cheese is melted and bubbly.\n",
|
||||
"7. **Garnish with Fresh Basil (Optional):**\n",
|
||||
"\t* Remove the pizza from the oven and sprinkle chopped fresh basil leaves over the top, if desired.\n",
|
||||
"\n",
|
||||
"### Tips and Variations\n",
|
||||
"\n",
|
||||
"* For a crispy crust, bake the pizza for an additional 2-3 minutes.\n",
|
||||
"* Add other toppings such as pepperoni, sausage, or mushrooms to create a unique flavor combination.\n",
|
||||
"* Use different types of cheese, such as cheddar or parmesan, for a varied flavor profile.\n",
|
||||
"\n",
|
||||
"Enjoy your delicious homemade Cheese Pizza!\n",
|
||||
"Turn 3\n",
|
||||
"**Cheese Pizza Recipe Documentation**\n",
|
||||
"=====================================\n",
|
||||
"\n",
|
||||
"### Description\n",
|
||||
"\n",
|
||||
"A classic Cheese Pizza is a delicious and satisfying dish that consists of a crispy crust topped with a rich tomato sauce, melted mozzarella cheese, and various seasonings. This recipe provides a simple and easy-to-follow guide to making a mouth-watering Cheese Pizza at home.\n",
|
||||
"\n",
|
||||
"### Ingredients\n",
|
||||
"\n",
|
||||
"* **Crust:**\n",
|
||||
"\t+ 2 cups of warm water\n",
|
||||
"\t+ 1 tablespoon of sugar\n",
|
||||
"\t+ 2 teaspoons of active dry yeast\n",
|
||||
"\t+ 3 cups of all-purpose flour\n",
|
||||
"\t+ 1 teaspoon of salt\n",
|
||||
"\t+ 2 tablespoons of olive oil\n",
|
||||
"* **Sauce:**\n",
|
||||
"\t+ 2 cups of crushed tomatoes\n",
|
||||
"\t+ 1/4 cup of olive oil\n",
|
||||
"\t+ 4 cloves of garlic, minced\n",
|
||||
"\t+ 1 teaspoon of dried oregano\n",
|
||||
"\t+ Salt and pepper to taste\n",
|
||||
"* **Toppings:**\n",
|
||||
"\t+ 8 ounces of mozzarella cheese, shredded\n",
|
||||
"\t+ Fresh basil leaves, chopped (optional)\n",
|
||||
"\n",
|
||||
"### How to Make It\n",
|
||||
"\n",
|
||||
"To make a Cheese Pizza, follow these steps:\n",
|
||||
"\n",
|
||||
"#### Steps\n",
|
||||
"\n",
|
||||
"1. **Activate the Yeast:**\n",
|
||||
"\t* In a large bowl, combine the warm water, sugar, and yeast.\n",
|
||||
"\t* Stir gently to dissolve the yeast, and let it sit for 5-10 minutes until frothy.\n",
|
||||
"2. **Make the Crust:**\n",
|
||||
"\t* Add the flour, salt, and olive oil to the bowl with the yeast mixture.\n",
|
||||
"\t* Mix the dough until it comes together in a ball.\n",
|
||||
"\t* Knead the dough on a floured surface for 5-10 minutes until smooth and elastic.\n",
|
||||
"3. **Prepare the Sauce:**\n",
|
||||
"\t* In a separate bowl, combine the crushed tomatoes, olive oil, garlic, oregano, salt, and pepper.\n",
|
||||
"\t* Mix well to create a smooth sauce.\n",
|
||||
"4. **Assemble the Pizza:**\n",
|
||||
"\t* Preheat the oven to 425°F (220°C).\n",
|
||||
"\t* Roll out the dough into a circle or rectangle shape, depending on your preference.\n",
|
||||
"\t* Place the dough on a baking sheet or pizza stone.\n",
|
||||
"\t* Spread the tomato sauce evenly over the dough, leaving a small border around the edges.\n",
|
||||
"5. **Add the Cheese:**\n",
|
||||
"\t* Sprinkle the shredded mozzarella cheese over the sauce.\n",
|
||||
"6. **Bake the Pizza:**\n",
|
||||
"\t* Bake the pizza in the preheated oven for 15-20 minutes until the crust is golden brown and the cheese is melted and bubbly.\n",
|
||||
"7. **Garnish with Fresh Basil (Optional):**\n",
|
||||
"\t* Remove the pizza from the oven and sprinkle chopped fresh basil leaves over the top, if desired.\n",
|
||||
"\n",
|
||||
"### Tips and Variations\n",
|
||||
"\n",
|
||||
"* For a crispy crust, bake the pizza for an additional 2-3 minutes.\n",
|
||||
"* Add other toppings such as pepperoni, sausage, or mushrooms to create a unique flavor combination.\n",
|
||||
"* Use different types of cheese, such as cheddar or parmesan, for a varied flavor profile.\n",
|
||||
"\n",
|
||||
"Enjoy your delicious homemade Cheese Pizza!\n",
|
||||
"Turn 4\n",
|
||||
"It seems like you've copied the entire Cheese Pizza Recipe Documentation I provided earlier. If you'd like to make any changes or additions to the recipe, or if you have any questions about it, feel free to ask and I'll be happy to help! \n",
|
||||
"\n",
|
||||
"If you're looking for some suggestions on how to improve the documentation, here are a few ideas:\n",
|
||||
"\n",
|
||||
"1. **Add nutritional information**: Providing the nutritional content of the Cheese Pizza, such as calories, fat, carbohydrates, and protein, can be helpful for people who are tracking their diet.\n",
|
||||
"2. **Include images or diagrams**: Adding images or diagrams of the different steps in the recipe can help to clarify the process and make it easier to follow.\n",
|
||||
"3. **Provide variations for special diets**: Offering suggestions for how to modify the recipe to accommodate special dietary needs, such as gluten-free or vegan, can make the recipe more accessible to a wider range of people.\n",
|
||||
"4. **Add a troubleshooting section**: Including a section that addresses common problems or issues that may arise during the cooking process, such as a crust that's too thick or cheese that's not melting properly, can help to ensure that the recipe turns out well.\n",
|
||||
"\n",
|
||||
"Let me know if you have any other questions or if there's anything else I can help with!\n",
|
||||
"Turn 5\n",
|
||||
"I apologize for copying the entire documentation earlier. You're right; it would be more helpful to provide suggestions or improvements to the existing recipe. Here are some potential additions and modifications:\n",
|
||||
"\n",
|
||||
"1. **Nutritional Information:**\n",
|
||||
"\t* Calculating the nutritional content of the Cheese Pizza could involve breaking down the ingredients and their corresponding calorie, fat, carbohydrate, and protein contributions.\n",
|
||||
"\t* For example:\n",
|
||||
"\t\t+ Crust (2 cups flour, 1 teaspoon sugar, 1/4 cup olive oil): approximately 300-350 calories, 10-12g fat, 50-60g carbohydrates, 10-12g protein\n",
|
||||
"\t\t+ Sauce (2 cups crushed tomatoes, 1/4 cup olive oil, 4 cloves garlic, 1 teaspoon dried oregano): approximately 100-150 calories, 10-12g fat, 20-25g carbohydrates, 5-7g protein\n",
|
||||
"\t\t+ Cheese (8 ounces mozzarella): approximately 200-250 calories, 15-18g fat, 5-7g carbohydrates, 20-25g protein\n",
|
||||
"\t* Total estimated nutritional content: approximately 600-750 calories, 35-42g fat, 75-92g carbohydrates, 35-44g protein (per serving)\n",
|
||||
"2. **Images and Diagrams:**\n",
|
||||
"\t* Adding images of the different steps in the recipe could help illustrate the process, such as:\n",
|
||||
"\t\t+ A photo of the yeast mixture after it has sat for 5-10 minutes\n",
|
||||
"\t\t+ An image of the dough being kneaded on a floured surface\n",
|
||||
"\t\t+ A diagram showing how to roll out the dough into a circle or rectangle shape\n",
|
||||
"3. **Variations for Special Diets:**\n",
|
||||
"\t* Gluten-free crust option:\n",
|
||||
"\t\t+ Replace all-purpose flour with gluten-free flour blend (containing rice flour, potato starch, and tapioca flour)\n",
|
||||
"\t\t+ Add xanthan gum to help improve texture and structure\n",
|
||||
"\t* Vegan cheese alternative:\n",
|
||||
"\t\t+ Use vegan mozzarella cheese or soy-based cheese alternative\n",
|
||||
"\t\t+ Consider adding nutritional yeast for a cheesy flavor\n",
|
||||
"4. **Troubleshooting Section:**\n",
|
||||
"\t* Common issues with the crust:\n",
|
||||
"\t\t+ Too thick: try reducing the amount of flour or increasing the yeast fermentation time\n",
|
||||
"\t\t+ Too thin: try increasing the amount of flour or adding more water\n",
|
||||
"\t* Issues with the cheese melting:\n",
|
||||
"\t\t+ Not melting properly: try broiling the pizza for an additional 1-2 minutes or using a higher-quality mozzarella cheese\n",
|
||||
"\n",
|
||||
"Please let me know if you'd like to discuss any of these suggestions further or if there's anything else I can help with!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Create documentation team\n",
|
||||
"doc_researcher = AssistantAgent(\n",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue