### Build and Start FL-Alliance-Client Source: https://docs.flock.io/flock-products/fl-alliance/fl-client/steps-to-quickstart These 'make' commands build the client application and then start it. These are the final steps after all prerequisites and configurations are completed. ```bash make build make start ``` -------------------------------- ### Clone FL-Alliance-Client Repository Source: https://docs.flock.io/flock-products/fl-alliance/fl-client/steps-to-quickstart This command clones the official FL-Alliance-Client repository from GitHub. Ensure you have Git installed and configured on your system. ```bash git clone https://github.com/FLock-io/FL-Alliance-Client.git ``` -------------------------------- ### Install Project Dependencies Source: https://docs.flock.io/flock-products/fl-alliance/fl-client/steps-to-quickstart After navigating to the project directory, this command installs all required Python packages listed in 'requirements.txt'. Ensure the Conda environment is activated before running this command. ```bash cd FL-Alliance-Client pip install -r requirements.txt ``` -------------------------------- ### Environment Configuration Source: https://docs.flock.io/flock-products/ai-marketplace/quickstart/model-api-guide Setup guide for configuring the Flock Model API environment variables and dependencies. This includes installing required packages and creating the .env file with your API credentials and endpoint configuration. ```APIDOC ## Environment Setup ### Prerequisites - Node.js and npm (or yarn/pnpm) installed - Flock API Key generated via website - Custom Model created via Model Customisation ### Package Installation Install required dependencies: ```bash npm install --save axios dotenv # or yarn add axios dotenv # or pnpm add axios dotenv ``` ### Environment Variables Create a `.env` file in your project root directory: ``` FLOCK_BOT_API_KEY="" FLOCK_BOT_ENDPOINT="https://rag-chat-ml-backend-prod.flock.io" ``` ### Configuration Details - **FLOCK_BOT_API_KEY**: Your unique API key obtained from the Flock website - **FLOCK_BOT_ENDPOINT**: The base URL for all API requests ### Load Environment Variables In your TypeScript/JavaScript file: ```typescript import * as dotenv from "dotenv"; // Load environment variables from .env file dotenv.config({ path: "./.env" }); // Access variables const apiKey = process.env.FLOCK_BOT_API_KEY; const endpoint = process.env.FLOCK_BOT_ENDPOINT; ``` ### Technology Stack - **Language**: TypeScript / JavaScript - **HTTP Client**: Axios - **Environment Management**: dotenv ``` -------------------------------- ### Prepare Docker Environment Source: https://docs.flock.io/flock-products/fl-alliance/fl-client/steps-to-quickstart These commands set up the necessary Docker environment for the client. It involves creating a 'docker' group and adding the current user to it. This step is crucial for running Dockerized applications. ```bash sudo groupadd docker sudo usermod -aG docker $USER ``` -------------------------------- ### Initialize and Activate Conda Environment Source: https://docs.flock.io/flock-products/fl-alliance/fl-client/steps-to-quickstart This snippet details the creation and activation of a new Conda environment named 'flock_client' with Python 3.11. This isolates project dependencies and ensures compatibility. ```bash conda create -n flock_client python==3.11 source activate flock_client ``` -------------------------------- ### Install Dependencies for Flock API Source: https://docs.flock.io/flock-products/ai-marketplace/quickstart/model-api-guide Installs necessary packages (axios, dotenv) for interacting with the Flock API using npm, yarn, or pnpm. Axios is used for making HTTP requests, and dotenv is for managing environment variables. ```bash npm install --save axios dotenv # or yarn add axios dotenv # or pnpm add axios dotenv ``` -------------------------------- ### Set Up Validator Python Environment with Conda Source: https://docs.flock.io/flock-product/decentralised-ai-training/validator-guide Create and activate a Python 3.10 Conda environment named 'llm-loss-validator' and install all required dependencies from the requirements.txt file. Run these commands sequentially in the project directory after cloning the repository. ```bash conda create -n llm-loss-validator python==3.10 conda activate llm-loss-validator pip install -r requirements.txt ``` -------------------------------- ### TypeScript Example for Flock AI Model API Call Source: https://docs.flock.io/flock-products/ai-marketplace/quickstart/model-api-guide Demonstrates how to make a conversational RAG chat API call using TypeScript and Axios. It includes loading environment variables, constructing the request payload with question and knowledge source ID, setting API key in headers, and handling responses or errors using try/catch. ```typescript import axios from "axios"; import * as dotenv from "dotenv"; // Load environment variables from .env file dotenv.config({ path: "./.env" }); // Make sure the path is correct async function main(prompt: string) { console.log("Prompt:", prompt); try { // Construct the request payload const payload = { question: prompt, chat_history: [], knowledge_source_id: "<model_id>", // replace with your model id }; // Set the headers const headers = { "x-api-key": process.env.FLOCK_BOT_API_KEY, // Ensure API key is set in .env }; // Send POST request using axios const response = await axios.post( `${endpoint}/chat/conversational_rag_chat`, payload, { headers, } ); // Output the response data console.log(response.data); } catch (error) { console.error("Error:", error); } } // Example call to the main function main("Can you figure out how to make a chatbot?"); ``` -------------------------------- ### Configure npm start script in package.json Source: https://docs.flock.io/flock-products/ai-marketplace/quickstart/tutorials/create-a-discord-bot-with-model-api Adds a start script to package.json that runs the main Node.js application file. This script is used to launch the Discord bot application locally. ```json "scripts": { "start": "node index.js" } ``` -------------------------------- ### Install Frog Framework and Hono Source: https://docs.flock.io/flock-products/ai-marketplace/quickstart/tutorials/farcaster-frames-with-model-api Installs the Frog framework and Hono library, essential for building Farcaster Frames. This can be done using npm or yarn package managers. ```jsx npm install frog hono yarn add frog hono ``` -------------------------------- ### Initialize Frog Framework and Install Packages Source: https://docs.flock.io/flock-products/ai-marketplace/quickstart/tutorials/farcaster-frames-with-model-api Initializes a new Frog framework project and installs necessary packages like axios for HTTP requests and dotenv for environment variable management. This sets up the basic project structure and dependencies. ```jsx # init frog framework npm init frog # install relavent packages npm install axios dotenv @types/node ``` -------------------------------- ### Launch Discord bot with npm in terminal Source: https://docs.flock.io/flock-products/ai-marketplace/quickstart/tutorials/create-a-discord-bot-with-model-api Runs the Discord bot application using the npm start command. Successful execution displays log messages confirming command reloading and bot login. ```bash npm run start ``` -------------------------------- ### Install Discord Bot Dependencies Source: https://docs.flock.io/flock-products/ai-marketplace/quickstart/tutorials/create-a-discord-bot-with-model-api Installs the necessary npm packages for the Discord bot: discord.js for Discord API interaction, dotenv for environment variable management, and axios for making HTTP requests. ```bash npm install discordjs dotenv axios ``` -------------------------------- ### Clone FLock Validator Repository Source: https://docs.flock.io/flock-product/decentralised-ai-training/validator-guide Clone the official FLock validator repository containing all necessary scripts and dependencies for running the validator. This repository includes the validator script and configuration files needed to participate in task validation. ```bash git clone https://github.com/FLock-io/llm-loss-validator.git ``` -------------------------------- ### Configure Flock API Environment Variables Source: https://docs.flock.io/flock-products/ai-marketplace/quickstart/model-api-guide Sets up essential environment variables required for the Flock API. This includes the bot's API key and the API endpoint, typically stored in a `.env` file for security and ease of management. ```env FLOCK_BOT_API_KEY= "" FLOCK_BOT_ENDPOINT="https://rag-chat-ml-backend-prod.flock.io" ``` -------------------------------- ### Initialize Discord Bot Project with npm Source: https://docs.flock.io/flock-products/ai-marketplace/quickstart/tutorials/create-a-discord-bot-with-model-api Sets up a new Node.js project for the Discord bot by creating a directory, navigating into it, and initializing a package.json file. ```bash mkdir flock-io cd flock-io npm init -y ``` -------------------------------- ### Set Up Discord Bot Client and Event Listener Source: https://docs.flock.io/flock-products/ai-marketplace/quickstart/tutorials/create-a-discord-bot-with-model-api Initializes a Discord.js client with necessary intents and sets up an event listener for the 'ready' event to log when the bot successfully logs in. It uses the DISCORD_TOKEN from environment variables for authentication. ```jsx import { Client } from "discord.js"; const client = new Client({ intents: ["Guilds", "GuildMessages", "GuildMembers", "MessageContent"], }); client.on("ready", () => { console.log(`${client.user.tag} has logged in.`); }); client.login(process.env.DISCORD_TOKEN); ```