fa2c085c by Jonille Arreglo

27157

1 parent f9fcdbe6
Showing 1 changed file with 11 additions and 5 deletions
...@@ -66,7 +66,6 @@ app.post('/api', async (req, res) => { ...@@ -66,7 +66,6 @@ app.post('/api', async (req, res) => {
66 }); 66 });
67 let input = response.data.choices[0].text; 67 let input = response.data.choices[0].text;
68 res.json({ 68 res.json({
69 input: input,
70 message: anchorme({ 69 message: anchorme({
71 input, 70 input,
72 options: { 71 options: {
...@@ -93,7 +92,7 @@ app.post('/api', async (req, res) => { ...@@ -93,7 +92,7 @@ app.post('/api', async (req, res) => {
93 async function runGPTTurbo(req, res) { 92 async function runGPTTurbo(req, res) {
94 // "gpt-3.5-turbo" 93 // "gpt-3.5-turbo"
95 const { message, currentModel, temperature } = req.body; 94 const { message, currentModel, temperature } = req.body;
96 var returnMessage = ''; 95 var input = '';
97 try { 96 try {
98 const response = await openai.createChatCompletion({ 97 const response = await openai.createChatCompletion({
99 model: `${currentModel}`, 98 model: `${currentModel}`,
...@@ -101,18 +100,25 @@ async function runGPTTurbo(req, res) { ...@@ -101,18 +100,25 @@ async function runGPTTurbo(req, res) {
101 max_tokens: 3000, 100 max_tokens: 3000,
102 temperature 101 temperature
103 }); 102 });
104 returnMessage = response.data.choices[0].message.content 103 input = response.data.choices[0].message.content
105 } catch (e) { 104 } catch (e) {
106 let error_msg = e.response.data.error.message ? e.response.data.error.message : ''; 105 let error_msg = e.response.data.error.message ? e.response.data.error.message : '';
107 if (error_msg.indexOf('maximum context length')>=0){ 106 if (error_msg.indexOf('maximum context length')>=0){
108 returnMessage = "The output for your prompt is too long for us to process. Please reduce your prompt and try again."; 107 input = "The output for your prompt is too long for us to process. Please reduce your prompt and try again.";
109 }else{ 108 }else{
110 console.log(e.response); 109 console.log(e.response);
111 } 110 }
112 } finally { 111 } finally {
113 res.json({ 112 res.json({
114 prompt: JSON.parse(message), 113 prompt: JSON.parse(message),
115 message: returnMessage 114 message: anchorme({
115 input,
116 options: {
117 attributes: {
118 target: "_blank"
119 },
120 }
121 })
116 }); 122 });
117 return; 123 return;
118 } 124 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!