Skip to content

Commit 621fa54

Browse files
committed
moved indexname and timeout into config
1 parent b949de7 commit 621fa54

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

app/api/read/route.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { PineconeClient } from '@pinecone-database/pinecone'
33
import {
44
queryPineconeVectorStoreAndQueryLLM,
55
} from '../../../utils'
6+
import { indexName } from '../../../config'
67

78
export async function POST(req: NextRequest) {
89
const body = await req.json()
@@ -12,7 +13,6 @@ export async function POST(req: NextRequest) {
1213
environment: process.env.PINECONE_ENVIRONMENT || ''
1314
})
1415

15-
const indexName = 'my-test-index-2'
1616
const text = await queryPineconeVectorStoreAndQueryLLM(client, indexName, body)
1717

1818
return NextResponse.json({

app/api/setup/route.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
createPineconeIndex,
77
updatePinecone
88
} from '../../../utils'
9+
import { indexName } from '../../../config'
910

1011
export async function POST() {
1112
const loader = new DirectoryLoader('./documents', {
@@ -14,7 +15,6 @@ export async function POST() {
1415
})
1516

1617
const docs = await loader.load()
17-
const indexName = 'my-test-index-2'
1818
const vectorDimensions = 1536
1919

2020
const client = new PineconeClient()

config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const indexName = 'my-test-pinecone-index'
2+
export const timeout = 180000

utils.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter'
33
import { OpenAI } from 'langchain/llms/openai'
44
import { loadQAStuffChain } from 'langchain/chains'
55
import { Document } from 'langchain/document'
6+
import { timeout } from './config'
67

78
export const queryPineconeVectorStoreAndQueryLLM = async (
89
client,
@@ -73,7 +74,7 @@ export const createPineconeIndex = async (
7374
// 6. Log successful creation
7475
console.log(`Creating index.... please wait for it to finish initializing.`);
7576
// 7. Wait 60 seconds for index initialization
76-
await new Promise((resolve) => setTimeout(resolve, 180000));
77+
await new Promise((resolve) => setTimeout(resolve, timeout));
7778
} else {
7879
// 8. Log if index already exists
7980
console.log(`"${indexName}" already exists.`);

0 commit comments

Comments
 (0)