Skip to content

Commit

Permalink
fix: misc bug fixes and email format improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamesb committed Mar 6, 2024
1 parent 51f529b commit cf73514
Show file tree
Hide file tree
Showing 9 changed files with 240 additions and 179 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
import { Prompt } from "prompt-iteration-assistant";
import { answersQuestionInputSchema } from "./schemas/answersQuestionInputSchema";
import {
AnswersQuestionInput,
answersQuestionInputSchema,
} from "./schemas/answersQuestionInputSchema";
import { answersQuestionOutputSchema } from "./schemas/answersQuestionOutputSchema";
import { answersQuestionPrompt } from "./prompts/answersQuestionPrompt";

export const ANSWERS_QUESTION = "Answers Question";

export const answersQuestion = () =>
new Prompt({
name: ANSWERS_QUESTION,
description:
"Check whether the text contains the start of an answer to the question",
prompts: [answersQuestionPrompt],
model: "gpt-4",
input: answersQuestionInputSchema,
output: answersQuestionOutputSchema,
});

if (require.main === module) {
(async () => {
const res = await answersQuestion().run({
stream: false,
promptVariables: {
text: "",
question: "How does chain of thought prompting work",
},
class AnswersQuestion extends Prompt<
typeof answersQuestionInputSchema,
typeof answersQuestionOutputSchema
> {
constructor() {
super({
name: ANSWERS_QUESTION,
description:
"Check whether the text contains the start of an answer to the question",
prompts: [answersQuestionPrompt],
model: "gpt-4",
input: answersQuestionInputSchema,
output: answersQuestionOutputSchema,
});
console.log(res);
})();
}
async execute(args: AnswersQuestionInput) {
try {
return this.run({
stream: false,
promptVariables: args,
});
} catch (e) {
console.error(e);
return { answersQuestion: false };
}
}
}

export const answersQuestion = () => new AnswersQuestion();
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,42 @@ import { findStartOfAnswerPrompt } from "./prompts/findStartOfAnswerPrompt";

export const FIND_START_OF_ANSWER = "Find Start Of Answer";

export const findStartOfAnswer = () =>
new Prompt({
name: FIND_START_OF_ANSWER,
description: "Find the start of an answer to a question in some text",
prompts: [findStartOfAnswerPrompt],
model: "gpt-4",
input: findStartOfAnswerInputSchema,
output: findStartOfAnswerOutputSchema,
exampleData: [],
});
class FindStartOfAnswer extends Prompt<
typeof findStartOfAnswerInputSchema,
typeof findStartOfAnswerOutputSchema
> {
constructor() {
super({
name: FIND_START_OF_ANSWER,
description: "Find the start of an answer to a question in some text",
prompts: [findStartOfAnswerPrompt],
model: "gpt-4",
input: findStartOfAnswerInputSchema,
output: findStartOfAnswerOutputSchema,
exampleData: [],
});
}

if (require.main === module) {
(async () => {})();
async execute(args: {
question: string;
text: string;
openPipeRequestTags?: RequestTagsWithoutName;
enableOpenPipeLogging?: boolean;
}) {
const promptVariables: FindStartOfAnswerInput = {
text: args.text,
question: args.question,
};
try {
return this.run({
stream: false,
promptVariables,
});
} catch (e) {
console.error(e);
return { quotedAnswer: null };
}
}
}

export const findStartOfAnswer = () => new FindStartOfAnswer();
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,15 @@ ${cue.text}
.join(`\n---\n`),
question: args.question,
};
return this.run({
stream: false,
promptVariables,
});
try {
return this.run({
stream: false,
promptVariables,
});
} catch (e) {
console.error(e);
return { cueId: null };
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { CandidatePrompt, ChatMessage } from "prompt-iteration-assistant";
import {
CandidatePrompt,
ChatMessage,
toCamelCase,
} from "prompt-iteration-assistant";
import { FindStartOfAnswerYouTubeInput } from "../schemas/findStartOfAnswerYouTubeInputSchema";
import { FindStartOfAnswerYouTubeOutput } from "../schemas/findStartOfAnswerYouTubeOutputSchema";
import { FIND_START_OF_ANSWER_YOUTUBE } from "../findStartOfAnswerYouTube";

export const findStartOfAnswerYouTubePrompt =
new CandidatePrompt<FindStartOfAnswerYouTubeInput>({
Expand All @@ -9,41 +15,35 @@ export const findStartOfAnswerYouTubePrompt =
ChatMessage.system(
`
# Instructions
- Given a question from the user, evalutate whether the beginning of the answer is in the transcript.
- If the beginning of the answer is in the transcript, return the ID of the transcript cure where the answer starts.
- The answer doesn't need to be complete, just the start of it.
- Given a question from the user, evaluate whether the beginning of the answer is in the transcript.
- If the beginning of the answer is in the transcript, return the ID of the transcript cue where the answer starts.
- If the beginning of the answer is not in the transcript, return null.
`.trim()
),
// ChatMessage.user(
// `
// # Transcript

// # Question
// What is the best way to learn a new language?
// `.trim()
// ),
// ChatMessage.assistant<FindStartOfAnswerYouTubeOutput>(null, {
// name: toCamelCase(FIND_START_OF_ANSWER_YOUTUBE),
// arguments: {
// answersQuestion: true,
// cueId: 0,
// },
// }),
// ChatMessage.user(
// `
// # Transcript
ChatMessage.user(
`# Transcript
ID: 0
Hello, my name is John.
---
ID: 1
I am a software developer interested in learning new languages.
---
ID: 2
The best way to learn a new language is through
---
ID: 3
immersion.
// # Question
// How does chain of thought prompting work?
// `.trim()
// ),
// ChatMessage.assistant<FindStartOfAnswerYouTubeOutput>(null, {
// name: toCamelCase(FIND_START_OF_ANSWER_YOUTUBE),
// arguments: {
// answersQuestion: false,
// },
// }),
# Question
What is the best way to learn a new language?
`.trim()
),
ChatMessage.assistant<FindStartOfAnswerYouTubeOutput>(null, {
name: toCamelCase(FIND_START_OF_ANSWER_YOUTUBE),
arguments: {
cueId: 2,
},
}),
ChatMessage.user(
`
# Transcript
Expand Down
52 changes: 31 additions & 21 deletions packages/cli/src/recommender/prompts/titleClip/titleClip.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
import { Prompt } from "prompt-iteration-assistant";
import { titleClipPrompt } from "./prompts/titleClipPrompt";
import { titleClipInputSchema } from "./schemas/titleClipInputSchema";
import {
TitleClipInput,
titleClipInputSchema,
} from "./schemas/titleClipInputSchema";
import { titleClipOutputSchema } from "./schemas/titleClipOutputSchema";

export const TITLE_CLIP = "Title Clip";

export const titleClip = () =>
new Prompt({
name: TITLE_CLIP,
description: "Give the clip a short title",
prompts: [titleClipPrompt],
model: "gpt-3.5-turbo",
input: titleClipInputSchema,
output: titleClipOutputSchema,
});
class TitleClip extends Prompt<
typeof titleClipInputSchema,
typeof titleClipOutputSchema
> {
constructor() {
super({
name: TITLE_CLIP,
description: "Give the clip a short title",
prompts: [titleClipPrompt],
model: "gpt-3.5-turbo",
input: titleClipInputSchema,
output: titleClipOutputSchema,
});
}

if (require.main === module) {
(async () => {
// const res = await answersQuestion().run({
// stream: false,
// // promptVariables: {
// // text: "",
// // question: "How does chain of thought prompting work",
// // },
// });
// console.log(res);
})();
async execute(args: TitleClipInput) {
try {
return this.run({
stream: false,
promptVariables: args,
});
} catch (e) {
console.error(e);
return { title: "" };
}
}
}

export const titleClip = () => new TitleClip();
8 changes: 1 addition & 7 deletions packages/cli/src/youtube/transcript.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import chalk from "chalk";
import { exec, execSync } from "child_process";
import {
existsSync,
readFileSync,
readdirSync,
writeFile,
writeFileSync,
} from "fs";
import { existsSync, readFileSync, writeFileSync } from "fs";
import path from "path";
import { dataFolder } from "../filesystem";
import { parseSync, stringifySync } from "subtitle";
Expand Down
21 changes: 16 additions & 5 deletions packages/client/src/components/AdminPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ import {
TableRow,
} from "@mui/material";
import React from "react";
import { sortBy } from "remeda";
import { sortBy, last } from "remeda";

dayjs.extend(relativeTime);

export const AdminPage = () => {
const [pipelines, setPipelines] =
useState<AdminRouterOutput["getPipelinesAndTasks"]>();
const [force, setForce] = useState(0);
const [hideSuccessful, setHideSuccessful] = useState(false);

useEffect(() => {
// Function to fetch data
const fetchData = () => {
Expand All @@ -46,6 +48,13 @@ export const AdminPage = () => {
<Button onClick={() => trpcAdmin.unlockWorkers.mutate()}>
Force unlock workers
</Button>
<Button
onClick={() => {
setHideSuccessful(true);
}}
>
{!hideSuccessful ? "Hide" : "Show"} Successful
</Button>
<TableContainer component={Paper}>
<Table aria-label="pipelines table">
<TableHead>
Expand All @@ -65,15 +74,17 @@ export const AdminPage = () => {
</TableRow>
</TableHead>
<TableBody>
{sortBy(pipelines, (x) => dayjs(x.createdAt).valueOf()).map(
(pipeline) => (
{sortBy(pipelines, (x) => dayjs(x.createdAt).valueOf())
.filter((p) =>
hideSuccessful ? last(p.tasks)?.name !== "done" : true
)
.map((pipeline) => (
<PipelineRow
key={pipeline.id}
pipeline={pipeline}
setForce={setForce}
/>
)
)}
))}
</TableBody>
</Table>
</TableContainer>
Expand Down
Loading

0 comments on commit cf73514

Please sign in to comment.