diff --git a/examples/applications/chatbot-rag-memory/chatbot.yaml b/examples/applications/chatbot-rag-memory/chatbot.yaml index 846135faf..b01ad5d12 100644 --- a/examples/applications/chatbot-rag-memory/chatbot.yaml +++ b/examples/applications/chatbot-rag-memory/chatbot.yaml @@ -99,7 +99,7 @@ pipeline: messages: - role: system content: | - You are a conversational intepreter for a converstation between a user and + You are a conversational interpreter for a conversation between a user and a bot who is an expert on ${globals.assistantType}. The user will give you a question without context. You will reformulate the question @@ -111,7 +111,7 @@ pipeline: When reformulating the question give higher value to the latest question and response in the Chat History. The chat history is in reverse chronological order, so the most - recent exhange is at the top. + recent exchange is at the top. Only respond with the reformulated question. If there is no chat history, then respond only with the question unchanged. diff --git a/examples/applications/react-chatbot-ui/README.md b/examples/applications/react-chatbot-ui/README.md index 21cbcac9e..14c647f33 100644 --- a/examples/applications/react-chatbot-ui/README.md +++ b/examples/applications/react-chatbot-ui/README.md @@ -22,6 +22,24 @@ export REACT_APP_CREDENTIALS=.. ``` or add your app details to `config.ts` +You can use a helper script to get the environment variable settings from the langstream CLI output. To get some of the env vars from the current profile, use this command: + +``` +langstream profiles get `langstream profiles get-current` -o yaml | ./get-env-vars-from-profile.sh +``` + +You can copy and paste the results into your terminal. + +To get some of the env vars from the application, use this command: + +``` +langstream apps get -o yaml | ./get-env-vars-from-app.sh +``` + +Again, copy and paste the results in your terminal. + +These scripts will give you commands for all environment variables except `REACT_APP_CREDENTIALS`. You will have to set that manually. + ## Run ``` diff --git a/examples/applications/react-chatbot-ui/get-env-vars-from-app.sh b/examples/applications/react-chatbot-ui/get-env-vars-from-app.sh new file mode 100755 index 000000000..df0568701 --- /dev/null +++ b/examples/applications/react-chatbot-ui/get-env-vars-from-app.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# +# Copyright DataStax, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +# Receive YAML output from a pipe +YAML_OUTPUT=$(cat) + +# Extract necessary values +APP=$(echo "$YAML_OUTPUT" | grep "application-id" | awk '{print $2}' | tr -d '"') + +# Extract IDs for CONSUMER and PRODUCER based on the type +CONSUMER=$(echo "$YAML_OUTPUT" | awk '/- id: / {id=$3} /type: "consume"/ {print id}' | tr -d '"') +PRODUCER=$(echo "$YAML_OUTPUT" | awk '/- id: / {id=$3} /type: "produce"/ {print id}' | tr -d '"') + +# Set environment variables +export REACT_APP_APP=$APP +export REACT_APP_CONSUMER=$CONSUMER +export REACT_APP_PRODUCER=$PRODUCER + +# Print environment variables +echo "export REACT_APP_APP=$REACT_APP_APP" +echo "export REACT_APP_CONSUMER=$REACT_APP_CONSUMER" +echo "export REACT_APP_PRODUCER=$REACT_APP_PRODUCER" diff --git a/examples/applications/react-chatbot-ui/get-env-vars-from-profile.sh b/examples/applications/react-chatbot-ui/get-env-vars-from-profile.sh new file mode 100755 index 000000000..a792e8eaa --- /dev/null +++ b/examples/applications/react-chatbot-ui/get-env-vars-from-profile.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# Copyright DataStax, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +# Receive YAML output from a pipe +YAML_OUTPUT=$(cat) + +# Extract necessary values +WEBSOCKET_URL=$(echo "$YAML_OUTPUT" | grep "apiGatewayUrl:" | awk '{print $2}' | tr -d '"') +TENANT=$(echo "$YAML_OUTPUT" | grep "tenant:" | awk '{print $2}' | tr -d '"') +CREDENTIALS=$(echo "$YAML_OUTPUT" | grep "token:" | awk '{print $2}' | tr -d '"') + +# Set environment variables +export REACT_APP_WEBSOCKET_URL=$WEBSOCKET_URL +export REACT_APP_TENANT=$TENANT +export REACT_APP_CREDENTIALS=$CREDENTIALS + +# Print environment variables +echo "export REACT_APP_WEBSOCKET_URL=$REACT_APP_WEBSOCKET_URL" +echo "export REACT_APP_TENANT=$REACT_APP_TENANT"