10
10
from pathlib import Path
11
11
from datetime import datetime
12
12
13
- import pinecone
14
- from dotenv import load_dotenv
15
-
16
13
from llama_index .core import VectorStoreIndex , Document , StorageContext
17
14
from llama_index .vector_stores .pinecone import PineconeVectorStore
18
15
@@ -28,33 +25,21 @@ class AudioIndex:
28
25
def __init__ (self ):
29
26
"""Initialize the audio index."""
30
27
try :
31
- # Initialize Pinecone
32
- pinecone .init (
33
- api_key = config .get ("PINECONE_API_KEY" ),
34
- environment = config .get ("PINECONE_ENV" )
28
+ # Initialize Pinecone vector store through LlamaIndex
29
+ vector_store = PineconeVectorStore (
30
+ api_key = config .pinecone_api_key ,
31
+ environment = config .pinecone_environment ,
32
+ index_name = config .pinecone_index_name
35
33
)
36
34
37
- # Get or create index
38
- index_name = "audiokit"
39
- if index_name not in pinecone .list_indexes ():
40
- pinecone .create_index (
41
- name = index_name ,
42
- dimension = 1536 , # Default for OpenAI embeddings
43
- metric = "cosine"
44
- )
45
-
46
- # Setup vector store
47
- pinecone_index = pinecone .Index (index_name )
48
- vector_store = PineconeVectorStore (pinecone_index = pinecone_index )
49
-
50
35
# Create storage context
51
36
storage_context = StorageContext .from_defaults (vector_store = vector_store )
52
37
53
38
# Initialize vector store index
54
39
self .index = VectorStoreIndex .from_documents (
55
40
[],
56
41
storage_context = storage_context ,
57
- show_progress = True # Show progress in the method
42
+ show_progress = True
58
43
)
59
44
60
45
logger .info ("Audio index initialized successfully" )
0 commit comments