autogen
autogen copied to clipboard
Prominent example on using JSON mode
We need a very prominent example of using JSON mode -- either by OpenAI API or using constrained encoding like Guidance. It is important for using GroupChat and many have asked for it:
Hello @ekzhu,
I came across this issue while navigating through GitHub and noticed there's an interest in seeing a prominent example of JSON mode in action, especially for GroupChat applications.
Having some experience with OpenAI's API, I thought I might contribute a simple but illustrative example. Here's how you could structure a JSON payload to interact with an AI in a GroupChat setting:
{
"model": "gpt-3.5-turbo",
"prompt": "You are an AI present in a professional group chat. Your role is to assist users by providing accurate technical support. Keep your responses concise and informative.",
"temperature": 0.7,
"max_tokens": 250,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0,
"stop": ["\n"]
}
This example showcases how you might instruct the AI to behave in a helpful and professional manner within a chat. The stop
parameter is particularly useful to control the end of the AI's response, which in this case, is set to cease upon reaching a new line.
For those inquiring about the use of constrained encoding like Guidance, this could involve additional fields within the JSON to dictate the dos and don'ts explicitly for the AI, ensuring it stays within the bounds of the intended conversation topic.
If there's a specific scenario or constraints you're curious about, or if the group could use a more detailed run-through of these examples, I'd be glad to expand on this. Feel free to point out any specific requirements, and I'll do my best to tailor the example accordingly.
Hope this helps, and I'm here if you need any further clarification!
I've written a fair bit about JSON mode. very happy to collaborate with JZ and/or whomever else for a notebook & blog post.
JSON mode for solving order of operations issues: https://www.linkedin.com/pulse/solving-ai-reasoning-flaws-leah-bonser-w76uc
JSON mode and FSM for smooth speaker transition: https://www.linkedin.com/pulse/pseudo-weights-bias-implementation-graph-sequence-multi-leah-bonser-xwe8c
I'm also about to start on an article about Task Decomposition, that will make heavy use of JSON as well. Happy to turn that into an example for AG as well.
Task Decomposition,
i would be quite keen + will make the time if you maybe might consider working together on a prominent example using JSON mode
but maybe for a "planner" (like in semantic-kernel
could be really interesting
Hey yeah that sounds good. I haven't looked into semantic kernel that much, but I've quickly looked over the planner function and, yeah 100% thats what I've done.
I've been experimenting with hierarchical task decomp, so each planner agent is typically only going to break the task down into a handful of steps, but more specialised planner further down the branch with break it down further if that makes sense.
I'm also about to start on an article about Task Decomposition, that will make heavy use of JSON as well. Happy to turn that into an example for AG as well.
Looking forward to it @Aretai-Leah
I'm also about to start on an article about Task Decomposition, that will make heavy use of JSON as well. Happy to turn that into an example for AG as well
Is your article already available? :-)
hey, the first one with a simple JSON mode is just about ready. I can probably have the decomp one done in a few days.
Ok. Really dumb question. I've got a draft notebook for JSON mode. How do share it here? Notebooks aren't allowed as attachments. Apologies, very new this kind of thing.
Ok. Really dumb question. I've got a draft notebook for JSON mode. How do share it here? Notebooks aren't allowed as attachments. Apologies, very new this kind of thing.
Not dumb it's great . so if you make a branch with this notebook in the examples folder , you can link it once it's published, but the best would be to make a PR based on this issue , because it's slightly easier to access the file(s)
Ah, I'm not a collaborator yet.
Nevertheless, I've zipped up the notebook here if anyone wants to test. JSON_mode_ag_example.zip
Thanks @Aretai-Leah looking forward to a PR for the notebook.
@ekzhu Draft PR here: https://github.com/microsoft/autogen/pull/2554
Was just chatting to Tonic. We could jazz it up a bit. update the output so it conforms to a spec like csv then have a function save it as csv. But the point with this one was to be very simple, focusing on the interactions between JSON and the agent Description.