diff --git a/src/handlers/ask-llm.ts b/src/handlers/ask-llm.ts index 7e6a891..cccf7f2 100644 --- a/src/handlers/ask-llm.ts +++ b/src/handlers/ask-llm.ts @@ -14,7 +14,7 @@ import { DEFAULT_SYSTEM_MESSAGE } from "../adapters/openai/helpers/prompts"; * @returns The response from GPT * @throws If no question is provided */ -export async function askQuestion(context: Context, question: string) { +export async function askQuestion(context: Context<"issue_comment.created">, question: string) { if (!question) { throw context.logger.error("No question provided"); } @@ -22,6 +22,7 @@ export async function askQuestion(context: Context, question: string) { context, owner: context.payload.repository.owner.login, repo: context.payload.repository.name, + issueNum: context.payload.issue.number, }); const formattedChat = await formatChatHistory(context, streamlinedComments, specAndBodies); context.logger.info(`${formattedChat.join("")}`); diff --git a/src/helpers/format-chat-history.ts b/src/helpers/format-chat-history.ts index b1b5ecb..aa9f13d 100644 --- a/src/helpers/format-chat-history.ts +++ b/src/helpers/format-chat-history.ts @@ -13,7 +13,7 @@ import { splitKey } from "./issue"; * @returns A promise that resolves to a formatted string representing the chat history. */ export async function formatChatHistory( - context: Context, + context: Context<"issue_comment.created">, streamlined: Record, specAndBodies: Record ): Promise { diff --git a/tests/main.test.ts b/tests/main.test.ts index fd25aa7..91de76e 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -258,13 +258,13 @@ function createContext(body = TEST_SLASH_COMMAND) { const user = db.users.findFirst({ where: { id: { equals: 1 } } }); return { payload: { - issue: db.issue.findFirst({ where: { id: { equals: 1 } } }) as unknown as Context["payload"]["issue"], + issue: db.issue.findFirst({ where: { id: { equals: 1 } } }) as unknown as Context<"issue_comment.created">["payload"]["issue"], sender: user, - repository: db.repo.findFirst({ where: { id: { equals: 1 } } }) as unknown as Context["payload"]["repository"], - comment: { body, user: user } as unknown as Context["payload"]["comment"], + repository: db.repo.findFirst({ where: { id: { equals: 1 } } }) as unknown as Context<"issue_comment.created">["payload"]["repository"], + comment: { body, user: user } as unknown as Context<"issue_comment.created">["payload"]["comment"], action: "created" as string, - installation: { id: 1 } as unknown as Context["payload"]["installation"], - organization: { login: "ubiquity" } as unknown as Context["payload"]["organization"], + installation: { id: 1 } as unknown as Context<"issue_comment.created">["payload"]["installation"], + organization: { login: "ubiquity" } as unknown as Context<"issue_comment.created">["payload"]["organization"], }, owner: "ubiquity", repo: "test-repo", @@ -408,5 +408,5 @@ function createContext(body = TEST_SLASH_COMMAND) { }, octokit: new octokit.Octokit(), eventName: "issue_comment.created" as SupportedEventsU, - } as unknown as Context; + } as unknown as Context<"issue_comment.created">; }