Skip to content

Commit

Permalink
Automatically applying Prettier changes
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed May 24, 2024
1 parent c95ec39 commit 283caae
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class ArakooServer {
this.app = new Hono();
}

useCors(allowedEndpoints?:string, options?: any) {
useCors(allowedEndpoints?: string, options?: any) {
this.app.use(allowedEndpoints || "*", cors(options));
}

Expand Down
2 changes: 1 addition & 1 deletion JS/edgechains/arakoodev/src/document-loader/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { PdfLoader } from "./lib/pdf-loader/pdfLoader.js";
export { YoutubeLoader } from "./lib/youtube-video-transcript-loader/youtubeLoader.js"
export { YoutubeLoader } from "./lib/youtube-video-transcript-loader/youtubeLoader.js";
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { YoutubeTranscript } from "youtube-transcript"
import { YoutubeTranscript } from "youtube-transcript";

export class YoutubeLoader {
private videoUrl: string;
Expand All @@ -13,4 +13,4 @@ export class YoutubeLoader {
this.transcript = await YoutubeTranscript.fetchTranscript(this.videoUrl);
return this.transcript.map((t: any) => t.text).join(" ");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ export class OpenAI {
openAI_url,
{
model: chatOptions.model || "gpt-3.5-turbo",
messages: chatOptions.prompt ? [
{
role: chatOptions.role || "user",
content: chatOptions.prompt,
},
] : chatOptions.messages,
messages: chatOptions.prompt
? [
{
role: chatOptions.role || "user",
content: chatOptions.prompt,
},
]
: chatOptions.messages,
max_tokens: chatOptions.max_tokens || 256,
temperature: chatOptions.temperature || 0.7,
},
Expand All @@ -71,17 +73,14 @@ export class OpenAI {
Authorization: "Bearer " + this.apiKey,
"content-type": "application/json",
},
},
}
)
.then((response) => {
return response.data.choices;
})
.catch((error) => {
if (error.response) {
console.log(
"Server responded with status code:",
error.response.status,
);
console.log("Server responded with status code:", error.response.status);
console.log("Response data:", error.response.data);
} else if (error.request) {
console.log("No response received:", error);
Expand All @@ -92,39 +91,40 @@ export class OpenAI {
return responce[0].message;
}

async chatWithFunction(chatOptions: chatWithFunctionOptions): Promise<chatWithFunctionReturnOptions> {
async chatWithFunction(
chatOptions: chatWithFunctionOptions
): Promise<chatWithFunctionReturnOptions> {
const responce = await axios
.post(
openAI_url,
{
model: chatOptions.model || "gpt-3.5-turbo",
messages: chatOptions.prompt ? [
{
role: chatOptions.role || "user",
content: chatOptions.prompt,
},
] : chatOptions.messages,
messages: chatOptions.prompt
? [
{
role: chatOptions.role || "user",
content: chatOptions.prompt,
},
]
: chatOptions.messages,
max_tokens: chatOptions.max_tokens || 256,
temperature: chatOptions.temperature || 0.7,
functions: chatOptions.functions,
function_call: chatOptions.function_call || "auto"
function_call: chatOptions.function_call || "auto",
},
{
headers: {
Authorization: "Bearer " + this.apiKey,
"content-type": "application/json",
},
},
}
)
.then((response) => {
return response.data.choices;
})
.catch((error) => {
if (error.response) {
console.log(
"Server responded with status code:",
error.response.status,
);
console.log("Server responded with status code:", error.response.status);
console.log("Response data:", error.response.data);
} else if (error.request) {
console.log("No response received:", error);
Expand All @@ -148,17 +148,14 @@ export class OpenAI {
Authorization: `Bearer ${this.apiKey}`,
"content-type": "application/json",
},
},
}
)
.then((response) => {
return response.data.data;
})
.catch((error) => {
if (error.response) {
console.log(
"Server responded with status code:",
error.response.status,
);
console.log("Server responded with status code:", error.response.status);
console.log("Response data:", error.response.data);
} else if (error.request) {
console.log("No response received:", error.request);
Expand All @@ -168,6 +165,4 @@ export class OpenAI {
});
return response;
}

}

1 change: 0 additions & 1 deletion JS/edgechains/arakoodev/src/scraper/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { WebScraper } from "./lib/webScraper";

14 changes: 7 additions & 7 deletions JS/edgechains/arakoodev/src/scraper/src/lib/webScraper.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import request from 'request';
import cheerio from 'cheerio';
import request from "request";
import cheerio from "cheerio";

export class WebScraper {
constructor() { }
constructor() {}
async getContent(url: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
request(url, (error: any, response: any, html: string) => {
if (!error && response.statusCode == 200) {
const $ = cheerio.load(html);
const contentArr: string[] = [];

$('p').each((index: number, element:any) => {
$("p").each((index: number, element: any) => {
const paragraphText: string = $(element).text();
contentArr.push(paragraphText);
});

resolve(contentArr.join(' ').trim());
resolve(contentArr.join(" ").trim());
} else {
reject('Error: ' + error);
reject("Error: " + error);
}
});
});
}
}
}

0 comments on commit 283caae

Please sign in to comment.