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

Chat example using structured output from openai #1611

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JamesHWade
Copy link

This PR introduces a new example app demonstrating Shiny's chat capabilities with structured output parsing. This is what I was showing you in the workshop @cpsievert.

Key features:

  • Chat interface for recipe queries
  • Generates structured JSON output when user requests "Summarize recipe"
  • Displays formatted recipe details and JSON representation in sidebar
  • Uses OpenAI's latest gpt-4o model for chat and structured response

This example showcases how to combine chat functionality with conditional structured output, providing a practical use case for developers building similar applications in Shiny.

@schloerke schloerke added this to the v1.2.0 milestone Aug 20, 2024
@schloerke schloerke added the documentation Improvements or additions to documentation label Aug 20, 2024
shiny
shinyswatch
python-dotenv
openai
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this is the correct version, but the summarize feature wasn't working for me with 1.31.1

Suggested change
openai
openai>=1.41.1

json_str = json.dumps(recipe().dict(), indent=2)
return json_str

@reactive.Effect
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@reactive.Effect
@reactive.effect

@cpsievert
Copy link
Collaborator

cpsievert commented Aug 20, 2024

Thank you for this James, this is really great!

I left a couple suggestions, but I'll handle them myself -- I have more than a few suggestions, so I'll take care of that myself :)

@JamesHWade
Copy link
Author

Awesome! I look forward to seeing what you do with it and to learn from how you approach it.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants