Skip to content

Commit

Permalink
fix: iimprove question generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamesb committed Mar 9, 2024
1 parent cfbb67a commit 364bd42
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ import {
CreateQueriesFromProfileInput,
createQueriesFromProfileInputSchema,
} from "./schemas/createQueriesFromProfileInputSchema";
import { createQueriesFromProfileOutputSchema } from "./schemas/createQueriesFromProfileOutputSchema";
import {
RequestTagsWithoutName,
formatPromptName,
} from "../../../openpipe/requestTags";
import { openpipe } from "../../../openpipe/openpipe";
import { experilearningDataset } from "./datasets/experilearningDataset";
import { createQueriesFromProfileZeroShotFreeFormPrompt } from "./prompts/zeroShotFreeForm";
import { DefaultRun } from "modelfusion";
import { z } from "zod";
import dotenv from "dotenv";

export const CREATE_SEARCH_QUERIES_FROM_PROFILE = "Create Questions";

Expand All @@ -21,7 +17,7 @@ export const CREATE_SEARCH_QUERIES_FROM_PROFILE = "Create Questions";
*/
export class CreateSearchQueriesFromProfile extends Prompt<
typeof createQueriesFromProfileInputSchema,
typeof createQueriesFromProfileOutputSchema
z.ZodString
> {
constructor() {
super({
Expand All @@ -30,7 +26,6 @@ export class CreateSearchQueriesFromProfile extends Prompt<
prompts: [createQueriesFromProfileZeroShotFreeFormPrompt],
model: "gpt-4",
input: createQueriesFromProfileInputSchema,
output: createQueriesFromProfileOutputSchema,
exampleData: [],
});
}
Expand All @@ -47,12 +42,16 @@ export class CreateSearchQueriesFromProfile extends Prompt<
profile: args.profile,
};
try {
const res = await this.run({
promptVariables,
stream: false,
run: args.run,
const res =
(await this.run({
promptVariables,
stream: false,
run: args.run,
})) || "";
const queries = res.split("\n").map((query) => {
return query.replace(/(^- )|(^\d+\. )/g, "").trim();
});
return res || { queries: [] };
return { queries };
} catch (e) {
console.error(e);
return { queries: [] };
Expand All @@ -72,6 +71,7 @@ export const createQueriesFromProfile = () =>

if (require.main === module) {
(async () => {
dotenv.config({ path: "packages/cli/.env" });
const res = await createQueriesFromProfile().execute({
user: experilearningDataset.user.value,
bio: experilearningDataset.bio.value,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
import { CandidatePrompt, ChatMessage } from "prompt-iteration-assistant";
import { sharedCreateQueriesInstructions } from "./shared";
import { CreateQueriesFromProfileInput } from "../schemas/createQueriesFromProfileInputSchema";

export const createQueriesFromProfileZeroShotFreeFormPrompt =
new CandidatePrompt<CreateQueriesFromProfileInput>({
name: "zero shot free form-2",
compile() {
return [
ChatMessage.system(sharedCreateQueriesInstructions({ short: false })),
ChatMessage.system(
`
# Instructions
- Based on your persona, write 10 research questions you would be interested in investigating based on ideas, concepts, problems, people and events that interest you.
- Don't include introductory or background questions.
- Make sure the questions are interesting. Don't ask questions you likely know the answer to based on your persona.
- Don't ask duplicate questions.
`.trim()
),
{
role: "user",
content: `
# My Twitter Username
# Your Persona
## Your Username
${this.getVariable("user")}
# My Twitter Bio
## Your Bio
${this.getVariable("bio")}
# My Profile
## Your Profile
${this.getVariable("profile")}
`.trim(),
},
Expand Down

This file was deleted.

9 changes: 0 additions & 9 deletions packages/server/src/tasks/twitterPipeline.saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,15 +396,6 @@ export const twitterPipeline = new Saga(
}),
{ concurrency: 2 }
);
console.log(
"all results",
JSON.stringify({
metaphorArticleResults,
metaphorYouTubeResults,
youtubeResults,
})
);

const all = [
...youtubeResults,
...metaphorYouTubeResults,
Expand Down

0 comments on commit 364bd42

Please sign in to comment.