Skip to content

Commit

Permalink
🐳 experimental: Dev Image Workflow & Remove Unused Code (danny-avila#…
Browse files Browse the repository at this point in the history
…1928)

* chore: remove unused code in progressCallback, as well as handle reply.trim(), post `getCompletion`

* chore(Dockerfile): remove curl installation

* experimental: dev image parallelized with matrix strategy and building for amd64/arm64 support

* make platforms explicit
  • Loading branch information
danny-avila authored Feb 29, 2024
1 parent 93912a2 commit 1a870c7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
2 changes: 1 addition & 1 deletion app/clients/OpenAIClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ class OpenAIClient extends BaseClient {
const { finish_reason } = streamResult.choices[0];
opts.addMetadata({ finish_reason });
}
return reply.trim();
return (reply ?? '').trim();
}

initializeLLM({
Expand Down
23 changes: 0 additions & 23 deletions server/utils/handleText.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,13 @@ const addSpaceIfNeeded = (text) => (text.length > 0 && !text.endsWith(' ') ? tex

const createOnProgress = ({ generation = '', onProgress: _onProgress }) => {
let i = 0;
let code = '';
let precode = '';
let codeBlock = false;
let tokens = addSpaceIfNeeded(generation);

const progressCallback = async (partial, { res, text, bing = false, ...rest }) => {
let chunk = partial === text ? '' : partial;
tokens += chunk;
precode += chunk;
tokens = tokens.replaceAll('[DONE]', '');

if (codeBlock) {
code += chunk;
}

if (precode.includes('```') && codeBlock) {
codeBlock = false;
precode = precode.replace(/```/g, '');
code = '';
}

if (precode.includes('```') && code === '') {
precode = precode.replace(/```/g, '');
codeBlock = true;
}

if (tokens.match(/^\n(?!:::plugins:::)/)) {
tokens = tokens.replace(/^\n/, '');
}

if (bing) {
tokens = citeText(tokens, true);
}
Expand Down

0 comments on commit 1a870c7

Please sign in to comment.