Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -77,9 +77,9 @@ headers = {"Authorization": f"Bearer {hf_token}"}
|
|
77 |
hf_embeddings = HFEmbeddings(api_url, headers)
|
78 |
|
79 |
#Pinecone账号:
|
80 |
-
PINECONE_API_KEY = os.getenv('PINECONE_API_KEY')
|
81 |
-
PINECONE_ENVIRONMENT = os.getenv('PINECONE_ENVIRONMENT')
|
82 |
-
PINECONE_INDEX_NAME = os.getenv('PINECONE_INDEX_NAME')
|
83 |
#def generate_random_string(length):
|
84 |
# letters = string.ascii_letters
|
85 |
# random_string = ''.join(random.choice(letters) for _ in range(length))
|
@@ -91,9 +91,13 @@ PINECONE_INDEX_NAME = os.getenv('PINECONE_INDEX_NAME')
|
|
91 |
# return ''.join(random.choice(letters) for i in range(length))
|
92 |
#random_string = generate_random_string(8)
|
93 |
|
|
|
|
|
|
|
|
|
94 |
index_name = PINECONE_INDEX_NAME
|
95 |
#namespace = random_string
|
96 |
-
namespace = "HF-GRADIO-
|
97 |
|
98 |
#def exit_handler():
|
99 |
# pinecone.init(api_key=PINECONE_API_KEY, environment=PINECONE_ENVIRONMENT)
|
@@ -104,6 +108,11 @@ namespace = "HF-GRADIO-0909"
|
|
104 |
|
105 |
pinecone.init(api_key=PINECONE_API_KEY, environment=PINECONE_ENVIRONMENT)
|
106 |
vector_db = Pinecone.from_texts(db_texts, hf_embeddings, index_name=index_name, namespace=namespace)
|
|
|
|
|
|
|
|
|
|
|
107 |
#vector_db = Pinecone.from_texts([t.page_content for t in db_texts], hf_embeddings, index_name=index_name, namespace=namespace)
|
108 |
#docsearch = Pinecone.from_texts([t.page_content for t in texts], embeddings, index_name=index_name, namespace=namespace)
|
109 |
print("***********************************")
|
|
|
77 |
hf_embeddings = HFEmbeddings(api_url, headers)
|
78 |
|
79 |
#Pinecone账号:
|
80 |
+
#PINECONE_API_KEY = os.getenv('PINECONE_API_KEY')
|
81 |
+
#PINECONE_ENVIRONMENT = os.getenv('PINECONE_ENVIRONMENT')
|
82 |
+
#PINECONE_INDEX_NAME = os.getenv('PINECONE_INDEX_NAME')
|
83 |
#def generate_random_string(length):
|
84 |
# letters = string.ascii_letters
|
85 |
# random_string = ''.join(random.choice(letters) for _ in range(length))
|
|
|
91 |
# return ''.join(random.choice(letters) for i in range(length))
|
92 |
#random_string = generate_random_string(8)
|
93 |
|
94 |
+
PINECONE_API_KEY = "5f07b52e-2a16-42a3-89c4-8899c584109e"
|
95 |
+
PINECONE_ENVIRONMENT = "asia-southeast1-gcp-free"
|
96 |
+
PINECONE_INDEX_NAME = "myindex-allminilm-l6-v2-384"
|
97 |
+
|
98 |
index_name = PINECONE_INDEX_NAME
|
99 |
#namespace = random_string
|
100 |
+
namespace = "HF-GRADIO-0914"
|
101 |
|
102 |
#def exit_handler():
|
103 |
# pinecone.init(api_key=PINECONE_API_KEY, environment=PINECONE_ENVIRONMENT)
|
|
|
108 |
|
109 |
pinecone.init(api_key=PINECONE_API_KEY, environment=PINECONE_ENVIRONMENT)
|
110 |
vector_db = Pinecone.from_texts(db_texts, hf_embeddings, index_name=index_name, namespace=namespace)
|
111 |
+
|
112 |
+
#Considering Python apps automatically execute codes, a Vector-DB should have been created under namespace = "HF-GRADIO-0909"
|
113 |
+
#when this app begins to run, however, the real world test results show not that way (i.e. namespace not created).
|
114 |
+
#then input something in the input text box and click submit, to see how the app will react.
|
115 |
+
|
116 |
#vector_db = Pinecone.from_texts([t.page_content for t in db_texts], hf_embeddings, index_name=index_name, namespace=namespace)
|
117 |
#docsearch = Pinecone.from_texts([t.page_content for t in texts], embeddings, index_name=index_name, namespace=namespace)
|
118 |
print("***********************************")
|