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

[Example]: Use serde, schemars to make structure output code easy #301

Conversation

cptrodgers
Copy link
Contributor

Use serde and schemars to write structure output example.

@cptrodgers
Copy link
Contributor Author

Tested in local:

Screenshot 2024-12-20 at 16 39 34

@cptrodgers
Copy link
Contributor Author

Relating issue: #302

@cptrodgers cptrodgers changed the title Use serde, schemars to make structure output code easy [Example]: Use serde, schemars to make structure output code easy Dec 20, 2024
@cptrodgers cptrodgers force-pushed the examples/use-serde-and-schemars-for-structure-output branch from 63c5e4d to 404c99e Compare January 11, 2025 13:55
@cptrodgers
Copy link
Contributor Author

   Compiling structured-outputs-schemars v0.1.0 (/Users/rodgers/Working/async-openai/examples/structured-outputs-schemars)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 11.74s
     Running `/Users/rodgers/Working/async-openai/target/debug/structured-outputs-schemars`
{
  "final_answer": "x = -3.75",
  "steps": [
    {
      "output": "8x + 7 = -23",
      "explanation": "Start with the equation: 8x + 7 = -23."
    },
    {
      "output": "8x = -23 - 7",
      "explanation": "Subtract 7 from both sides to isolate the term with x."
    },
    {
      "output": "8x = -30",
      "explanation": "Calculate the right side: -23 - 7 = -30."
    },
    {
      "output": "x = -30 / 8",
      "explanation": "Now, divide both sides by 8 to solve for x."
    },
    {
      "output": "x = -3.75",
      "explanation": "Simplify -30 / 8 to find the value of x."
    }
  ]
}

Re-run to check example result.

Copy link
Owner

@64bit 64bit left a comment

Choose a reason for hiding this comment

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

Thanks, looks good!

@64bit 64bit merged commit f6792f3 into 64bit:main Jan 11, 2025
Sevenannn pushed a commit to spiceai/async-openai that referenced this pull request Mar 4, 2025
…bit#301)

* Add structured-outputs-schemars

* Upadte naming and using crates infor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants