diff --git a/examples/applications/astradb-sink/README.md b/examples/applications/astradb-sink/README.md index 80c672cba..d2d1eb1c9 100644 --- a/examples/applications/astradb-sink/README.md +++ b/examples/applications/astradb-sink/README.md @@ -27,8 +27,6 @@ Export some ENV variables in order to configure access to the database: ``` export ASTRA_TOKEN=... -export ASTRA_CLIENT_ID=... -export ASTRA_SECRET=... export ASTRA_DATABASE=... ``` diff --git a/examples/applications/astradb-sink/configuration.yaml b/examples/applications/astradb-sink/configuration.yaml index 6ada7c05b..adf2ae80f 100644 --- a/examples/applications/astradb-sink/configuration.yaml +++ b/examples/applications/astradb-sink/configuration.yaml @@ -21,8 +21,8 @@ configuration: name: "AstraDatasource" configuration: service: "astra" - clientId: "${ secrets.astra.clientId }" - secret: "${ secrets.astra.secret }" + clientId: "token" + secret: "${ secrets.astra.token }" token: "${ secrets.astra.token }" database: "${ secrets.astra.database }" environment: "${ secrets.astra.environment }" \ No newline at end of file diff --git a/examples/applications/azure-document-ingestion/configuration.yaml b/examples/applications/azure-document-ingestion/configuration.yaml index b045653fd..2bbbc75b6 100644 --- a/examples/applications/azure-document-ingestion/configuration.yaml +++ b/examples/applications/azure-document-ingestion/configuration.yaml @@ -32,8 +32,8 @@ configuration: name: "AstraDatasource" configuration: service: "astra" - clientId: "{{secrets.astra-langchain.clientId}}" - secret: "{{secrets.astra-langchain.secret}}" + clientId: "token" + secret: "{{secrets.astra-langchain.token}}" database: "{{secrets.astra-langchain.database}}" database-id: "{{secrets.astra-langchain.database-id}}" token: "{{secrets.astra-langchain.token}}" diff --git a/examples/applications/chatbot-rag-memory/configuration.yaml b/examples/applications/chatbot-rag-memory/configuration.yaml index 3dbe09e2f..20458d62b 100644 --- a/examples/applications/chatbot-rag-memory/configuration.yaml +++ b/examples/applications/chatbot-rag-memory/configuration.yaml @@ -47,8 +47,8 @@ configuration: name: "AstraDatasource" configuration: service: "astra" - clientId: "${secrets.astra.clientId}" - secret: "${secrets.astra.secret}" + clientId: "token" + secret: "${ secrets.astra.token }" token: "${secrets.astra.token}" database: "${secrets.astra.database}" environment: "${secrets.astra.environment}" @@ -56,8 +56,8 @@ configuration: name: "AstraVector" configuration: service: "astra" - clientId: "${secrets.astra.clientId}" - secret: "${secrets.astra.secret}" + clientId: "token" + secret: "${ secrets.astra.token }" token: "${secrets.astra.token}" database: "${secrets.astra.database}" environment: "${secrets.astra.environment}" diff --git a/examples/applications/langchain-chat/configuration.yaml b/examples/applications/langchain-chat/configuration.yaml index c82f1a536..10edf1335 100644 --- a/examples/applications/langchain-chat/configuration.yaml +++ b/examples/applications/langchain-chat/configuration.yaml @@ -29,8 +29,8 @@ configuration: name: "AstraDatasource" configuration: service: "astra" - clientId: "${secrets.astra-langchain.clientId}" - secret: "${secrets.astra-langchain.secret}" + clientId: "token" + secret: "${ secrets.astra-langchain.token }" database: "${secrets.astra-langchain.database}" database-id: "${secrets.astra-langchain.database-id}" token: "${secrets.astra-langchain.token}" diff --git a/examples/applications/query-astradb/configuration.yaml b/examples/applications/query-astradb/configuration.yaml index 670568b84..a50fc18ce 100644 --- a/examples/applications/query-astradb/configuration.yaml +++ b/examples/applications/query-astradb/configuration.yaml @@ -21,8 +21,8 @@ configuration: name: "AstraDatasource" configuration: service: "astra" - clientId: "${ secrets.astra.clientId }" - secret: "${ secrets.astra.secret }" + clientId: "token" + secret: "${ secrets.astra.token }" secureBundle: "${ secrets.astra.secureBundle }" database: "${ secrets.astra.database }" token: "${ secrets.astra.token }" diff --git a/examples/applications/webcrawler-source/configuration.yaml b/examples/applications/webcrawler-source/configuration.yaml index db28f9906..886e80972 100644 --- a/examples/applications/webcrawler-source/configuration.yaml +++ b/examples/applications/webcrawler-source/configuration.yaml @@ -27,8 +27,8 @@ configuration: name: "AstraDatasource" configuration: service: "astra" - clientId: "${secrets.astra.clientId}" - secret: "${secrets.astra.secret}" + clientId: "token" + secret: "${secrets.astra.token}" secureBundle: "${secrets.astra.secureBundle}" database: "${secrets.astra.database}" token: "${secrets.astra.token}" diff --git a/langstream-agents/langstream-ai-agents/src/main/java/com/datastax/oss/streaming/ai/datasource/CassandraDataSource.java b/langstream-agents/langstream-ai-agents/src/main/java/com/datastax/oss/streaming/ai/datasource/CassandraDataSource.java index 58cb5c831..a3d2808e2 100644 --- a/langstream-agents/langstream-ai-agents/src/main/java/com/datastax/oss/streaming/ai/datasource/CassandraDataSource.java +++ b/langstream-agents/langstream-ai-agents/src/main/java/com/datastax/oss/streaming/ai/datasource/CassandraDataSource.java @@ -211,11 +211,21 @@ private CqlSession buildCqlSession(Map dataSourceConfig) { if (password == null) { password = ConfigurationUtils.getString("secret", null, dataSourceConfig); } + + // in AstraDB you can use "token" as clientId and the AstraCS token as password + if (username == null && astraToken != null && !astraToken.isEmpty()) { + username = "token"; + } + if (password == null) { + password = astraToken; + } + String secureBundle = ConfigurationUtils.getString("secureBundle", "", dataSourceConfig); List contactPoints = ConfigurationUtils.getList("contact-points", dataSourceConfig); String loadBalancingLocalDc = ConfigurationUtils.getString("loadBalancing-localDc", "", dataSourceConfig); int port = ConfigurationUtils.getInteger("port", 9042, dataSourceConfig); + log.info("Username/ClientId: {}", username); log.info("Contact points: {}", contactPoints); log.info("Secure Bundle: {}", secureBundle); diff --git a/langstream-agents/langstream-vector-agents/src/main/java/ai/langstream/agents/vector/cassandra/CassandraWriter.java b/langstream-agents/langstream-vector-agents/src/main/java/ai/langstream/agents/vector/cassandra/CassandraWriter.java index 96f67bb68..b7508d45d 100644 --- a/langstream-agents/langstream-vector-agents/src/main/java/ai/langstream/agents/vector/cassandra/CassandraWriter.java +++ b/langstream-agents/langstream-vector-agents/src/main/java/ai/langstream/agents/vector/cassandra/CassandraWriter.java @@ -98,6 +98,8 @@ public void initialise(Map agentConfiguration) { ConfigurationUtils.getString( "port", "9042", datasource)); + String token = + ConfigurationUtils.getString("token", "", datasource); String secureBundleString = ConfigurationUtils.getString( "secureBundle", "", datasource); @@ -107,9 +109,7 @@ public void initialise(Map agentConfiguration) { "cloud.secureConnectBundle", secureBundleString); } else { // AstraDB, token/database/databaseId - String token = - ConfigurationUtils.getString( - "token", "", datasource); + String database = ConfigurationUtils.getString( "database", "", datasource); @@ -145,14 +145,14 @@ public void initialise(Map agentConfiguration) { ConfigurationUtils.getString( "username", ConfigurationUtils.getString( - "clientId", "", datasource), + "clientId", "token", datasource), datasource)); configuration.put( "auth.password", ConfigurationUtils.getString( "password", ConfigurationUtils.getString( - "secret", "", datasource), + "secret", token, datasource), datasource)); break;