Skip to content

Commit 61550f7

Browse files
[ref] update env var namings to match expected (#332)
1 parent 05506f5 commit 61550f7

32 files changed

+161
-162
lines changed

.github/workflows/_run_e2e_tests.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,9 @@ jobs:
8282
- name: Run notebook tests
8383
if: ${{ inputs.run-notebooks }}
8484
env:
85-
ASTRA_DB_TOKEN: "${{ secrets[inputs.astradb-token-secret-name] }}"
8685
ASTRA_DB_APPLICATION_TOKEN: "${{ secrets[inputs.astradb-token-secret-name] }}"
87-
ASTRA_DB_ENDPOINT: "${{ steps.astra-db.outputs.db_endpoint }}"
8886
ASTRA_DB_API_ENDPOINT: "${{ steps.astra-db.outputs.db_endpoint }}"
8987
ASTRA_DB_ID: "${{ steps.astra-db.outputs.db_id }}"
90-
OPEN_AI_KEY: "${{ secrets.E2E_TESTS_OPEN_AI_KEY }}"
9188
OPENAI_API_KEY: "${{ secrets.E2E_TESTS_OPEN_AI_KEY }}"
9289
LANGCHAIN_API_KEY: "${{ secrets.E2E_TESTS_LANGCHAIN_API_KEY }}"
9390
LLAMA_CLOUD_API_KEY: "${{ secrets.E2E_TESTS_LLAMA_CLOUD_API_KEY }}"
@@ -104,14 +101,13 @@ jobs:
104101
if: ${{ inputs.run-tests }}
105102
env:
106103
VECTOR_DATABASE_TYPE: "${{ inputs.vector-database-type }}"
107-
ASTRA_DB_TOKEN: "${{ secrets[inputs.astradb-token-secret-name] }}"
108-
ASTRA_DB_ENDPOINT: "${{ steps.astra-db.outputs.db_endpoint }}"
104+
ASTRA_DB_APPLICATION_TOKEN: "${{ secrets[inputs.astradb-token-secret-name] }}"
105+
ASTRA_DB_API_ENDPOINT: "${{ steps.astra-db.outputs.db_endpoint }}"
109106
ASTRA_DB_ID: "${{ steps.astra-db.outputs.db_id }}"
110107
ASTRA_DB_ENV: "${{ inputs.astradb-env }}"
111-
OPEN_AI_KEY: "${{ secrets.E2E_TESTS_OPEN_AI_KEY }}"
112108
OPENAI_API_KEY: "${{ secrets.E2E_TESTS_OPEN_AI_KEY }}"
113-
AZURE_OPEN_AI_KEY: "${{ secrets.E2E_TESTS_AZURE_OPEN_AI_KEY }}"
114-
AZURE_OPEN_AI_ENDPOINT: "${{ secrets.E2E_TESTS_AZURE_OPEN_AI_ENDPOINT }}"
109+
AZURE_OPENAI_API_KEY: "${{ secrets.E2E_TESTS_AZURE_OPEN_AI_KEY }}"
110+
AZURE_OPENAI_ENDPOINT: "${{ secrets.E2E_TESTS_AZURE_OPEN_AI_ENDPOINT }}"
115111
AZURE_BLOB_STORAGE_CONNECTION_STRING: "${{ secrets.E2E_TESTS_AZURE_BLOB_STORAGE_CONNECTION_STRING }}"
116112
GCLOUD_ACCOUNT_KEY_JSON: "${{ secrets.E2E_TESTS_GCLOUD_ACCOUNT_KEY_JSON }}"
117113
GOOGLE_API_KEY: "${{ secrets.E2E_TESTS_GOOGLE_API_KEY }}"

.github/workflows/run-benchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
- name: Run
2323
env:
24-
OPEN_AI_KEY: "${{ secrets.E2E_TESTS_OPEN_AI_KEY }}"
24+
OPENAI_API_KEY: "${{ secrets.E2E_TESTS_OPEN_AI_KEY }}"
2525
NVIDIA_API_KEY: "${{ secrets.E2E_TESTS_NVIDIA_API_KEY }}"
2626
run: |
2727
cd ragstack-e2e-tests

docs/modules/examples/pages/rag-with-cassio.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ You will need a secure connect bundle and a user with Database Administrator per
5656
----
5757
ASTRA_DB_SECURE_BUNDLE_PATH = os.getenv("ASTRA_DB_SECURE_BUNDLE_PATH")
5858
ASTRA_DB_APPLICATION_TOKEN = os.getenv("ASTRA_DB_APPLICATION_TOKEN")
59-
ASTRA_DB_TOKEN_BASED_USERNAME = "token"
59+
ASTRA_DB_APPLICATION_TOKEN_BASED_USERNAME = "token"
6060
ASTRA_DB_KEYSPACE = os.getenv("ASTRA_DB_NAMESPACE")
6161
ASTRA_DB_TABLE_NAME = os.getenv("ASTRA_DB_COLLECTION")
6262
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
@@ -81,7 +81,7 @@ def getCQLSession(mode='astra_db'):
8181
"secure_connect_bundle": ASTRA_DB_SECURE_BUNDLE_PATH,
8282
},
8383
auth_provider=PlainTextAuthProvider(
84-
ASTRA_DB_TOKEN_BASED_USERNAME,
84+
ASTRA_DB_APPLICATION_TOKEN_BASED_USERNAME,
8585
ASTRA_DB_APPLICATION_TOKEN,
8686
),
8787
)

