-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathverify_setup.py
More file actions
53 lines (38 loc) · 1.2 KB
/
Copy pathverify_setup.py
File metadata and controls
53 lines (38 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
from dotenv import load_dotenv
# TODO Make sure you...
# pip install pinecone-client
from pinecone import Pinecone, ServerlessSpec
# TODO Make sure you...
# pip install openai
from openai import OpenAI
# We're loading env variables with dotenv
# Store your env variable in .env for
# PINECONE_API_KEY
# OPENAI_API_KEY
# This loads all the env variables defined in your .env file
# TODO pip install python-dotenv
load_dotenv()
print('Checking OpenAI Connectivity....')
# This call works becasue you OPENAI_API_KEY has been loaded
# Openai fetches it from the env variable unless you explicitly define an api key in the call
oa = OpenAI() # could be OpenAI(api_key=os.getenv('OPENAI_API_KEY')
response = oa.embeddings.create(
input="Check embedding this works",
model="text-embedding-3-small"
)
print("OpenAI Check complete")
print('Checking Pinecone Connectivity....')
pc = Pinecone(api_key=os.getenv('PINECONE_API_KEY'))
pc.create_index(
name="test",
dimension=1536,
spec=ServerlessSpec(
cloud='aws',
region='us-east-1'
)
)
index = pc.Index("test")
print(index.describe_index_stats())
pc.delete_index("test")
print("Pinecone check comeplete, you're ready to go")