Socket
Socket
Sign inDemoInstall

graphiql-plugin-chatgpt

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    graphiql-plugin-chatgpt

Graphiql ChatGPT plugin


Version published
Maintainers
1
Created

Readme

Source

GraphiQL ChatGPT plugin

npm

A GraphiQL plugin to get a generated query based on the current query via ChatGPT API.

Screenshot

Install

Use your favorite package manager to install the package:

# yarn
yarn add graphiql-plugin-chatgpt

# npm
npm install --save graphiql-plugin-chatgpt

The following packages are peer dependencies, so make sure you have them installed as well:

#yarn
yarn add react react-dom graphql @graphiql/react

#npm
npm install --save react react-dom graphql @graphiql/react

Usage

import { useChatGPTPlugin } from "graphiql-plugin-chatgpt"

import "graphiql-plugin-chatgpt/dist/graphiql-plugin-chatgpt.css"

function App() {
  // ...
  const chatGPTPlugin = useChatGPTPlugin({
    config: { provider: "openai", apiKey: getOpenAIApiKey() },
    userId: getUserId(),
    query: query,
    onEdit: setQuery,
  });
  
  return (
    <GraphiQL
      query={query}
      onEditQuery={setQuery}
      plugins={[chatGPTPlugin]}
    />
  );
}

Props

fieldrequiredtypedescription
configtrueOpenAIProviderConfigAPI service config
querytruestringCurrent query
userIdtruestringUser identifier (required to prevent side-effects from other users run)
onEdittrue(query: string)=>voidQuery setter function (run on Set query button click)

Types

export type OpenAIProviderConfig = DefaultOpenAIProviderConfig | AzureOpenAIProviderConfig

// You can use your OpenAI api key
// https://platform.openai.com/account/api-keys
type DefaultOpenAIProviderConfig = {
  provider: "openai"
  apiKey: string
}

type AzureOpenAIProviderConfig = {
  provider: "azure"
  apiKey: string
  endpoint: string
  apiVersion: string
}

Credits

This project was highly inspired from the @cx0's hackathon project (https://github.com/cx0/chatGPT-for-genetics)

Keywords

FAQs

Last updated on 06 Jul 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc