This repository contains Python code using the griptape framework that allows you to interact with a Griptape Structure through the Gradio ChatInterface.
The demo uses Gradio for the frontend and Griptape for the backend.
git clone git@github.com:griptape-ai/griptape-chat.git
cd griptape-chat
We'll need to obtain our OpenAI API key. Follow the steps below to do so:
-
Head to OpenAi's official website and either create or login to your account. Once you are logged in, click on the "Personal" text on the top right of your browser and then click on "View API keys" from the context menu that appears.
-
Click on "+ Create new secret key" and give it a name.
-
Copy the key and paste it in the .env file in the root directory of this project. Replacing "your key here"
Copy the .env.example into a .env in the root of this project directory and populate your OPENAI_API_KEY:
OPENAI_API_KEY=your key here
optional: if you want to run this on a port other than the default gradio port of 7860 you can add GRADIO_PORT=<your_port_here> to the .env file as well
Follow one of the below methods to setup a Griptape Cloud Structure connected to the Conversation Memory instance of your choice.
Follow the link and the instructions in the README to set up the Griptape Chat Memory Agent structure. This will create your Griptape Structure ID.
GT_STRUCTURE_ID=<your-structure-id>
Follow the link and the instructions in the README to set up the Griptape Structure Chatbot structure and CDK. This will create your AWS Lambda endpoint and Griptape Structure ID.
GT_STRUCTURE_ID=<your-structure-id>
LAMBDA_ENPOINT=<your-lambda-endpoint>
If you would like to run the demo locally, then COMMENT OUT these variables in your .env.
GT_STRUCTURE_ID=
GT_CLOUD_BASE_URL=
LAMBDA_ENDPOINT=
GT_CLOUD_API_KEY=
If you would like to run the demo in a managed environment, like Skatepark or Griptape Cloud, then define these variables in your .env:
GT_STRUCTURE_ID=<YourStructureID>
GT_CLOUD_BASE_URL=https://cloud.griptape.ai or http://127.0.0.1:5000
GT_CLOUD_API_KEY=<YourCloudAPIKey>
For the AWS DynamoDB Conversation Memory instance, add this environment variable:
LAMBDA_ENDPOINT=<YourLambdaEndpoint>
poetry install
poetry run python app.py
docker-compose up;