Skip to content

Commit 68f6221

Browse files
committed
Use our backend for completions
1 parent 259a662 commit 68f6221

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

.env

-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ REACT_APP_MODEL_NAME="GPT-J-6B"
33
REACT_APP_MODEL_ENDPOINT_URL=
44
REACT_APP_PROMPT_SUGGESTIONS=true
55
REACT_APP_GITHUB_LINK=true
6-
REACT_APP_MODEL_ID=
7-
REACT_APP_MODEL_API_KEY=
86
REACT_APP_USE_PROXY=false

src/App.js

+5-11
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ function App() {
3030

3131
const onClickSendPromptButton = useCallback(
3232
(extraText, topP, temp) => {
33-
const ENDPOINT = !!process.env.REACT_APP_MODEL_ENDPOINT_URL ? process.env.REACT_APP_MODEL_ENDPOINT_URL : ""
34-
35-
const API_KEY = !!process.env.REACT_APP_MODEL_API_KEY ? process.env.REACT_APP_MODEL_API_KEY : ""
36-
37-
const MODEL_ID = !!process.env.REACT_APP_MODEL_ID ? process.env.REACT_APP_MODEL_ID : ""
38-
const finalUrl = !!process.env.REACT_APP_USE_PROXY
33+
const ENDPOINT = !!process.env.REACT_APP_MODEL_ENDPOINT_URL ? process.env.REACT_APP_MODEL_ENDPOINT_URL : "http://localhost:8000/completion"
34+
const finalUrl = process.env.REACT_APP_USE_PROXY === "true"
3935
? `https://cors-proxy-janko.herokuapp.com/${ENDPOINT}`
4036
: ENDPOINT
4137

@@ -46,12 +42,10 @@ function App() {
4642
method: "POST",
4743
headers: {
4844
Accept: "application/json",
49-
"Content-Type": "application/json",
50-
Authorization: `Bearer ${API_KEY}`
45+
"Content-Type": "application/json"
5146
},
5247
body: JSON.stringify({
5348
data: fullPrompt.trim(),
54-
modelId: MODEL_ID,
5549
input_kwargs: {
5650
top_p: topP,
5751
temp: temp,
@@ -64,8 +58,8 @@ function App() {
6458
.then(data => {
6559
setIsLoading(false)
6660
setErrorText("")
67-
if (data && data.result && data.result.length) {
68-
let finalText = data.result[0]?.generated_text
61+
if (data) {
62+
let finalText = data[0]?.generated_text.substring(promptText.length)
6963
if (finalText.search("<|endoftext|>") > -1) {
7064
finalText = finalText.split("<|endoftext|>")[0]
7165
}

0 commit comments

Comments
 (0)