Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Use user openAI key also for title generation

Tomas Valenta71311b26906c
diff --git a/github/pullRequest.ts b/github/pullRequest.ts
index 37e25a304..baf3ec643 100644
--- a/github/pullRequest.ts
+++ b/github/pullRequest.ts
@@ -6,13 +6,14 @@ import { deployments, prisma } from 'db/prisma'
import { GitHubClient } from './client'
-const configuration = new Configuration({
- apiKey: process.env.OPENAI_API_KEY,
-})
-const openai = new OpenAIApi(configuration)
+export async function prTitleFromInstructions(instructions: string, openAIKey?: string) {
+ const configuration = new Configuration({
+ apiKey: openAIKey || process.env.OPENAI_API_KEY,
+ })
+
+ const openai = new OpenAIApi(configuration)
-export async function prTitleFromInstructions(instructions: string) {
try {
const result = await backOff(() => openai.createChatCompletion({
model: 'gpt-3.5-turbo',
diff --git a/pages/api/agent/index.ts b/pages/api/agent/index.ts
index 7f695c1d7..8f720e717 100644
--- a/pages/api/agent/index.ts
+++ b/pages/api/agent/index.ts
@@ -94,7 +94,7 @@ async function postAgent(req: NextApiRequest, res: NextApiResponse) {
repositoryID,
})
- const prTitle = await prTitleFromInstructions(body)
+ const prTitle = await prTitleFromInstructions(body, openAIKey)
if (!prTitle) {
throw new Error('Generated PR title is empty')