0.1.4 • Published 4 months ago

@wegotdocs/react v0.1.4

Weekly downloads
-
License
-
Repository
-
Last release
4 months ago

@wegotdocs/react

Installation

npm install @wegotdocs/react

Example usage

"use client"
import { useGenerate } from "@wegotdocs/react"

export default function Generator() {
  const { submit, loading, summary, request, streamError } = useGenerate({
    endpoint: "/api/services/openai_api_2_3_0_3_0_0",
  })
  return (
    <div>
      <form
        onSubmit={(e) => {
          e.preventDefault()
          const formData = new FormData(e.target as HTMLFormElement)
          submit({
            description: formData.get("description") as string,
          })
        }}
      >
        <textarea
          name="description"
          placeholder="Describe what you want from the API"
          required
        />
        <button type="submit">Generate API Query</button>
      </form>
      {loading && !summary && <p>Loading...</p>}
      {!!summary && <p>{summary}</p>}
      {!!streamError && <p style={{ color: "red" }}>{streamError.message}</p>}
      {!!request.curl && <pre>{request.curl}</pre>}
    </div>
  )
}
0.1.4

4 months ago

0.1.3

4 months ago

0.1.2

4 months ago

0.1.1

4 months ago

0.1.0

4 months ago