Skip to content

Commit

Permalink
fix docs; var names;
Browse files Browse the repository at this point in the history
  • Loading branch information
meddy672 committed Feb 6, 2024
1 parent 7dc53dc commit d78747a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function main(){

filePath = await new GPTDocx({
format: BASIC,
prompt: "Write Paper on coffee.",
prompt: "Write Paper on coffee.",
}).createFile();
console.log(filePath)

Expand Down
9 changes: 4 additions & 5 deletions src/ChatGPT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
}).send();
* ```
* @async
* Class ChatGPT
*/
class ChatGPT {
/**
Expand All @@ -43,7 +42,7 @@ class ChatGPT {
*
* @param prompt **Required** a string that represents the prompt.
* @param format **Required** sent to OpenAI to provide context to the prompt.
* @param apiKeyEnv: **Optional** a string used to represent the **apikey** used in the request. Defaults to OPENAI_API_KEY.
* @param apiKeyEnv: **Optional** a string used to represent the **apikeyEnv** used in the request. Defaults to OPENAI_API_KEY.
* @param config **Optional** an object to apply additonal settings to openai.
* @returns ChatGPT instance
*/
Expand All @@ -59,7 +58,7 @@ class ChatGPT {

/**
* @description
* Takes format and builds the openai request body for the request.
* Takes the format and builds the openai request body for the request.
*
* @param {Format} format - format used for context.
* @returns ChatCompletionCreateParams
Expand Down Expand Up @@ -102,8 +101,8 @@ class ChatGPT {
console.debug("Sending resquest...");
const response: ChatCompletionResponse =
await this.openai.chat.completions.create(this.requestBody);
const content = response.choices[0].message.content as string;
return JSON.parse(content);
const context = response.choices[0].message.content as string;
return JSON.parse(context);
} catch (err) {
console.error("Unable to complete Open A.I request: ", err);
throw new Error("Error: OPENAI_REQUEST_ERROR");
Expand Down
2 changes: 1 addition & 1 deletion src/Document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class WordDocument {
*
* @param docName **Required** name of the document.
* @param pages **Required** an array of document components to add to the document.
* @param options **Optional** an object add addtional styling and configuration the the document.
* @param options **Optional** an object to add addtional styling and configuration the the document.
*/
constructor({ docName, pages, options }: WordDocumentArgs) {
this.options = options || DOCUMENT.BASIC;
Expand Down
4 changes: 2 additions & 2 deletions src/DocxTemplater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class DocxTemplater {
private docName: string;

/**
* The word file that will used as the template.
* The word file that will be used as the template.
*/
private service: string;

Expand All @@ -46,7 +46,7 @@ export default class DocxTemplater {
* @param docName **Required** the name of the word file or docuement.
* @param service **Required** the word file that will be used as the template.
* @param response **Required** the response recieved from ChatGPT object.
* @param useAngularParser **Optional** user the angular parse or not.
* @param useAngularParser **Optional** use the angular parse or not.
* @returns
*/
constructor({
Expand Down
12 changes: 6 additions & 6 deletions src/GPTDocx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,32 +144,32 @@ class GPTDocx {
* @returns {Object} an object with requestFormat and optional styles.
*/
private _getFormat(format: string): Format {
let requestedService: any;
let requestedFormat: any;
try {
if (
process.env["NODE_ENV"] === "development" ||
process.env["NODE_ENV"] === "test"
) {
requestedService = require(
requestedFormat = require(
join(__dirname, Static.FORMATS_DIR, format, Static.INDEX_TS),
);
} else {
requestedService = require(
requestedFormat = require(
join(__dirname, Static.FORMATS_DIR, format, Static.INDEX_JS),
);
}
} catch (error) {
console.error(`Unable to find format: ${format}`);
}

return requestedService?.format;
return requestedFormat?.format;
}

/**
* @description
* Validates the format and retuns the format.
*
* Throws error if format is invalid.
* Throws parse service error if format is invalid.
*
* @private
*/
Expand Down Expand Up @@ -350,7 +350,7 @@ class GPTDocx {

/**
* @description
* Handle use case when a in a format key is **links** .
* Handle use case when a format key is **links** .
* Takes the **links** and applies the correct
* wrapper class. Adds each link to the page's
* container```this.children```. **Docx Only**.
Expand Down

0 comments on commit d78747a

Please sign in to comment.