Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor 'run' method to use an enum per API, and a file per API #3

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions main/api1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { AzureFunction, Context, HttpRequest } from "@azure/functions"
import { ChatGPT, ThoughtDB } from "vanjacloud.shared.js";
import * as path from 'path';
import UrlPattern from 'url-pattern';
import axios from 'axios';
import * as fs from "fs";
import keys from "../keys";
import { LanguageTeacher } from "vanjacloud.shared.js";
import moment from "moment";

const systemPromptTemplate = fs.readFileSync('./content/systemprompt.template.md', 'utf8');
const blogSummary = fs.readFileSync('./content/blog1.summary.md', 'utf8');
const blogRaw = fs.readFileSync('./content/blog1.raw.md', 'utf8');

const systemPrompt =
`${systemPromptTemplate}

Introduction:
${blogSummary}

Full Post:
${blogRaw}
`

export interface IMainQuery {
id: number;
}

export interface IMainBody {
body: true
}

export interface IMainParams {
route: string
}

export const Message = ChatGPT.Message;

interface WhatsAppMessage {
object: string;
entry: [{

// Rest of the code for the first API implementation

export async function api1(query: any, body: any, params: IMainParams) {
// Implementation of the first API
}
47 changes: 47 additions & 0 deletions main/api2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { AzureFunction, Context, HttpRequest } from "@azure/functions"
import { ChatGPT, ThoughtDB } from "vanjacloud.shared.js";
import * as path from 'path';
import UrlPattern from 'url-pattern';
import axios from 'axios';
import * as fs from "fs";
import keys from "../keys";
import { LanguageTeacher } from "vanjacloud.shared.js";
import moment from "moment";

const systemPromptTemplate = fs.readFileSync('./content/systemprompt.template.md', 'utf8');
const blogSummary = fs.readFileSync('./content/blog1.summary.md', 'utf8');
const blogRaw = fs.readFileSync('./content/blog1.raw.md', 'utf8');

const systemPrompt =
`${systemPromptTemplate}

Introduction:
${blogSummary}

Full Post:
${blogRaw}
`

export interface IMainQuery {
id: number;
}

export interface IMainBody {
body: true
}

export interface IMainParams {
route: string
}

export const Message = ChatGPT.Message;

interface WhatsAppMessage {
object: string;
entry: [{

// Rest of the code for the second API implementation

export async function api2(query: any, body: any, params: IMainParams) {
// Implementation of the second API
}
47 changes: 47 additions & 0 deletions main/api3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { AzureFunction, Context, HttpRequest } from "@azure/functions"
import { ChatGPT, ThoughtDB } from "vanjacloud.shared.js";
import * as path from 'path';
import UrlPattern from 'url-pattern';
import axios from 'axios';
import * as fs from "fs";
import keys from "../keys";
import { LanguageTeacher } from "vanjacloud.shared.js";
import moment from "moment";

const systemPromptTemplate = fs.readFileSync('./content/systemprompt.template.md', 'utf8');
const blogSummary = fs.readFileSync('./content/blog1.summary.md', 'utf8');
const blogRaw = fs.readFileSync('./content/blog1.raw.md', 'utf8');

const systemPrompt =
`${systemPromptTemplate}

Introduction:
${blogSummary}

Full Post:
${blogRaw}
`

export interface IMainQuery {
id: number;
}

export interface IMainBody {
body: true
}

export interface IMainParams {
route: string
}

export const Message = ChatGPT.Message;

interface WhatsAppMessage {
object: string;
entry: [{

// Rest of the code for the third API implementation

export async function api3(query: any, body: any, params: IMainParams) {
// Implementation of the third API
}
47 changes: 47 additions & 0 deletions main/api4.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { AzureFunction, Context, HttpRequest } from "@azure/functions"
import { ChatGPT, ThoughtDB } from "vanjacloud.shared.js";
import * as path from 'path';
import UrlPattern from 'url-pattern';
import axios from 'axios';
import * as fs from "fs";
import keys from "../keys";
import { LanguageTeacher } from "vanjacloud.shared.js";
import moment from "moment";

const systemPromptTemplate = fs.readFileSync('./content/systemprompt.template.md', 'utf8');
const blogSummary = fs.readFileSync('./content/blog1.summary.md', 'utf8');
const blogRaw = fs.readFileSync('./content/blog1.raw.md', 'utf8');

const systemPrompt =
`${systemPromptTemplate}

Introduction:
${blogSummary}

Full Post:
${blogRaw}
`

export interface IMainQuery {
id: number;
}

export interface IMainBody {
body: true
}

export interface IMainParams {
route: string
}

export const Message = ChatGPT.Message;

interface WhatsAppMessage {
object: string;
entry: [{

// Rest of the code for the fourth API implementation

export async function api4(query: any, body: any, params: IMainParams) {
// Implementation of the fourth API
}
47 changes: 47 additions & 0 deletions main/api5.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { AzureFunction, Context, HttpRequest } from "@azure/functions"
import { ChatGPT, ThoughtDB } from "vanjacloud.shared.js";
import * as path from 'path';
import UrlPattern from 'url-pattern';
import axios from 'axios';
import * as fs from "fs";
import keys from "../keys";
import { LanguageTeacher } from "vanjacloud.shared.js";
import moment from "moment";

const systemPromptTemplate = fs.readFileSync('./content/systemprompt.template.md', 'utf8');
const blogSummary = fs.readFileSync('./content/blog1.summary.md', 'utf8');
const blogRaw = fs.readFileSync('./content/blog1.raw.md', 'utf8');

const systemPrompt =
`${systemPromptTemplate}

Introduction:
${blogSummary}

Full Post:
${blogRaw}
`

export interface IMainQuery {
id: number;
}

export interface IMainBody {
body: true
}

export interface IMainParams {
route: string
}

export const Message = ChatGPT.Message;

interface WhatsAppMessage {
object: string;
entry: [{

// Rest of the code for the fifth API implementation

export async function api5(query: any, body: any, params: IMainParams) {
// Implementation of the fifth API
}
Loading