Ducksss / HacknRoll2023-Robin-Hood

Chrome Web Extension that uses a custom GPTZero Model to automatically detect and rephrase any GPT-generated text on Notion via a single click!
MIT License
13 stars 3 forks source link

Investigate Feasibility of User-Connect vs Backend-Connect for ChatGPT Playground #17

Closed kiritowu closed 1 year ago

kiritowu commented 1 year ago

To-Dos:

kiritowu commented 1 year ago

According to this (js) and this (py) example, the only authentication to call openai's API is just the apiKey.

import { Configuration, OpenAIApi } from "openai";

const configuration = new Configuration({
  apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
import openai
openai.api_key = "sk-..."

# list engines
engines = openai.Engine.list()

# print the first engine's id
print(engines.data[0].id)

# create a completion
completion = openai.Completion.create(engine="ada", prompt="Hello world")

# print the completion
print(completion.choices[0].text)

There are two options available and the attached are the pros & cons:

  1. User use own APIKey:
    • Pros:
      1. Needless to worry about scalability and profitability (arguably we dont need to worry in first place since just hackathon)
      2. Needless for backend, everything happens in front-end (However, at current stage seems like Backend is needed for the tokenization and GPT-like detection)
    • Cons:
      1. Addtional front-end validation to ensure that the user must provide a APIKey and it is valid
  2. Use centralised APIKey:
    • Pros:
      1. It works. Can bs about the feasibility also
    • Cons
      1. Should have no latency issue but that is one small concern
      2. Have backend
kiritowu commented 1 year ago

Use Python Backend for APIKey.