Skip to content

Commit eec2a1b

Browse files
committed
new completion endpoint
1 parent dadd16c commit eec2a1b

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

src/main.tsx

+14-17
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ import axios from 'axios'
44

55
import { SimliClient } from './SimliClient'
66

7-
const oai =
8-
(import.meta.env.VITE_OPENAI_API_KEY !== '' && import.meta.env.VITE_OPENAI_API_KEY) ||
9-
'sk-' + 'IJIqeGXk0LyYkBIAPFkET3BlbkFJWBZSrG2KMgApy3xUi9uH'
10-
const sk =
11-
(import.meta.env?.VITE_SIMLI_API_KEY !== '' && import.meta.env?.VITE_SIMLI_API_KEY) ||
12-
'dlqhn6n14udwl4z3v66pn'
13-
const e11 =
14-
(import.meta.env?.VITE_ELEVENLABS_API_KEY !== '' && import.meta.env?.VITE_SIMLI_API_KEY) ||
15-
'sk_' + 'db6b7ebae17ee002ca26b741b55ae505545f5235149999f4'
7+
const oai = import.meta.env.VITE_OPENAI_API_KEY
8+
const sk = import.meta.env.VITE_SIMLI_API_KEY
9+
const e11 = import.meta.env.VITE_ELEVENLABS_API_KEY
10+
11+
const completionEndpoint = import.meta.env?.VITE_COMPLETION_ENDPOINT || 'http://localhost:3000'
1612

1713
import './styles.css'
1814

@@ -104,21 +100,22 @@ const App = () => {
104100

105101
try {
106102
const chatGPTResponse = await axios.post(
107-
'https://api.openai.com/v1/chat/completions',
103+
completionEndpoint + '/eliza/message',
108104
{
109-
model: 'gpt-4o-mini',
110-
messages: [{ role: 'user', content: text }],
105+
text,
111106
},
112107
{
113-
headers: {
114-
'Authorization': `Bearer ${oai}`,
115-
'Content-Type': 'application/json',
116-
},
117108
cancelToken: cancelTokenRef.current.token,
118109
}
119110
)
120111

121-
const chatGPTText = chatGPTResponse.data.choices[0].message.content
112+
console.log('chatGPTResponse', chatGPTResponse)
113+
114+
const chatGPTText = chatGPTResponse.data.text
115+
if (!chatGPTText || chatGPTText.length === 0) {
116+
setError('No response from chatGPT. Please try again.')
117+
return
118+
}
122119
setChatgptText(chatGPTText)
123120

124121
const elevenlabsResponse = await axios.post(

0 commit comments

Comments
 (0)