Skip to content

Commit

Permalink
First alpha version
Browse files Browse the repository at this point in the history
  • Loading branch information
aguszanoli committed Jan 24, 2024
1 parent c0b3d05 commit d71aa63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 4 additions & 7 deletions engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ const openaiInstance = new OpenAIApi(configuration);

//New function using Azure OpenAI Cboard API
async function getWordSuggestions(prompt, maxWords, language) {
//TODO ver esto para pasar el lang
//const phraseToEdit = req.body.phrase;
//const phraseLanguage = req.body.language;

if (!prompt || !maxWords || !language) {
console.error("Error with parameters");
Expand Down Expand Up @@ -105,7 +102,7 @@ async function fetchPictogramsURLs(words, symbolSet, language) {
{
id: "NaN",
text: words[responses.indexOf(response)],
locale: language,
language: language, //TODO arreglame esto cat
picto: { image_url: "ERROR: No image in the Symbol Set" },
},
];
Expand Down Expand Up @@ -238,8 +235,8 @@ async function processPictograms(pictogramsURL) {

//Function to get word suggestions and then fetch a Pictogram for each suggested word
async function getSuggestions(prompt, maxWords, symbolSet, language) {
const words = await getWordSuggestions(prompt, maxWords, language);
//const words = ["Pizza", "Pasta", "Gelato", "Espresso", "Mocha"];
//const words = await getWordSuggestions(prompt, maxWords, language);
const words = ["Pizza", "Pasta", "Gelato", "Espresso", "Mocha"];
const pictogramsURLs = await fetchPictogramsURLs(words, symbolSet, language);
// Return the list of words and pictograms URLs
return { pictogramsURLs };
Expand All @@ -250,7 +247,7 @@ async function getSuggestions(prompt, maxWords, symbolSet, language) {
const getSuggestionsAndProcessPictograms = async (prompt, maxSuggestions, symbolSet, language) => {
try {
const suggestions = await getSuggestions(prompt, maxSuggestions, symbolSet, language);
const pictogramsURLs = suggestions.pictogramsURLs; //TODO Aca se me ato la rama, problablemente esto se pueda mejorar
const pictogramsURLs = suggestions.pictogramsURLs;
const pictograms = await processPictograms(pictogramsURLs);
return pictograms;
} catch (error) {
Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ const { getSuggestions } = require('./engine');
const { processPictograms } = require('./engine');

const language = 'eng';
const maxSuggestions = 12;
const maxSuggestions = 10;
const symbolSet = 'arasaac';
const prompt = 'indian drinks';
const prompt = 'objects to draw and paint';
const promptImage = 'orange';

/*

getSuggestions(prompt,maxSuggestions,symbolSet,language)
.then(suggestions => console.log(suggestions))
.then(result => console.log(result))
Expand Down Expand Up @@ -39,10 +39,12 @@ processPictograms(pictogramsURL)


//Call getSuggestionsAndProcessPictograms to run the whole pipeline
/*
getSuggestionsAndProcessPictograms(prompt,maxSuggestions,symbolSet,language)
.then(picto => console.log(picto))
.then(result => console.log(result))
.catch(error => console.error(error));
*/

// Export the functions to be used
module.exports = {
Expand Down

0 comments on commit d71aa63

Please sign in to comment.