evaluation/langchain_trulens_full.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
"source": [
4242
"# this notebook assumes the following env vars exist in a .env file:\n",
4343
"#\n",
44-
"# ASTRA_DB_ENDPOINT=https://<uuid>-<region>.apps.astra.datastax.com\n",
45-
"# ASTRA_DB_TOKEN=AstraCS:<secret>:<secret>\n",
44+
"# ASTRA_DB_API_ENDPOINT=https://<uuid>-<region>.apps.astra.datastax.com\n",
45+
"# ASTRA_DB_APPLICATION_TOKEN=AstraCS:<secret>:<secret>\n",
4646
"# AZURE_OPENAI_ENDPOINT=https://<domain>.openai.azure.com/\n",
4747
"# AZURE_OPENAI_API_KEY=<secret>\n",
4848
"# OPENAI_API_TYPE=azure\n",
@@ -114,8 +114,8 @@
114114
"astra_db_vstore = AstraDB(\n",
115115
" collection_name=astra_db_collection_name,\n",
116116
" embedding=open_ai_embeddings,\n",
117-
" token=os.getenv(\"ASTRA_DB_TOKEN\"),\n",
118-
" api_endpoint=os.getenv(\"ASTRA_DB_ENDPOINT\")\n",
117+
" token=os.getenv(\"ASTRA_DB_APPLICATION_TOKEN\"),\n",
118+
" api_endpoint=os.getenv(\"ASTRA_DB_API_ENDPOINT\")\n",
119119
")"
120120
]
121121
},
@@ -515,4 +515,4 @@
515515
},
516516
"nbformat": 4,
517517
"nbformat_minor": 2
518-
}
518+
}

evaluation/tru_shared.py

Lines changed: 52 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
# this code assumes the following env vars exist in a .env file:
2323
#
24-
# ASTRA_DB_ENDPOINT
25-
# ASTRA_DB_TOKEN
24+
# ASTRA_DB_API_ENDPOINT
25+
# ASTRA_DB_APPLICATION_TOKEN
2626
# AZURE_OPENAI_ENDPOINT
2727
# AZURE_OPENAI_API_KEY
2828
# OPENAI_API_VERSION
@@ -48,13 +48,15 @@ def get_test_data():
4848
if os.path.isdir(os.path.join(base_path, name)):
4949
datasets[name] = []
5050
with open(os.path.join(base_path, name, "rag_dataset.json")) as f:
51-
examples = json.load(f)['examples']
51+
examples = json.load(f)["examples"]
5252
for e in examples:
5353
datasets[name].append(e["query"])
54-
golden_set.append({
55-
"query": e["query"],
56-
"response": e["reference_answer"],
57-
})
54+
golden_set.append(
55+
{
56+
"query": e["query"],
57+
"response": e["reference_answer"],
58+
}
59+
)
5860
print("Loaded dataset: ", name)
5961
return datasets, golden_set
6062

@@ -75,39 +77,45 @@ def get_feedback_functions(pipeline, golden_set):
7577
# Define a groundedness feedback function
7678
grounded = Groundedness(groundedness_provider=azureOpenAI)
7779
f_groundedness = (
78-
Feedback(grounded.groundedness_measure_with_cot_reasons,
79-
name="groundedness")
80-
.on(context.collect()).on_output()
80+
Feedback(grounded.groundedness_measure_with_cot_reasons, name="groundedness")
81+
.on(context.collect())
82+
.on_output()
8183
.aggregate(grounded.grounded_statements_aggregator)
8284
)
8385

8486
# Question/answer relevance between overall question and answer.
85-
f_answer_relevance = (
86-
Feedback(azureOpenAI.relevance_with_cot_reasons,
87-
name="answer_relevance")
88-
.on_input_output()
89-
)
87+
f_answer_relevance = Feedback(
88+
azureOpenAI.relevance_with_cot_reasons, name="answer_relevance"
89+
).on_input_output()
9090

9191
# Question/statement relevance between question and each context chunk.
9292
f_context_relevance = (
93-
Feedback(azureOpenAI.qs_relevance_with_cot_reasons,
94-
name="context_relevance")
95-
.on_input().on(context)
93+
Feedback(azureOpenAI.qs_relevance_with_cot_reasons, name="context_relevance")
94+
.on_input()
95+
.on(context)
9696
.aggregate(np.mean)
9797
)
9898

9999
# GroundTruth for comparing the Answer to the Ground-Truth Answer
100-
ground_truth_collection = GroundTruthAgreement(
101-
golden_set, provider=azureOpenAI)
102-
f_answer_correctness = (
103-
Feedback(ground_truth_collection.agreement_measure,
104-
name="answer_correctness")
105-
.on_input_output()
106-
)
107-
return [f_answer_relevance, f_context_relevance, f_groundedness, f_answer_correctness]
108-
109-
110-
def get_recorder(framework: Framework, pipeline, app_id: str, golden_set: [], feedback_mode: str = "deferred"):
100+
ground_truth_collection = GroundTruthAgreement(golden_set, provider=azureOpenAI)
101+
f_answer_correctness = Feedback(
102+
ground_truth_collection.agreement_measure, name="answer_correctness"
103+
).on_input_output()
104+
return [
105+
f_answer_relevance,
106+
f_context_relevance,
107+
f_groundedness,
108+
f_answer_correctness,
109+
]
110+
111+
112+
def get_recorder(
113+
framework: Framework,
114+
pipeline,
115+
app_id: str,
116+
golden_set: [],
117+
feedback_mode: str = "deferred",
118+
):
111119
feedbacks = get_feedback_functions(pipeline, golden_set)
112120
if framework == Framework.LANG_CHAIN:
113121
return TruChain(
@@ -124,11 +132,12 @@ def get_recorder(framework: Framework, pipeline, app_id: str, golden_set: [], fe
124132
feedback_mode=feedback_mode,
125133
)
126134
else:
127-
raise Exception(
128-
f"Unknown framework: {framework} specified for get_recorder()")
135+
raise Exception(f"Unknown framework: {framework} specified for get_recorder()")
129136

130137

131-
def get_azure_chat_model(framework: Framework, deployment_name: str, model_version: str):
138+
def get_azure_chat_model(
139+
framework: Framework, deployment_name: str, model_version: str
140+
):
132141
if framework == Framework.LANG_CHAIN:
133142
return AzureChatOpenAI(
134143
azure_deployment=deployment_name,
@@ -146,15 +155,13 @@ def get_azure_chat_model(framework: Framework, deployment_name: str, model_versi
146155
temperature=temperature,
147156
)
148157
else:
149-
raise Exception(
150-
f"Unknown framework: {framework} specified for getChatModel()")
158+
raise Exception(f"Unknown framework: {framework} specified for getChatModel()")
151159

152160

153161
def get_azure_embeddings_model(framework: Framework):
154162
if framework == Framework.LANG_CHAIN:
155163
return AzureOpenAIEmbeddings(
156-
azure_deployment="text-embedding-ada-002",
157-
openai_api_version="2023-05-15"
164+
azure_deployment="text-embedding-ada-002", openai_api_version="2023-05-15"
158165
)
159166
elif framework == Framework.LLAMA_INDEX:
160167
return AzureOpenAIEmbedding(
@@ -166,27 +173,29 @@ def get_azure_embeddings_model(framework: Framework):
166173
)
167174
else:
168175
raise Exception(
169-
f"Unknown framework: {framework} specified for getEmbeddingsModel()")
176+
f"Unknown framework: {framework} specified for getEmbeddingsModel()"
177+
)
170178

171179

172180
def get_astra_vector_store(framework: Framework, collection_name: str):
173181
if framework == Framework.LANG_CHAIN:
174182
return LangChainAstraDBVectorStore(
175183
collection_name=collection_name,
176184
embedding=get_azure_embeddings_model(framework),
177-
token=os.getenv("ASTRA_DB_TOKEN"),
178-
api_endpoint=os.getenv("ASTRA_DB_ENDPOINT")
185+
token=os.getenv("ASTRA_DB_APPLICATION_TOKEN"),
186+
api_endpoint=os.getenv("ASTRA_DB_API_ENDPOINT"),
179187
)
180188
elif framework == Framework.LLAMA_INDEX:
181189
return AstraDBVectorStore(
182190
collection_name=collection_name,
183-
api_endpoint=os.getenv("ASTRA_DB_ENDPOINT"),
184-
token=os.getenv("ASTRA_DB_TOKEN"),
191+
api_endpoint=os.getenv("ASTRA_DB_API_ENDPOINT"),
192+
token=os.getenv("ASTRA_DB_APPLICATION_TOKEN"),
185193
embedding_dimension=1536,
186194
)
187195
else:
188196
raise Exception(
189-
f"Unknown framework: {framework} specified for get_astra_vector_store()")
197+
f"Unknown framework: {framework} specified for get_astra_vector_store()"
198+
)
190199

191200

192201
def execute_query(framework: Framework, pipeline, query):
@@ -195,8 +204,7 @@ def execute_query(framework: Framework, pipeline, query):
195204
elif framework == Framework.LLAMA_INDEX:
196205
pipeline.query(query)
197206
else:
198-
raise Exception(
199-
f"Unknown framework: {framework} specified for execute_query()")
207+
raise Exception(f"Unknown framework: {framework} specified for execute_query()")
200208

201209

202210
# runs the pipeline across all queries in all known datasets

examples/notebooks/FLARE.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@
9191
"from getpass import getpass\n",
9292
"\n",
9393
"# Enter your settings for Astra DB and OpenAI:\n",
94-
"os.environ[\"ASTRA_DB_ENDPOINT\"] = input(\"Enter your Astra DB API Endpoint: \")\n",
95-
"os.environ[\"ASTRA_DB_TOKEN\"] = getpass(\"Enter your Astra DB Token: \")\n",
96-
"os.environ[\"OPEN_AI_KEY\"] = getpass(\"Enter your OpenAI API Key: \")"
94+
"os.environ[\"ASTRA_DB_API_ENDPOINT\"] = input(\"Enter your Astra DB API Endpoint: \")\n",
95+
"os.environ[\"ASTRA_DB_APPLICATION_TOKEN\"] = getpass(\"Enter your Astra DB Token: \")\n",
96+
"os.environ[\"OPENAI_API_KEY\"] = getpass(\"Enter your OpenAI API Key: \")"
9797
]
9898
},
9999
{
@@ -155,8 +155,8 @@
155155
"vstore = AstraDB(\n",
156156
" collection_name=collection,\n",
157157
" embedding=embedding,\n",
158-
" token=os.environ[\"ASTRA_DB_TOKEN\"],\n",
159-
" api_endpoint=os.environ[\"ASTRA_DB_ENDPOINT\"],\n",
158+
" token=os.environ[\"ASTRA_DB_APPLICATION_TOKEN\"],\n",
159+
" api_endpoint=os.environ[\"ASTRA_DB_API_ENDPOINT\"],\n",
160160
")\n",
161161
"print(\"Astra vector store configured\")"
162162
]

examples/notebooks/QA_with_cassio.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@
119119
"\n",
120120
"# Enter your settings for Astra DB and OpenAI:\n",
121121
"os.environ[\"ASTRA_DB_ID\"] = input(\"Enter your Astra DB ID: \")\n",
122-
"os.environ[\"ASTRA_DB_TOKEN\"] = getpass(\"Enter your Astra DB Token: \")\n",
123-
"os.environ[\"OPEN_AI_KEY\"] = getpass(\"Enter your OpenAI API Key: \")"
122+
"os.environ[\"ASTRA_DB_APPLICATION_TOKEN\"] = getpass(\"Enter your Astra DB Token: \")\n",
123+
"os.environ[\"OPENAI_API_KEY\"] = getpass(\"Enter your OpenAI API Key: \")"
124124
]
125125
},
126126
{
@@ -199,7 +199,7 @@
199199
"\n",
200200
"cassio.init(\n",
201201
" database_id=os.environ[\"ASTRA_DB_ID\"],\n",
202-
" token=os.environ[\"ASTRA_DB_TOKEN\"],\n",
202+
" token=os.environ[\"ASTRA_DB_APPLICATION_TOKEN\"],\n",
203203
")"
204204
]
205205
},

examples/notebooks/RAG_with_cassio.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@
127127
"\n",
128128
"# Enter your settings for Astra DB and OpenAI:\n",
129129
"os.environ[\"ASTRA_DB_ID\"] = input(\"Enter your Astra DB ID: \")\n",
130-
"os.environ[\"ASTRA_DB_TOKEN\"] = getpass(\"Enter your Astra DB Token: \")\n",
131-
"os.environ[\"OPEN_AI_KEY\"] = getpass(\"Enter your OpenAI API Key: \")"
130+
"os.environ[\"ASTRA_DB_APPLICATION_TOKEN\"] = getpass(\"Enter your Astra DB Token: \")\n",
131+
"os.environ[\"OPENAI_API_KEY\"] = getpass(\"Enter your OpenAI API Key: \")"
132132
]
133133
},
134134
{
@@ -237,7 +237,7 @@
237237
"\n",
238238
"cassio.init(\n",
239239
" database_id=os.environ[\"ASTRA_DB_ID\"],\n",
240-
" token=os.environ[\"ASTRA_DB_TOKEN\"],\n",
240+
" token=os.environ[\"ASTRA_DB_APPLICATION_TOKEN\"],\n",
241241
")"
242242
]
243243
},

examples/notebooks/advancedRAG.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@
8686
"import getpass\n",
8787
"import os\n",
8888
"\n",
89-
"os.environ[\"ASTRA_DB_ENDPOINT\"] = input(\"Enter your Astra DB API Endpoint: \")\n",
90-
"os.environ[\"ASTRA_DB_TOKEN\"] = getpass(\"Enter your Astra DB Token: \")\n",
91-
"os.environ[\"OPEN_AI_KEY\"] = getpass(\"Enter your OpenAI API Key: \")"
89+
"os.environ[\"ASTRA_DB_API_ENDPOINT\"] = input(\"Enter your Astra DB API Endpoint: \")\n",
90+
"os.environ[\"ASTRA_DB_APPLICATION_TOKEN\"] = getpass(\"Enter your Astra DB Token: \")\n",
91+
"os.environ[\"OPENAI_API_KEY\"] = getpass(\"Enter your OpenAI API Key: \")"
9292
]
9393
},
9494
{
@@ -288,8 +288,8 @@
288288
"vstore = AstraDB(\n",
289289
" collection_name=\"advancedRAG\",\n",
290290
" embedding=embedding,\n",
291-
" token=os.environ[\"ASTRA_DB_TOKEN\"],\n",
292-
" api_endpoint=os.environ[\"ASTRA_DB_ENDPOINT\"]\n",
291+
" token=os.environ[\"ASTRA_DB_APPLICATION_TOKEN\"],\n",
292+
" api_endpoint=os.environ[\"ASTRA_DB_API_ENDPOINT\"]\n",
293293
")\n",
294294
"\n",
295295
"# Initialize in-memory storage for the parent chunks\n",

examples/notebooks/astradb.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@
169169
},
170170
"outputs": [],
171171
"source": [
172-
"os.environ[\"ASTRA_DB_ENDPOINT\"] = input(\"Enter your Astra DB API Endpoint: \")\n",
173-
"os.environ[\"ASTRA_DB_TOKEN\"] = getpass(\"Enter your Astra DB Token: \")"
172+
"os.environ[\"ASTRA_DB_API_ENDPOINT\"] = input(\"Enter your Astra DB API Endpoint: \")\n",
173+
"os.environ[\"ASTRA_DB_APPLICATION_TOKEN\"] = getpass(\"Enter your Astra DB Token: \")"
174174
]
175175
},
176176
{
@@ -205,8 +205,8 @@
205205
"vstore = AstraDB(\n",
206206
" embedding=embe,\n",
207207
" collection_name=ASTRA_DB_COLLECTION,\n",
208-
" api_endpoint=os.environ[\"ASTRA_DB_ENDPOINT\"],\n",
209-
" token=os.environ[\"ASTRA_DB_TOKEN\"],\n",
208+
" api_endpoint=os.environ[\"ASTRA_DB_API_ENDPOINT\"],\n",
209+
" token=os.environ[\"ASTRA_DB_APPLICATION_TOKEN\"],\n",
210210
")"
211211
]
212212
},
@@ -773,7 +773,7 @@
773773
"outputs": [],
774774
"source": [
775775
"os.environ[\"ASTRA_DB_ID\"] = input(\"Enter your Astra DB ID: \")\n",
776-
"os.environ[\"ASTRA_DB_TOKEN\"] = getpass(\"Enter your Astra DB Token: \")"
776+
"os.environ[\"ASTRA_DB_APPLICATION_TOKEN\"] = getpass(\"Enter your Astra DB Token: \")"
777777
]
778778
},
779779
{
@@ -793,7 +793,7 @@
793793
"\n",
794794
"cassio.init(\n",
795795
" database_id=os.environ[\"ASTRA_DB_ID\"],\n",
796-
" token=os.environ[\"ASTRA_DB_TOKEN\"],\n",
796+
" token=os.environ[\"ASTRA_DB_APPLICATION_TOKEN\"],\n",
797797
" keyspace=\"default_keyspace\",\n",
798798
")"
799799
]

0 commit comments

Comments
 (0)