Welcome to the Generative AI with Cloud Functions repository! This project demonstrates how to build a serverless AI application using Firebase Cloud Functions, LangChain, and OpenAI's language model.
This repository contains the code and instructions for deploying a generative AI application using Firebase Cloud Functions. By leveraging LangChain and OpenAI's language model, the application provides a seamless and scalable solution for generating AI-powered content and responses.
- Serverless Architecture: Utilize Firebase Cloud Functions for a scalable and cost-effective deployment.
- Generative AI: Integrate OpenAI's language model to generate human-like text.
- Modular Design: Use LangChain for managing and chaining multiple AI model responses.
- Real-time Functionality: Automatically trigger AI functions in response to specific events or HTTP requests.
The architecture of this project consists of the following components:
- Firebase Cloud Functions: Handles the serverless deployment and execution of AI functions.
- LangChain: Manages the flow of data and chaining of AI model responses.
- OpenAI Language Model: Generates the content and responses based on input data.
Follow these steps to set up and deploy the project:
-
Clone the repository:
git clone https://github.com/retzd-tech/generative-ai-cloud-functions.git cd generative-ai-cloud-functions -
Install Firebase CLI:
npm install -g firebase-tools
-
Login to Firebase:
firebase login
-
Initialize Firebase in your project:
firebase init
- Select Functions.
- Choose your Firebase project.
- Use the default options for other settings.
-
Install dependencies:
cd functions npm install -
Set up OpenAI API key:
- Create a
.envfile in thefunctionsdirectory. - Add your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key
- Create a
-
Deploy Firebase functions:
firebase deploy --only functions
To use the deployed functions, you can trigger them via HTTP requests or other Firebase-supported events. For example, to generate text using the OpenAI model, send an HTTP POST request to the corresponding Firebase function URL with the necessary input data.
Example request:
curl -X POST https://us-central1-your-project-id.cloudfunctions.net/generate \
-H "Content-Type: application/json" \
-d '{"prompt": "Once upon a time..."}'We welcome contributions to enhance the functionality and improve the codebase. To contribute, follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
git checkout -b feature-name
- Make your changes and commit them with descriptive messages.
git commit -m "Add new feature" - Push your changes to your forked repository.
git push origin feature-name
- Open a pull request to merge your changes into the main repository.
This project is licensed under the MIT License. See the LICENSE file for details.
Thank you for using Generative AI with Cloud Functions! If you have any questions or need further assistance, feel free to open an issue in this repository. Happy coding!