Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Introduce Prompt customization into config #10

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

Merged
samheutmaker merged 8 commits into context-labs:master from andrewhong5297:prompt-config
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
make linkHosted boolean work
  • Loading branch information
andrewhong5297 committed Mar 26, 2023
commit 1c90fa8e413a00bbbe626a1ef8edbad631d03161
3 changes: 2 additions & 1 deletion autodoc.config.json
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"folderPrompt": "Write a technical explanation of what the code in this file does\n and how it might fit into the larger project or work with other parts of the project.\n Give examples of how this code might be used. Include code examples where appropriate.\n Be concise. Include any information that may be relevant to a developer who is curious about this code.\n Keep you response under 400 words. Output should be in markdown format.\n Do not just list the files and folders in this folder.",
"chatPrompt": "",
"contentType": "code",
"targetAudience": "smart developer"
"targetAudience": "smart developer",
"linkHosted": false
}
6 changes: 4 additions & 2 deletions src/cli/commands/estimate/index.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export const estimate = async ({
folderPrompt,
chatPrompt,
contentType,
targetAudience
targetAudience,
linkHosted,
}: AutodocRepoConfig) => {
const json = path.join(output, 'docs', 'json/');

Expand All @@ -41,7 +42,8 @@ export const estimate = async ({
folderPrompt,
chatPrompt,
contentType,
targetAudience
targetAudience,
linkHosted,
},
true,
);
Expand Down
3 changes: 3 additions & 0 deletions src/cli/commands/index/convertJsonToMarkdown.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const convertJsonToMarkdown = async ({
folderPrompt: folderPrompt,
contentType: contentType,
targetAudience: targetAudience,
linkHosted: linkHosted,
}: AutodocRepoConfig) => {
/**
* Count the number of files in the project
Expand All @@ -35,6 +36,7 @@ export const convertJsonToMarkdown = async ({
folderPrompt,
contentType,
targetAudience,
linkHosted,
});

/**
Expand Down Expand Up @@ -95,6 +97,7 @@ export const convertJsonToMarkdown = async ({
folderPrompt,
contentType,
targetAudience,
linkHosted,
});
spinnerSuccess(`Created ${files} mardown files...`);
};
4 changes: 4 additions & 0 deletions src/cli/commands/index/index.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const index = async ({
chatPrompt,
contentType,
targetAudience,
linkHosted,
}: AutodocRepoConfig) => {
const json = path.join(output, 'docs', 'json/');
const markdown = path.join(output, 'docs', 'markdown/');
Expand All @@ -40,6 +41,7 @@ export const index = async ({
chatPrompt,
contentType,
targetAudience,
linkHosted,
});
updateSpinnerText('Processing repository...');
spinnerSuccess();
Expand All @@ -60,6 +62,7 @@ export const index = async ({
chatPrompt,
contentType,
targetAudience,
linkHosted,
});
spinnerSuccess();

Expand All @@ -76,6 +79,7 @@ export const index = async ({
chatPrompt,
contentType,
targetAudience,
linkHosted,
});
spinnerSuccess();
};
Expand Down
12 changes: 10 additions & 2 deletions src/cli/commands/index/processRepository.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const processRepository = async (
folderPrompt,
contentType,
targetAudience,
linkHosted,
}: AutodocRepoConfig,
dryRun?: boolean,
) => {
Expand All @@ -65,10 +66,11 @@ export const processRepository = async (
contentType,
filePrompt,
targetAudience,
linkHosted,
}): Promise<void> => {
const content = await fs.readFile(filePath, 'utf-8');
const markdownFilePath = path.join(outputRoot, filePath);
const url = githubFileUrl(repositoryUrl, inputRoot, filePath);
const url = githubFileUrl(repositoryUrl, inputRoot, filePath, linkHosted);
const summaryPrompt = createCodeFileSummary(
projectName,
projectName,
Expand Down Expand Up @@ -181,6 +183,7 @@ export const processRepository = async (
contentType,
folderPrompt,
shouldIgnore,
linkHosted,
}): Promise<void> => {
/**
* For now we don't care about folders
Expand All @@ -192,7 +195,8 @@ export const processRepository = async (
const contents = (await fs.readdir(folderPath)).filter(
(fileName) => !shouldIgnore(fileName),
);
const url = githubFolderUrl(repositoryUrl, inputRoot, folderPath);
// eslint-disable-next-line prettier/prettier
const url = githubFolderUrl(repositoryUrl, inputRoot, folderPath, linkHosted);
const allFiles: (FileSummary | null)[] = await Promise.all(
contents.map(async (fileName) => {
const entryPath = path.join(folderPath, fileName);
Expand Down Expand Up @@ -295,6 +299,7 @@ export const processRepository = async (
folderPrompt,
contentType,
targetAudience,
linkHosted,
}),
traverseFileSystem({
inputPath: inputRoot,
Expand All @@ -308,6 +313,7 @@ export const processRepository = async (
folderPrompt,
contentType,
targetAudience,
linkHosted,
}),
]);

Expand All @@ -333,6 +339,7 @@ export const processRepository = async (
folderPrompt,
contentType,
targetAudience,
linkHosted,
});
spinnerSuccess(`Processing ${files} files...`);

Expand All @@ -349,6 +356,7 @@ export const processRepository = async (
folderPrompt,
contentType,
targetAudience,
linkHosted,
});
spinnerSuccess(`Processing ${folders} folders... `);
stopSpinner();
Expand Down
1 change: 1 addition & 0 deletions src/cli/commands/init/index.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const makeConfigTemplate = (
chatPrompt: '',
contentType: 'code',
targetAudience: 'smart developer',
linkHosted: false,
};
};

Expand Down
2 changes: 2 additions & 0 deletions src/cli/commands/query/createChatChain.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Chat History:
Follow Up Input: {question}
Standalone question:`);

// eslint-disable-next-line prettier/prettier
const makeQAPrompt = (projectName: string, repositoryUrl: string, contentType: string, chatPrompt: string, targetAudience: string) =>
PromptTemplate.fromTemplate(
`You are an AI assistant for a software project called ${projectName}. You are trained on all the ${contentType} that makes up this project.
Expand Down Expand Up @@ -58,6 +59,7 @@ export const makeChain = (
prompt: CONDENSE_PROMPT,
});

// eslint-disable-next-line prettier/prettier
const QA_PROMPT = makeQAPrompt(projectName, repositoryUrl, contentType, chatPrompt, targetAudience);
const docChain = loadQAChain(
new OpenAIChat({
Expand Down
22 changes: 16 additions & 6 deletions src/cli/utils/FileUtil.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,28 @@ export const githubFileUrl = (
githubRoot: string,
inputRoot: string,
filePath: string,
linkHosted: boolean,
): string => {
return `${githubRoot}/blob/master/${filePath.substring(
inputRoot.length - 1,
)}`;
if (linkHosted) {
return `${githubRoot}/${filePath.substring(inputRoot.length - 1)}`;
} else {
return `${githubRoot}/blob/master/${filePath.substring(
inputRoot.length - 1,
)}`;
}
};

export const githubFolderUrl = (
githubRoot: string,
inputRoot: string,
folderPath: string,
linkHosted: boolean,
): string => {
return `${githubRoot}/tree/master/${folderPath.substring(
inputRoot.length - 1,
)}`;
if (linkHosted) {
return `${githubRoot}/${folderPath.substring(inputRoot.length - 1)}`;
} else {
return `${githubRoot}/tree/master/${folderPath.substring(
inputRoot.length - 1,
)}`;
}
};
4 changes: 3 additions & 1 deletion src/cli/utils/traverseFileSystem.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const traverseFileSystem = async (
): Promise<void> => {
try {
// eslint-disable-next-line prettier/prettier
const { inputPath, projectName, processFile, processFolder, ignore, filePrompt, folderPrompt, contentType, targetAudience } = params;
const { inputPath, projectName, processFile, processFolder, ignore, filePrompt, folderPrompt, contentType, targetAudience, linkHosted } = params;

try {
await fs.access(inputPath);
Expand Down Expand Up @@ -43,6 +43,7 @@ export const traverseFileSystem = async (
folderPrompt,
contentType,
targetAudience,
linkHosted,
});
}
}),
Expand All @@ -61,6 +62,7 @@ export const traverseFileSystem = async (
filePrompt,
contentType,
targetAudience,
linkHosted,
});
}
}),
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type AutodocRepoConfig = {
chatPrompt: string;
contentType: string;
targetAudience: string;
linkHosted: boolean;
};

export type FileSummary = {
Expand All @@ -33,6 +34,7 @@ export type ProcessFileParams = {
contentType: string;
filePrompt: string;
targetAudience: string;
linkHosted: boolean;
};

export type ProcessFile = (params: ProcessFileParams) => Promise<void>;
Expand All @@ -54,6 +56,7 @@ export type ProcessFolderParams = {
contentType: string;
folderPrompt: string;
targetAudience: string;
linkHosted: boolean;
shouldIgnore: (fileName: string) => boolean;
};

Expand All @@ -69,6 +72,7 @@ export type TraverseFileSystemParams = {
folderPrompt: string;
contentType: string;
targetAudience: string;
linkHosted: boolean;
};

export enum LLMModels {
Expand Down

AltStyle によって変換されたページ (->オリジナル) /