Skip to content

Commit

Permalink
Fix createCompleition method
Browse files Browse the repository at this point in the history
  • Loading branch information
moz-gh committed Sep 19, 2024
1 parent ebef03e commit e6cccef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

14 changes: 12 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ class Formulaic {
}
}

async getScripts(formulaId) {
const url = `${this.baseURL}/api/recipes/${formulaId}/scripts`;
this.logDebug("Fetching scripts for formula:", formulaId);
try {
return await this.httpClient.get(url);
} catch (error) {
throw new Error(`Failed to get scripts: ${error.message}`);
}
}

async createFormula(data) {
const url = `${this.baseURL}/api/recipes`;

Expand All @@ -135,8 +145,8 @@ class Formulaic {
const variables = Array.isArray(data.variables) ? data.variables : [];

try {
const formula = await this.getFormula(formulaId);
const url = `${this.baseURL}/api/recipes/${formulaId}/scripts/${formula.id}/artifacts`;
const script = await this.getScripts(formulaId);
const url = `${this.baseURL}/api/recipes/${formulaId}/scripts/${script.id}/artifacts`;
this.logDebug("Creating completion for formula:", formulaId);

return await this.httpClient.post(url, { ...data, models, variables });
Expand Down

0 comments on commit e6cccef

Please sign in to comment.