Skip to content

Commit

Permalink
Merge pull request #112 from intelligentnode/release-1.8.6
Browse files Browse the repository at this point in the history
Release 1.8.7
  • Loading branch information
intelligentnode authored May 25, 2024
2 parents 7cece5a + e2b1d65 commit 0260bd2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
17 changes: 11 additions & 6 deletions IntelliNode/function/Gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ class Gen {
*
* @returns {Promise<string|Buffer>} - The generated image, either as base64 string or Buffer.
*/
static async generate_image_from_desc(promptString, openaiKey, imageApiKey, is_base64 = true,
provider = SupportedImageModels.STABILITY, customProxyHelper=null) {
static async generate_image_from_desc(promptString, openaiKey, imageApiKey, is_base64 = true, width= 1024,
height = 1024, provider = SupportedImageModels.STABILITY, customProxyHelper=null) {

const imageDescription = await Gen.getImageDescription(promptString, openaiKey, customProxyHelper);
const imgModel = new RemoteImageModel(imageApiKey, provider);
const images = await imgModel.generateImages(
new ImageModelInput({ prompt: imageDescription,
numberOfImages: 1,
width: 512,
height: 512,
width: width,
height: height,
responseFormat: 'b64_json'}));
if (is_base64) {
return images[0];
Expand Down Expand Up @@ -121,6 +121,8 @@ class Gen {
tokeSize = 8000;
} else if (model_name.includes('gpt-4')) {
tokeSize = 4000;
} else if (model_name.includes('gpt-4o')) {
tokeSize = 20000;
}

// prepare the bot
Expand All @@ -130,7 +132,7 @@ class Gen {
// set the user message with the template
input.addUserMessage(promptTemp.format({'text': text}));
const responses = await chatbot.chat(input);
return JSON.parse(responses[0].trim());
return JSON.parse(responses[0].trim().replace('```json', '').replace('```', '').replace('```', '').replace('```', ''));
}

static async save_html_page(text, folder, file_name, openaiKey, model_name='gpt-4', customProxyHelper=null) {
Expand Down Expand Up @@ -158,15 +160,18 @@ class Gen {
tokeSize = 8000;
} else if (model_name.includes('gpt-4')) {
tokeSize = 3900;
} else if (model_name.includes('gpt-4o')) {
tokeSize = 20000;
}

const chatbot = new Chatbot(openaiKey, SupportedChatModels.OPENAI, customProxyHelper);
const input = new ChatGPTInput('Generate HTML graphs from the CSV data and ensure the response is a valid JSON to parse with full HTML code.',
{ maxTokens: tokeSize, model: model_name, temperature:0.3 });
// set the user message with the template
input.addUserMessage(promptTemp.format({'count': num_graphs, 'topic': topic, 'text': csvStrData}));
const responses = await chatbot.chat(input);

return JSON.parse(responses[0].trim())[0];
return JSON.parse(responses[0].trim().replace('```json', '').replace('```', '').replace('```', '').replace('```', ''))[0];
}


Expand Down
2 changes: 1 addition & 1 deletion IntelliNode/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "intellinode",
"version": "1.8.5",
"version": "1.8.8",
"description": "Evaluate and integrate with latest AI models including ChatGPT, Llama, Diffusion, Cohere, Gemini, and Hugging Face.",
"main": "index.js",
"keywords": [
Expand Down
6 changes: 3 additions & 3 deletions IntelliNode/test/integration/Gen.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0260bd2

Please sign in to comment.