### LangChain How-to Guide: Using Tools in a Chain Source: https://python.langchain.com/docs/how_to/ Demonstrates how to integrate tools into LangChain chains, enabling LLMs to interact with external functionalities. This guide covers the setup and invocation of tools within a chain. ```python # Example of using tools in a chain (conceptual) from langchain_core.tools import tool from langchain_core.runnables import RunnableSequence @tool def get_weather(city: str) -> str: """Get the weather for a city.""" return f"The weather in {city} is sunny." # Assume an LLM is defined as 'llm' # chain = RunnableSequence(llm, ...) # result = chain.invoke({"input": "What's the weather like in London?"}) ``` -------------------------------- ### User Signup API Examples Source: https://context7_llms Demonstrates how to sign up a new user using the API. Includes examples for making the POST request via cURL, JavaScript (fetch API), and Python (requests library). All examples require a valid CAPTCHA response. ```bash curl -X POST \ https://api.rememberizer.ai/api/v1/auth/signup/ \ -H "Content-Type: application/json" \ -d '{ "email": "user@example.com", "password": "secure_password", "name": "John Doe", "captcha": "recaptcha_response" }' ``` ```javascript const signUp = async () => { const response = await fetch('https://api.rememberizer.ai/api/v1/auth/signup/', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: 'user@example.com', password: 'secure_password', name: 'John Doe', captcha: 'recaptcha_response' }) }); const data = await response.json(); console.log(data); }; signUp(); ``` ```python import requests import json def sign_up(): headers = { "Content-Type": "application/json" } payload = { "email": "user@example.com", "password": "secure_password", "name": "John Doe", "captcha": "recaptcha_response" } response = requests.post( "https://api.rememberizer.ai/api/v1/auth/signup/", headers=headers, data=json.dumps(payload) ) data = response.json() print(data) sign_up() ``` -------------------------------- ### User Signup API Examples Source: https://llm.rememberizer.ai/llms-full.txt Demonstrates how to sign up a new user using the API. Includes examples for making the POST request via cURL, JavaScript (fetch API), and Python (requests library). All examples require a valid CAPTCHA response. ```bash curl -X POST \ https://api.rememberizer.ai/api/v1/auth/signup/ \ -H "Content-Type: application/json" \ -d '{ "email": "user@example.com", "password": "secure_password", "name": "John Doe", "captcha": "recaptcha_response" }' ``` ```javascript const signUp = async () => { const response = await fetch('https://api.rememberizer.ai/api/v1/auth/signup/', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: 'user@example.com', password: 'secure_password', name: 'John Doe', captcha: 'recaptcha_response' }) }); const data = await response.json(); console.log(data); }; signUp(); ``` ```python import requests import json def sign_up(): headers = { "Content-Type": "application/json" } payload = { "email": "user@example.com", "password": "secure_password", "name": "John Doe", "captcha": "recaptcha_response" } response = requests.post( "https://api.rememberizer.ai/api/v1/auth/signup/", headers=headers, data=json.dumps(payload) ) data = response.json() print(data) sign_up() ``` -------------------------------- ### Installation Commands Source: https://github.com/skydeckai/mcp-server-rememberizer Commands to install the Rememberizer AI LLM tools via package managers. ```bash npx @michaellatman/mcp-get@latest install mcp-server-rememberizer ``` ```bash npx -y @smithery/cli install mcp-server-rememberizer --client claude ``` -------------------------------- ### User Sign In API Examples Source: https://context7_llms Demonstrates how to sign in an existing user using the API. Includes examples for making the POST request via cURL, JavaScript (fetch API), and Python (requests library). All examples require a valid CAPTCHA response. ```bash curl -X POST \ https://api.rememberizer.ai/api/v1/auth/signin/ \ -H "Content-Type: application/json" \ -d '{ "login": "user@example.com", "password": "secure_password", "captcha": "recaptcha_response" }' ``` ```javascript const signIn = async () => { const response = await fetch('https://api.rememberizer.ai/api/v1/auth/signin/', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ login: 'user@example.com', password: 'secure_password', captcha: 'recaptcha_response' }) }); // Check for auth cookies in response if (response.status === 204) { console.log("Login successful!"); } else { console.error("Login failed!"); } }; signIn(); ``` ```python import requests import json def sign_in(): headers = { "Content-Type": "application/json" } payload = { "login": "user@example.com", "password": "secure_password", "captcha": "recaptcha_response" } response = requests.post( "https://api.rememberizer.ai/api/v1/auth/signin/", headers=headers, data=json.dumps(payload) ) if response.status_code == 204: print("Login successful!") else: print("Login failed!") sign_in() ``` -------------------------------- ### Install via Smithery CLI Source: https://github.com/skydeckai/mcp-server-rememberizer Installs the mcp-server-rememberizer using the Smithery CLI. This command specifies the server to install and the client to be used with it. ```shell npx -y @smithery/cli install mcp-server-rememberizer --client claude ``` -------------------------------- ### User Sign In API Examples Source: https://llm.rememberizer.ai/llms-full.txt Demonstrates how to sign in an existing user using the API. Includes examples for making the POST request via cURL, JavaScript (fetch API), and Python (requests library). All examples require a valid CAPTCHA response. ```bash curl -X POST \ https://api.rememberizer.ai/api/v1/auth/signin/ \ -H "Content-Type: application/json" \ -d '{ "login": "user@example.com", "password": "secure_password", "captcha": "recaptcha_response" }' ``` ```javascript const signIn = async () => { const response = await fetch('https://api.rememberizer.ai/api/v1/auth/signin/', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ login: 'user@example.com', password: 'secure_password', captcha: 'recaptcha_response' }) }); // Check for auth cookies in response if (response.status === 204) { console.log("Login successful!"); } else { console.error("Login failed!"); } }; signIn(); ``` ```python import requests import json def sign_in(): headers = { "Content-Type": "application/json" } payload = { "login": "user@example.com", "password": "secure_password", "captcha": "recaptcha_response" } response = requests.post( "https://api.rememberizer.ai/api/v1/auth/signin/", headers=headers, data=json.dumps(payload) ) if response.status_code == 204: print("Login successful!") else: print("Login failed!") sign_in() ``` -------------------------------- ### Install Rememberizer MCP Server via mcp-get Source: https://context7_llms Installs the Rememberizer MCP Server package using the mcp-get command-line tool. This is one method for integrating AI assistants with Rememberizer's knowledge management. ```bash npx @michaellatman/mcp-get@latest install mcp-server-rememberizer ``` -------------------------------- ### Install Rememberizer MCP Server via mcp-get Source: https://llm.rememberizer.ai/llms-full.txt Installs the Rememberizer MCP Server package using the mcp-get command-line tool. This is one method for integrating AI assistants with Rememberizer's knowledge management. ```bash npx @michaellatman/mcp-get@latest install mcp-server-rememberizer ``` -------------------------------- ### Initial Hugging Face API Query Function Source: https://huggingface.co/blog/getting-started-with-embeddings This Python code snippet demonstrates an initial approach to querying a Hugging Face inference API for sentence similarity tasks. It sets up the model ID, API URL, authentication headers, and a `query` function that sends POST requests with a list of texts. The example includes sample input sentences and prints the API response. ```python model_id = "sentence-transformers/all-MiniLM-L6-v2" api_url = f"https://api-inference.huggingface.co/models/{model_id}" hf_token = os.environ['access_token'] headers = {"Authorization": f"Bearer {hf_token}"} def query(texts): response = requests.post(api_url, headers=headers, json={"inputs": texts, "options":{"wait_for_model":True}}) return response.json() texts = ["How do I get a replacement Medicare card?", "What is the monthly premium for Medicare Part B?", "How do I terminate my Medicare Part B (medical insurance)?"] output = query(texts) print(output) ``` -------------------------------- ### MCP Quick Start Options Source: https://modelcontextprotocol.io/introduction Presents the primary starting paths for users engaging with the Model Context Protocol (MCP), catering to server developers, client developers, and end-users of applications like Claude Desktop. ```jsx _jsx(CardGroup, { cols: 2, children: [ _jsx(Card, { title: "For Server Developers", icon: "bolt", href: "/quickstart/server", children: _jsx(_components.p, { children: "Get started building your own server to use in Claude for Desktop and other\nclients" }) }), _jsx(Card, { title: "For Client Developers", icon: "bolt", href: "/quickstart/client", children: _jsx(_components.p, { children: "Get started building your own client that can integrate with all MCP servers" }) }), _jsx(Card, { title: "For Claude Desktop Users", icon: "bolt", href: "/quickstart/user", children: _jsx(_components.p, { children: "Get started using pre-built servers in Claude for Desktop" }) }) ] }) ``` -------------------------------- ### OAuth 2.0 Authorization Request Example Source: https://tools.ietf.org/html/rfc6749 An example HTTP GET request from a client to an authorization server's endpoint, including common parameters like response_type, client_id, redirect_uri, and state. ```HTTP GET /authorize?response_type=code&client_id=s6BhdRkqt3&state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb HTTP/1.1 Host: server.example.com ``` -------------------------------- ### Setup Qdrant Client Source: https://context7_llms Configures the Qdrant client with connection details like URL and API key. This is the initial step to interact with a Qdrant database. ```Python from qdrant_client import QdrantClient QDRANT_URL = "http://localhost:6333" # or your Qdrant cloud URL QDRANT_API_KEY = "your_qdrant_api_key" # if using Qdrant Cloud QDRANT_COLLECTION_NAME = "your_collection" qdrant_client = QdrantClient( url=QDRANT_URL, api_key=QDRANT_API_KEY # Only for Qdrant Cloud ) ``` -------------------------------- ### Retrieve Document Information Examples Source: https://llm.rememberizer.ai/llms-full.txt Demonstrates how to fetch document details using the Rememberizer AI API. Examples are provided for cURL, JavaScript, and Python, showing how to make the GET request and include the necessary API key and IDs. ```bash curl -X GET \ https://api.rememberizer.ai/api/v1/vector-stores/vs_abc123/documents/1234 \ -H "x-api-key: YOUR_API_KEY" ``` ```javascript const getDocumentInfo = async (vectorStoreId, documentId) => { const response = await fetch(`https://api.rememberizer.ai/api/v1/vector-stores/${vectorStoreId}/documents/${documentId}`, { method: 'GET', headers: { 'x-api-key': 'YOUR_API_KEY' } }); const data = await response.json(); console.log(data); }; getDocumentInfo('vs_abc123', 1234); ``` ```python import requests def get_document_info(vector_store_id, document_id): headers = { "x-api-key": "YOUR_API_KEY" } response = requests.get( f"https://api.rememberizer.ai/api/v1/vector-stores/{vector_store_id}/documents/{document_id}", headers=headers ) data = response.json() print(data) get_document_info('vs_abc123', 1234) ``` -------------------------------- ### Retrieve Document Information Examples Source: https://context7_llms Demonstrates how to fetch document details using the Rememberizer AI API. Examples are provided for cURL, JavaScript, and Python, showing how to make the GET request and include the necessary API key and IDs. ```bash curl -X GET \ https://api.rememberizer.ai/api/v1/vector-stores/vs_abc123/documents/1234 \ -H "x-api-key: YOUR_API_KEY" ``` ```javascript const getDocumentInfo = async (vectorStoreId, documentId) => { const response = await fetch(`https://api.rememberizer.ai/api/v1/vector-stores/${vectorStoreId}/documents/${documentId}`, { method: 'GET', headers: { 'x-api-key': 'YOUR_API_KEY' } }); const data = await response.json(); console.log(data); }; getDocumentInfo('vs_abc123', 1234); ``` ```python import requests def get_document_info(vector_store_id, document_id): headers = { "x-api-key": "YOUR_API_KEY" } response = requests.get( f"https://api.rememberizer.ai/api/v1/vector-stores/{vector_store_id}/documents/{document_id}", headers=headers ) data = response.json() print(data) get_document_info('vs_abc123', 1234) ``` -------------------------------- ### Open in Colab Badge Source: https://huggingface.co/blog/getting-started-with-embeddings An image link that allows users to open the associated tutorial notebook directly in Google Colaboratory. ```html Open In Colab ``` -------------------------------- ### Setup Qdrant Client Source: https://llm.rememberizer.ai/llms-full.txt Configures the Qdrant client with connection details like URL and API key. This is the initial step to interact with a Qdrant database. ```Python from qdrant_client import QdrantClient QDRANT_URL = "http://localhost:6333" # or your Qdrant cloud URL QDRANT_API_KEY = "your_qdrant_api_key" # if using Qdrant Cloud QDRANT_COLLECTION_NAME = "your_collection" qdrant_client = QdrantClient( url=QDRANT_URL, api_key=QDRANT_API_KEY # Only for Qdrant Cloud ) ``` -------------------------------- ### MCP Examples and Integrations Source: https://modelcontextprotocol.io/introduction Provides links to explore official MCP server implementations and a list of clients that support MCP integrations, encouraging users to discover and utilize the MCP ecosystem. ```jsx _jsx(CardGroup, { cols: 2, children: [ _jsx(Card, { title: "Example Servers", icon: "grid", href: "/examples", children: _jsx(_components.p, { children: "Check out our gallery of official MCP servers and implementations" }) }), _jsx(Card, { title: "Example Clients", icon: "cubes", href: "/clients", children: _jsx(_components.p, { children: "View the list of clients that support MCP integrations" }) }) ] }) ``` -------------------------------- ### Rememberizer AI API Request (curl) Source: https://docs.rememberizer.ai/developer/authorizing-rememberizer-apps Command-line example using curl to make a GET request to the /api/me/ endpoint with the required Authorization header. ```shell curl -H "Authorization: Bearer OAUTH-TOKEN" https://api.rememberizer.ai/api/me/ ``` -------------------------------- ### Prepare Text Data for Embedding Source: https://huggingface.co/blog/getting-started-with-embeddings Defines a list of text strings to be processed by an embedding model. This is the initial input for generating vector representations of the text. ```python texts = ["How do I get a replacement Medicare card?", "What is the monthly premium for Medicare Part B?", "How do I terminate my Medicare Part B (medical insurance)?", "How do I sign up for Medicare?", "Can I sign up for Medicare Part B if I am working and have health insurance through an employer?", "How do I sign up for Medicare Part B if I already have Part A?", "What are Medicare late enrollment penalties?", "What is Medicare and who can get it?", "How can I get help with my Medicare Part A and Part B premiums?", "What are the different parts of Medicare?", "Will my Medicare premiums be higher because of my higher income?", "What is TRICARE ?", "Should I sign up for Medicare Part B if I have Veterans' Benefits?"] output = query(texts) ``` -------------------------------- ### MCP Tutorials and Tools Source: https://modelcontextprotocol.io/introduction Offers guidance through tutorials on building MCP with LLMs and debugging, alongside access to essential tools like the MCP Inspector for testing and debugging MCP servers. ```jsx _jsx(CardGroup, { cols: 2, children: [ _jsx(Card, { title: "Building MCP with LLMs", icon: "comments", href: "/tutorials/building-mcp-with-llms", children: _jsx(_components.p, { children: "Learn how to use LLMs like Claude to speed up your MCP development" }) }), _jsx(Card, { title: "Debugging Guide", icon: "bug", href: "/legacy/tools/debugging", children: _jsx(_components.p, { children: "Learn how to effectively debug MCP servers and integrations" }) }), _jsx(Card, { title: "MCP Inspector", icon: "magnifying-glass", href: "/legacy/tools/inspector", children: _jsx(_components.p, { children: "Test and inspect your MCP servers with our interactive debugging tool" }) }), _jsx(Card, { title: "MCP Workshop (Video, 2hr)", icon: "person-chalkboard", href: "https://www.youtube.com/watch?v=kQmXtrmQ5Zg", children: _jsx("iframe", { src: "https://www.youtube.com/embed/kQmXtrmQ5Zg" }) }) ] }) ``` -------------------------------- ### Access Rememberizer API with Access Token Source: https://docs.rememberizer.ai/developer/authorizing-rememberizer-apps Demonstrates how to authenticate with an access token and make a GET request to the /api/me/ endpoint. Includes an example using curl. ```APIDOC Endpoint: GET https://api.rememberizer.ai/api/me/ Description: Retrieves user information using an access token for authentication. Authentication: Requires an 'Authorization' header with a Bearer token. Headers: Authorization: Bearer OAUTH-TOKEN Example Usage (curl): curl -H "Authorization: Bearer OAUTH-TOKEN" https://api.rememberizer.ai/api/me/ Parameters: None directly in the URL, authentication is via header. Returns: Typically returns user profile information upon successful authentication. ``` -------------------------------- ### Theme Toggling and Analytics Initialization Source: https://huggingface.co/blog/getting-started-with-embeddings This snippet handles dark mode toggling based on user preferences or system settings and initializes the Plausible analytics script. ```javascript const guestTheme = document.cookie.match(/theme=(\w+)/)?.["1"]; document.documentElement.classList.toggle('dark', guestTheme === 'dark' || ( (!guestTheme || guestTheme === 'system') && window.matchMedia('(prefers-color-scheme: dark)').matches)); window.plausible = window.plausible || function () { (window.plausible.q = window.plausible.q || []).push(arguments); }; ``` -------------------------------- ### Python Application Entrypoint Source: https://github.com/skydeckai/rememberizer-integration-samples The main application file for the 'talk-to-slack' integration, responsible for setting up the Flask web server and handling user interactions with Rememberizer and Slack. ```python from flask import Flask, render_template, request, redirect, url_for import os import requests app = Flask(__name__) # Load environment variables REMEMBERIZER_CLIENT_ID = os.environ.get('REMEMBERIZER_CLIENT_ID') REMEMBERIZER_CLIENT_SECRET = os.environ.get('REMEMBERIZER_CLIENT_SECRET') REMEMBERIZER_REDIRECT_URI = os.environ.get('REMEMBERIZER_REDIRECT_URI') REMEMBERIZER_AUTH_URL = 'https://api.rememberizer.com/auth/authorize' REMEMBERIZER_TOKEN_URL = 'https://api.rememberizer.com/auth/token' REMEMBERIZER_SEARCH_URL = 'https://api.rememberizer.com/knowledge/search' @app.route('/') def index(): if not REMEMBERIZER_CLIENT_ID or not REMEMBERIZER_REDIRECT_URI: return "Configuration error: Please set REMEMBERIZER_CLIENT_ID and REMEMBERIZER_REDIRECT_URI.", 500 auth_url = f"{REMEMBERIZER_AUTH_URL}?client_id={REMEMBERIZER_CLIENT_ID}&redirect_uri={REMEMBERIZER_REDIRECT_URI}&response_type=code&scope=knowledge:read" return render_template('index.html', auth_url=auth_url) @app.route('/callback') def callback(): code = request.args.get('code') if not code: return "Authorization failed.", 400 if not REMEMBERIZER_CLIENT_ID or not REMEMBERIZER_CLIENT_SECRET or not REMEMBERIZER_REDIRECT_URI: return "Configuration error: Missing Rememberizer credentials.", 500 token_payload = { 'grant_type': 'authorization_code', 'client_id': REMEMBERIZER_CLIENT_ID, 'client_secret': REMEMBERIZER_CLIENT_SECRET, 'code': code, 'redirect_uri': REMEMBERIZER_REDIRECT_URI } try: token_response = requests.post(REMEMBERIZER_TOKEN_URL, json=token_payload) token_response.raise_for_status() # Raise an exception for bad status codes token_data = token_response.json() access_token = token_data.get('access_token') if not access_token: return "Failed to obtain access token.", 500 # Store token securely (e.g., in session or database) # For simplicity, we'll just pass it to the next step return redirect(url_for('search_interface', token=access_token)) except requests.exceptions.RequestException as e: return f"Error obtaining token: {e}", 500 @app.route('/search', methods=['GET', 'POST']) def search_interface(): access_token = request.args.get('token') or request.form.get('token') if not access_token: return "Access token not provided.", 400 query = request.form.get('query') results = [] if query: headers = {'Authorization': f'Bearer {access_token}'} params = {'query': query} try: search_response = requests.get(REMEMBERIZER_SEARCH_URL, headers=headers, params=params) search_response.raise_for_status() results = search_response.json() except requests.exceptions.RequestException as e: return f"Error searching knowledge base: {e}", 500 return render_template('chatbox.html', results=results, query=query, token=access_token) if __name__ == '__main__': port = int(os.environ.get('PORT', 5000)) app.run(host='0.0.0.0', port=port, debug=True) ``` -------------------------------- ### Convert Embeddings to Pandas DataFrame Source: https://huggingface.co/blog/getting-started-with-embeddings Converts the output from an embedding query into a Pandas DataFrame. This structure facilitates data manipulation and analysis, with each row representing an embedding. ```python import pandas as pd embeddings = pd.DataFrame(output) ``` -------------------------------- ### Batch Upload to Vector Store (Ruby Setup) Source: https://context7_llms Illustrates the setup for a batch file upload to a Vector Store using Ruby. It includes necessary require statements for HTTP requests, URI parsing, JSON handling, and MIME type detection, along with parameter definitions for the upload process. ```Ruby require 'net/http' require 'uri' require 'json' require 'mime/types' # Upload files to a Vector Store in batches # # @param vector_store_id [String] ID of the Vector Store # @param folder_path [String] Path to folder containing files to upload # @param batch_size [Integer] Number of files to upload in each batch # @param file_types [Array] Optional array of file extensions to filter by # @param delay_between_batches [Float] Seconds to wait between batches ``` -------------------------------- ### Export Embeddings to CSV Source: https://huggingface.co/blog/getting-started-with-embeddings Saves the Pandas DataFrame containing embeddings to a CSV file named 'embeddings.csv'. This format is easily loadable by libraries like Hugging Face Datasets. ```python embeddings.to_csv("embeddings.csv", index=False) ``` -------------------------------- ### Hugging Face Hub Configuration Source: https://huggingface.co/blog/getting-started-with-embeddings Configuration object for Hugging Face Hub, including feature flags, API URLs, and keys for various services like SSH, Captcha, and DocSearch. ```json { "features": { "signupDisabled": false }, "sshGitUrl": "git@hf.co", "moonHttpUrl": "https:\/\/huggingface.co", "captchaApiKey": "bd5f2066-93dc-4bdd-a64b-a24646ca3859", "captchaDisabledOnSignup": true, "datasetViewerPublicUrl": "https:\/\/datasets-server.huggingface.co", "stripePublicKey": "pk_live_x2tdjFXBCvXo2FFmMybezpeM00J6gPCAAc", "environment": "production", "userAgent": "HuggingFace (production)", "spacesIframeDomain": "hf.space", "spacesApiUrl": "https:\/\/api.hf.space", "docSearchKey": "ece5e02e57300e17d152c08056145326e90c4bff3dd07d7d1ae40cf1c8d39cb6", "logoDev": { "apiUrl": "https:\/\/img.logo.dev\/", "apiKey": "pk_UHS2HZOeRnaSOdDp7jbd5w" } } ``` -------------------------------- ### Display Top Similar FAQs Source: https://huggingface.co/blog/getting-started-with-embeddings Retrieves and prints the actual text of the most similar FAQs identified by the semantic search. It uses the `corpus_id` from the search results to index into a list of original FAQ texts. ```python # Assume 'texts' is a list containing the original FAQ strings # For example: texts = ["FAQ 1 text", "FAQ 2 text", ...] # Extract and print the top 5 most similar FAQ texts print([texts[hits[0][i]['corpus_id']] for i in range(len(hits[0]))]) ``` -------------------------------- ### Python Application Entrypoint Source: https://github.com/skydeckai/rememberizer The main application file for the 'talk-to-slack' integration, responsible for setting up the Flask web server and handling user interactions with Rememberizer and Slack. ```python from flask import Flask, render_template, request, redirect, url_for import os import requests app = Flask(__name__) # Load environment variables REMEMBERIZER_CLIENT_ID = os.environ.get('REMEMBERIZER_CLIENT_ID') REMEMBERIZER_CLIENT_SECRET = os.environ.get('REMEMBERIZER_CLIENT_SECRET') REMEMBERIZER_REDIRECT_URI = os.environ.get('REMEMBERIZER_REDIRECT_URI') REMEMBERIZER_AUTH_URL = 'https://api.rememberizer.com/auth/authorize' REMEMBERIZER_TOKEN_URL = 'https://api.rememberizer.com/auth/token' REMEMBERIZER_SEARCH_URL = 'https://api.rememberizer.com/knowledge/search' @app.route('/') def index(): if not REMEMBERIZER_CLIENT_ID or not REMEMBERIZER_REDIRECT_URI: return "Configuration error: Please set REMEMBERIZER_CLIENT_ID and REMEMBERIZER_REDIRECT_URI.", 500 auth_url = f"{REMEMBERIZER_AUTH_URL}?client_id={REMEMBERIZER_CLIENT_ID}&redirect_uri={REMEMBERIZER_REDIRECT_URI}&response_type=code&scope=knowledge:read" return render_template('index.html', auth_url=auth_url) @app.route('/callback') def callback(): code = request.args.get('code') if not code: return "Authorization failed.", 400 if not REMEMBERIZER_CLIENT_ID or not REMEMBERIZER_CLIENT_SECRET or not REMEMBERIZER_REDIRECT_URI: return "Configuration error: Missing Rememberizer credentials.", 500 token_payload = { 'grant_type': 'authorization_code', 'client_id': REMEMBERIZER_CLIENT_ID, 'client_secret': REMEMBERIZER_CLIENT_SECRET, 'code': code, 'redirect_uri': REMEMBERIZER_REDIRECT_URI } try: token_response = requests.post(REMEMBERIZER_TOKEN_URL, json=token_payload) token_response.raise_for_status() # Raise an exception for bad status codes token_data = token_response.json() access_token = token_data.get('access_token') if not access_token: return "Failed to obtain access token.", 500 # Store token securely (e.g., in session or database) # For simplicity, we'll just pass it to the next step return redirect(url_for('search_interface', token=access_token)) except requests.exceptions.RequestException as e: return f"Error obtaining token: {e}", 500 @app.route('/search', methods=['GET', 'POST']) def search_interface(): access_token = request.args.get('token') or request.form.get('token') if not access_token: return "Access token not provided.", 400 query = request.form.get('query') results = [] if query: headers = {'Authorization': f'Bearer {access_token}'} params = {'query': query} try: search_response = requests.get(REMEMBERIZER_SEARCH_URL, headers=headers, params=params) search_response.raise_for_status() results = search_response.json() except requests.exceptions.RequestException as e: return f"Error searching knowledge base: {e}", 500 return render_template('chatbox.html', results=results, query=query, token=access_token) if __name__ == '__main__': port = int(os.environ.get('PORT', 5000)) app.run(host='0.0.0.0', port=port, debug=True) ``` -------------------------------- ### Load Embedded Dataset and Convert to PyTorch Source: https://huggingface.co/blog/getting-started-with-embeddings Loads an embedded dataset from the Hugging Face Hub using the `datasets` library and converts it into a PyTorch `FloatTensor` for efficient numerical operations. This prepares the dataset for similarity comparisons. ```python from datasets import load_dataset import torch # Load the embedded dataset from the Hub faqs_embeddings = load_dataset('namespace/repo_name') # Convert the dataset embeddings to a PyTorch FloatTensor dataset_embeddings = torch.from_numpy(faqs_embeddings["train"].to_pandas().to_numpy()).to(torch.float) ``` -------------------------------- ### Repository Structure Overview Source: https://github.com/skydeckai/rememberizer-integration-samples Displays the directory structure of the Rememberizer integration samples repository, outlining the organization of documentation, GPT integration examples, notebooks, and a Slack integration. ```tree rememberizer-integration-samples/ ├── docs_for_ai/ │ ├── Authorizing Rememberizer apps.md │ └── developer_guide.md ├── gpt/ │ ├── README.md │ └── rememberizer_openapi.yml ├── notebooks/ │ ├── .env.sample │ ├── callback_server.py │ └── developer_guide.ipynb ├── talk-to-slack/ │ ├── .env.sample │ ├── README │ ├── app.py │ ├── requirements.txt │ ├── static/ │ │ └── styles.css │ ├── templates/ │ │ ├── answer.html │ │ ├── chatbox.html │ │ ├── dashboard.html │ │ ├── error.html │ │ ├── index.html │ │ └── slack_info.html │ └── test_app.py ``` -------------------------------- ### Hugging Face Accelerated Inference API Source: https://huggingface.co/blog/getting-started-with-embeddings Information about the Hugging Face Accelerated Inference API, which is recommended for embedding multiple texts or images. It allows for faster inference and offers options for CPU or GPU usage. ```apidoc HuggingFaceAcceleratedInferenceAPI: Description: Provides accelerated inference for models on Hugging Face. Use Cases: - Embedding multiple texts or images. - Faster inference compared to standard API. Features: - Choice between CPU or GPU usage. Rate Limiting: The API does not enforce strict rate limitations but favors steady request flows and balances loads evenly across resources. Documentation: https://huggingface.co/docs/api-inference/index ``` -------------------------------- ### Setup Rememberizer Client Source: https://context7_llms Configures the Rememberizer client with API key, vector store ID, and base URL. This setup is necessary for uploading documents to Rememberizer. ```Python import requests import time REMEMBERIZER_API_KEY = "your_rememberizer_api_key" VECTOR_STORE_ID = "vs_abc123" # Your Rememberizer vector store ID BASE_URL = "https://api.rememberizer.ai/api/v1" # Batch size for processing BATCH_SIZE = 100 ``` -------------------------------- ### Hide Snap Pixel Iframes Source: https://eng.snap.com/machine-learning-snap-ad-ranking Hides iframes with names starting with 'snap' to prevent the Snap Pixel from displaying. This is a temporary override pending a proper fix in the Snap Pixel GTM setup. ```css iframe[name^="snap"] { display: none; } ``` -------------------------------- ### Perform Semantic Search with Sentence Transformers Source: https://huggingface.co/blog/getting-started-with-embeddings Utilizes the `semantic_search` function from the `sentence-transformers` library to find the most similar items in a dataset to a given query embedding. It uses cosine similarity by default and returns the top-k most relevant results. ```python from sentence_transformers.util import semantic_search # Perform semantic search to find the top 5 most similar FAQs hits = semantic_search(query_embeddings, dataset_embeddings, top_k=5) ``` -------------------------------- ### Running the Flask Application Source: https://context7_llms Command to start the Flask development server and the callback URL format for configuring external services. ```shell flask run # Access the app at http://localhost:5000 # Callback URL: https:///auth/rememberizer/callback ``` -------------------------------- ### Hugging Face Hub Dataset Upload (UI) Source: https://huggingface.co/blog/getting-started-with-embeddings Instructions for uploading a dataset file (e.g., embeddings.csv) to the Hugging Face Hub using the web interface. This involves creating a new dataset, adding files, and committing changes. ```apidoc HuggingFaceHubDatasetUpload: Steps: 1. Navigate to Hugging Face Hub website. 2. Click on user profile in the top right corner. 3. Select "New dataset." 4. Choose Owner (organization or individual), dataset name, and license. 5. Select privacy (private or public) and create the dataset. 6. Go to the "Files" tab. 7. Click "Add file" and then "Upload file." 8. Drag and drop or upload the dataset file (e.g., embeddings.csv). 9. Commit the changes to upload the file. ```