akshansh36 commited on
Commit
0911c21
·
verified ·
1 Parent(s): a8595ef

Delete create_embeddings.py

Browse files
Files changed (1) hide show
  1. create_embeddings.py +0 -51
create_embeddings.py DELETED
@@ -1,51 +0,0 @@
1
- import pinecone
2
- from langchain_google_genai import GoogleGenerativeAIEmbeddings
3
- from paragraphs2 import podcasts
4
- import uuid
5
- google_embeddings = GoogleGenerativeAIEmbeddings(
6
- model="models/embedding-001", # Correct model name
7
- google_api_key="AIzaSyANNRKfEb-YnVIBaSAq6hQ38XpxxGwvaws" # Your API key
8
- )
9
-
10
- # Initialize Pinecone instance
11
- pc = pinecone.Pinecone(
12
- api_key="4a80f293-ae6d-489a-a7d8-33ea3fcdd26b" # Your Pinecone API key
13
- )
14
-
15
- # Define the Pinecone index name (make sure it exists in your Pinecone dashboard)
16
- index_name = "iocl2"
17
- index = pc.Index(index_name)
18
-
19
- def create_embedding(variable):
20
- try:
21
- content=variable.get("description")
22
- url=variable.get("url")
23
- tag=variable.get("tag")
24
- updated_url=""
25
- if isinstance(url,list):
26
- updated_url=",".join(url)
27
- else:
28
- updated_url=url
29
-
30
- embedding=google_embeddings.embed_query(content)
31
- vectors=[]
32
- vectors.append({
33
- 'id': str(uuid.uuid4()),
34
- 'values': embedding,
35
- 'metadata': {
36
- 'chunk': content,
37
- "url":updated_url,
38
- "tag":tag
39
- }
40
- })
41
- index.upsert(vectors)
42
- print(f"inserted : {updated_url}")
43
- except Exception as e:
44
- print(f"error occured {e}")
45
-
46
-
47
- create_embedding(podcasts)
48
-
49
-
50
-
51
-