Skip to content
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

Prominent example on using JSON mode #2224

Closed
ekzhu opened this issue Mar 31, 2024 · 13 comments · Fixed by #2554
Closed

Prominent example on using JSON mode #2224

ekzhu opened this issue Mar 31, 2024 · 13 comments · Fixed by #2554
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed

Comments

@ekzhu
Copy link
Collaborator

ekzhu commented Mar 31, 2024

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:
image
image

@ekzhu ekzhu added documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed labels Mar 31, 2024
@RedBeret
Copy link

RedBeret commented Apr 1, 2024

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!

@Aretai-Leah
Copy link
Collaborator

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.

@Josephrp
Copy link
Collaborator

Josephrp commented Apr 2, 2024

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

@Aretai-Leah
Copy link
Collaborator

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.

@ekzhu
Copy link
Collaborator Author

ekzhu commented Apr 4, 2024

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

@ChristianWeyer
Copy link
Collaborator

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? :-)

@Aretai-Leah
Copy link
Collaborator

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.

@Aretai-Leah
Copy link
Collaborator

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.

@Josephrp
Copy link
Collaborator

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)

@Aretai-Leah
Copy link
Collaborator

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

@ekzhu
Copy link
Collaborator Author

ekzhu commented Apr 30, 2024

Thanks @Aretai-Leah looking forward to a PR for the notebook.

@Aretai-Leah
Copy link
Collaborator

@ekzhu Draft PR here: #2554

@Aretai-Leah
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@ekzhu @ChristianWeyer @RedBeret @Josephrp @Aretai-Leah and others