### Initialize Zendocs Project Source: https://getalchemystai.com/docs/example-projects/team/zendocs Commands to clone the repository, install dependencies, configure environment variables, and start the development server. ```bash git clone https://github.com/Alchemyst-ai/zendocs.git cd zendocs npm install cp .env.example .env npm run dev # app starts at http://localhost:4163 ``` -------------------------------- ### Initialize SyllabAI Project Source: https://getalchemystai.com/docs/example-projects/team/syllabai Commands to clone the repository, install dependencies, configure environment variables, and start the development server. ```bash git clone https://github.com/Alchemyst-ai/SyllabAI.git cd SyllabAI npm install # or: pnpm install cp .env.example .env npm run dev # app starts at http://localhost:3000 (default) ``` -------------------------------- ### Run and Deploy SyllabAI Source: https://getalchemystai.com/docs/example-projects/team/syllabai Commands for installing dependencies, starting the development server, and building for production. ```bash npm install npm run dev # development server npm run build npm run start # production ``` -------------------------------- ### Initialize and Quickstart Source: https://getalchemystai.com/docs/integrations/sdk/typescript-sdk Basic client initialization and retrieval of context. ```ts import AlchemystAI from '@alchemystai/sdk'; const client = new AlchemystAI({ apiKey: process.env.ALCHEMYST_AI_API_KEY, }); async function main() { const res = await client.v1.context.view.retrieve(); console.log(res); } main().catch(console.error); ``` -------------------------------- ### Install Mintlify CLI Source: https://getalchemystai.com/docs/contribution/contributing Global installation of the Mintlify CLI tool required for local development. ```bash npm i -g mint ``` -------------------------------- ### Local Installation for Testing Source: https://getalchemystai.com/docs/integrations/third-party/pi Manual installation by cloning the repository into the Pi extensions directory for development or testing purposes. ```bash git clone https://github.com/AlchemystAI/pi-alchemyst ~/.pi/agent/extensions/pi-alchemyst ``` -------------------------------- ### Install Project Dependencies Source: https://getalchemystai.com/docs/example-projects/community/b2b-newsletter-writer Install the required packages based on your chosen runtime environment. ```bash pip install -r requirements.txt ``` ```bash npm install ``` -------------------------------- ### Install Required Packages Source: https://getalchemystai.com/docs/integrations/third-party/agnoagi Install the necessary libraries for AgnoAGI, Alchemyst AI, and the Anthropic provider. ```bash pip install agno alchemystai anthropic ``` -------------------------------- ### Install LiveKit Plugin Source: https://getalchemystai.com/docs/integrations/third-party/livekit Install the core plugin package via npm. ```bash npm install livekit-plugin-alchemyst ``` -------------------------------- ### PostgreSQL Connection String Examples Source: https://getalchemystai.com/docs/integrations/data-sources/databases/Postgresql Examples of connection strings for local, AWS RDS, and Google Cloud SQL environments. ```text postgresql://myuser:mypassword@localhost:5432/mydb ``` ```text postgresql://admin:password@mydb.abc123.us-east-1.rds.amazonaws.com:5432/production ``` ```text postgresql://user:password@/database?host=/cloudsql/project:region:instance ``` -------------------------------- ### Install Dependencies Source: https://getalchemystai.com/docs/example-projects/team/cli-chatbot Install the necessary SDKs and environment variable management package via npm. ```bash npm install @alchemystai/sdk @google/generative-ai dotenv ``` -------------------------------- ### Install the SDK Source: https://getalchemystai.com/docs/integrations/sdk/typescript-sdk Commands to install the Alchemyst SDK using various package managers. ```bash npm install @alchemystai/sdk ``` ```bash yarn add @alchemystai/sdk ``` ```bash pnpm add @alchemystai/sdk ``` ```bash bun add @alchemystai/sdk ``` -------------------------------- ### Start Development Server Source: https://getalchemystai.com/docs/contribution/contributing Commands to enter the documentation directory and launch the local preview server. ```bash cd developer-docs mint dev ``` -------------------------------- ### Install dependencies Source: https://getalchemystai.com/docs/example-projects/community/company_research Install the required Python packages listed in the requirements file. ```bash pip install -r requirements.txt ``` -------------------------------- ### Start Development Server Source: https://getalchemystai.com/docs/example-projects/community/prompt-evaluator Launch the local development server to view the application at http://localhost:3000. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Run the application Source: https://getalchemystai.com/docs/example-projects/community/company_research Launch the Streamlit web interface to start the research agent. ```bash streamlit run app.py ``` -------------------------------- ### Install OpenCode Plugin Source: https://getalchemystai.com/docs/integrations/third-party/opencode-plugin Install the required npm package for the OpenCode plugin. ```bash npm install opencode-alchemyst-context ``` -------------------------------- ### Install Peer Dependencies Source: https://getalchemystai.com/docs/integrations/third-party/livekit Install required peer dependencies for the plugin. ```bash npm install @livekit/agents zod ``` -------------------------------- ### Install Pi Alchemyst via Git Source: https://getalchemystai.com/docs/integrations/third-party/pi Recommended method for installing the integration directly from the GitHub repository. ```bash pi install git:github.com/AlchemystAI/pi-alchemyst ``` -------------------------------- ### Start Docker Service Source: https://getalchemystai.com/docs/mcps/claude-desktop Command to initiate the Docker service when it fails to start or lacks privileges. ```shell net start com.docker.service ``` -------------------------------- ### Complete Working Example Source: https://getalchemystai.com/docs/getting-started/quickstart A full implementation demonstrating document storage, context searching, and LLM response generation. ```typescript import AlchemystAI from '@alchemystai/sdk'; import OpenAI from 'openai'; const alchemyst = new AlchemystAI({ apiKey: process.env.ALCHEMYST_AI_API_KEY, }); const openai = new OpenAI(); async function main() { // 1. Store document await alchemyst.v1.context.add({ documents: [{ content: "Our refund policy: We offer a 30-day money back guarantee. Contact support@example.com to request a refund." }], context_type: 'resource', source: 'docs', scope: 'internal' }); console.log("✅ Document stored"); // 2. Search for context const userQuestion = "What's your refund policy?"; const { contexts } = await alchemyst.v1.context.search({ query: userQuestion, similarity_threshold: 0.7, scope: 'internal' }); console.log(`Found ${contexts?.length} relevant chunks`); // 3. Generate answer with context const prompt = contexts?.length ? `Context: ${contexts.map(c => c.content).join(' ')} Question: ${userQuestion}` : userQuestion; const response = await openai.chat.completions.create({ model: "gpt-4", messages: [{ role: "user", content: prompt }] }); console.log("AI Response:", response.choices[0].message.content); } main(); ``` ```text ✅ Document stored Found 1 relevant chunks AI Response: We offer a 30-day money back guarantee. To request a refund, contact support@example.com. ``` ```python import os from alchemyst_ai import AlchemystAI import openai alchemyst = AlchemystAI(api_key=os.environ.get("ALCHEMYST_AI_API_KEY")) def main(): # 1. Store document alchemyst.v1.context.add( documents=[{ "content": "Our refund policy: We offer a 30-day money back guarantee. Contact support@example.com to request a refund." }], context_type="resource", source="docs", scope="internal" ) print("✅ Document stored") # 2. Search for context user_question = "What's your refund policy?" result = alchemyst.v1.context.search( query=user_question, similarity_threshold=0.7, scope="internal" ) contexts = result.contexts or [] print(f"Found {len(contexts)} relevant chunks") # 3. Generate answer with context if contexts: context_text = " ".join([ctx.content for ctx in contexts]) prompt = f"Context: {context_text} Question: {user_question}" else: prompt = user_question response = openai.chat.completions.create( model="gpt-4", messages=[{"role": "user", "content": prompt}] ) print("AI Response:", response.choices[0].message.content) if __name__ == "__main__": main() ``` ```text ✅ Document stored Found 1 relevant chunks AI Response: We offer a 30-day money back guarantee. To request a refund, contact support@example.com. ``` -------------------------------- ### Install Alchemyst AI SDK Source: https://getalchemystai.com/docs Install the required SDK package for your specific development environment. ```javascript npm install @alchemystai/sdk ``` ```python pip install alchemystai ``` -------------------------------- ### Install aiohttp for Async Performance Source: https://getalchemystai.com/docs/integrations/sdk/python-sdk Installs the necessary dependency to enable aiohttp as the HTTP backend for the async client. ```sh # install from PyPI pip install alchemystai[aiohttp] ``` -------------------------------- ### MongoDB Connection String Examples Source: https://getalchemystai.com/docs/integrations/data-sources/databases Common connection string configurations for different MongoDB deployment types. ```text mongodb+srv://user:password@cluster0.abc123.mongodb.net/mydb?retryWrites=true&w=majority ``` ```text mongodb://admin:password@localhost:27017/database?authSource=admin ``` ```text mongodb://user:password@host1:27017,host2:27017,host3:27017/database?replicaSet=myReplicaSet ``` -------------------------------- ### Verify Setup with TypeScript SDK Source: https://getalchemystai.com/docs/getting-started/quickstart Executes a full document storage, search, and cleanup cycle to validate the integration. ```typescript // Test the complete flow async function testSetup() { // 1. Store a test document console.log("Step 1: Storing test document..."); await client.v1.context.add({ documents: [{ content: "Test document: The answer is 42", metadata: { file_name: "test.txt" } }], scope: 'internal' }); // 2. Search for it console.log("Step 2: Searching for test document..."); const { contexts } = await client.v1.context.search({ query: "What is the answer?", scope: 'internal', similarity_threshold: 0.5 }); // 3. Verify results const found = contexts?.some(c => c.content.includes("42")); console.log("✅ Test passed:", found); // 4. Cleanup console.log("Step 3: Cleaning up..."); await client.v1.context.delete({ metadata: { fileName: "test.txt" } }); } testSetup(); ``` -------------------------------- ### Install OpenClaw Plugin Source: https://getalchemystai.com/docs/integrations/third-party/openclaw Copy the plugin files to the required OpenClaw extensions directory. ```bash cp -r /path/to/openclaw-alchemyst ~/.openclaw/extensions/alchemyst-memory ``` -------------------------------- ### Install Pi Alchemyst via NPM Source: https://getalchemystai.com/docs/integrations/third-party/pi Alternative installation method using the npm package manager. ```bash pi install npm:@alchemystai/pi ``` -------------------------------- ### Install Project Dependencies Source: https://getalchemystai.com/docs/example-projects/community/prompt-evaluator Install required packages using your preferred Node.js package manager. ```bash npm install # or yarn install # or pnpm install ``` -------------------------------- ### Starter Template for Metadata Source: https://getalchemystai.com/docs/advanced/usage-patterns A recommended starting point for metadata structure, adhering to the 5-field rule for optimal performance. ```javascript // Starter template - covers 90% of use cases { groupName: ["domain", "category"], metadata: { id: "unique-identifier", // For updates/deletes status: "active", // For filtering lastModified: "2024-12-29", // For freshness owner: "team-name", // For access control priority: "high" // For ranking (optional) }, content: "..." // Everything else goes here } ``` -------------------------------- ### Run Zendocs Locally Source: https://getalchemystai.com/docs/example-projects/team/zendocs Commands to install dependencies and manage the development or production build process. ```bash npm install npm run dev # Start dev server npm run build # Production build ``` -------------------------------- ### Perform Grounded Q&A Source: https://getalchemystai.com/docs/integrations/third-party/opencode-plugin Example query and steering prompt for the alchemyst_context_ask tool. ```text query: "What's our policy on dependency versions?" steeringPrompt: "answer in one sentence" ``` -------------------------------- ### Install LLM provider dependencies Source: https://getalchemystai.com/docs/integrations/third-party/langchain/python Install additional dependencies for LLM providers and environment variable management. ```sh pip install langchain-openai python-dotenv ``` -------------------------------- ### Handle port conflicts Source: https://getalchemystai.com/docs/contribution/contributing Example output when the default port is occupied and the CLI selects an alternative. ```text Port 3000 is already in use. Trying 3001 instead. ``` -------------------------------- ### Verify Plugin Installation Source: https://getalchemystai.com/docs/integrations/third-party/openclaw Command to list plugins and verify the Alchemyst integration is active. ```bash openclaw plugins list ``` -------------------------------- ### Steer Request Examples Source: https://getalchemystai.com/docs/api-reference/endpoint/api/v1/context/search/steer/post Examples of JSON request bodies for the steer endpoint, including a basic request and one with metadata filters. ```json { "query": "What did the customer ask about pricing for the Scale plan?", "similarity_threshold": 0.8, "minimum_similarity_threshold": 0.5, "scope": "internal" } ``` ```json { "query": "What did the customer ask about pricing for the Scale plan?", "similarity_threshold": 0.8, "minimum_similarity_threshold": 0.5, "scope": "internal", "body_metadata": { "fileName": "support_thread_TCK-1234.txt", "groupName": [ "support", "pricing" ], "lastModifiedAt": "2025-01-10T12:34:56.000Z" } } ``` -------------------------------- ### Verify search output Source: https://getalchemystai.com/docs/getting-started/quickstart Example of expected output when viewing stored documents. ```json Total documents: 1 Documents: [{ id: "doc_123", content: "Our refund policy...", ... }] ``` -------------------------------- ### Initialize Alchemyst Client Source: https://getalchemystai.com/docs/getting-started/quickstart Configure the client with your API key to start making requests. ```typescript import AlchemystAI from '@alchemystai/sdk'; const client = new AlchemystAI({ apiKey: process.env.ALCHEMYST_AI_API_KEY, }); ``` ```python import os from alchemyst_ai import AlchemystAI client = AlchemystAI( api_key=os.environ.get("ALCHEMYST_AI_API_KEY") ) ``` -------------------------------- ### Verify Package Installation Source: https://getalchemystai.com/docs/integrations/third-party/langchain/python Check if the alchemyst package is installed in the current environment. ```bash pip list | grep alchemyst ``` -------------------------------- ### Install Alchemyst LangChain package Source: https://getalchemystai.com/docs/integrations/third-party/langchain/python Install the required package via pip. ```sh pip install alchemyst-langchain ``` -------------------------------- ### Implement a CLI-based QnA Agent with Memory Source: https://getalchemystai.com/docs/integrations/third-party/agnoagi This example demonstrates a complete CLI loop including conversation history tracking, memory searching via the Alchemyst client, and basic command handling. ```python def show_history(self): """Display conversation history""" if not self.conversation_history: print("\nNo conversation history yet.") return print("\n" + "=" * 60) print("CONVERSATION HISTORY") print("=" * 60) for i, msg in enumerate(self.conversation_history, 1): role = "You" if msg["role"] == "user" else "Agent" print(f"\n[{i}] {role}: {msg['content']}") print("\n" + "=" * 60) def search_memory(self, query: str): """Search through all saved memories""" try: results = self.alchemyst_client.v1.context.search( query=query, similarity_threshold=0.5, scope="internal", minimum_similarity_threshold=0.2, body_metadata=None, # {"groupName": [self.context_group]}, ) print("🔍 Searching memory...") print(results.contexts) if results.contexts: print(f"\n🔍 Found {len(results.contexts)} relevant memories:") print("=" * 60) for i, result in enumerate(results.contexts[:5], 1): content = getattr(result, "content", "") print(f"\n[{i}] {content}") print("\n" + "=" * 60) else: print("\n🔍 No relevant memories found.") except Exception as e: print(f"Error searching memory: {e}") def print_welcome(): """Print welcome message""" print("\n" + "=" * 60) print(" CLI QnA AGENT WITH MEMORY") print(" Powered by OpenAI + Alchemyst AI") print("=" * 60) print("\nCommands:") print(" - Type your question to get an answer") print(" - 'history' - Show conversation history") print(" - 'search ' - Search through saved memories") print(" - 'exit' or 'quit' - Exit the program") print("\n" + "=" * 60 + "\n") def main(): """Main CLI loop""" # Print welcome message print_welcome() # Initialize agent try: agent = QnAAgent() except Exception as e: print(f"\n❌ Failed to initialize agent: {e}") print("\nPlease ensure you have set the following environment variables:") print(" - OPENAI_API_KEY") print(" - ALCHEMYST_AI_API_KEY") return # Main interaction loop while True: try: # Get user input user_input = input("\n💬 You: ").strip() # Handle empty input if not user_input: continue # Handle exit commands if user_input.lower() in ["exit", "quit", "q"]: print("\n👋 Goodbye! Your conversation has been saved to memory.") break # Handle history command if user_input.lower() == "history": agent.show_history() continue # Handle search command if user_input.lower().startswith("search "): query = user_input[7:].strip() if query: agent.search_memory(query) else: print("\n⚠️ Please provide a search query: search ") continue # Process question print("\n🤖 Agent: ", end="", flush=True) answer = agent.ask(user_input) print(answer) except KeyboardInterrupt: print("\n\n👋 Goodbye! Your conversation has been saved to memory.") break except Exception as e: print(f"\n❌ Error: {e}") if __name__ == "__main__": main() ``` -------------------------------- ### Install Dependencies for Memory-Enabled Agents Source: https://getalchemystai.com/docs/getting-started/quickstart-memory Commands to install the necessary packages for TypeScript and Python projects. ```bash npm install ai @alchemystai/aisdk ``` ```bash pip install alchemystai openai ``` -------------------------------- ### CLI Interface and Initialization Source: https://getalchemystai.com/docs/integrations/third-party/agnoagi Functions for displaying the welcome message and initializing the agent with required environment variables. ```python def print_welcome(): """Print welcome message""" print("\n" + "=" * 60) print(" CLI Knowledge Agent WITH MEMORY") print(" Powered by OpenAI + Alchemyst AI") print("=" * 60) print("\nCommands:") print(" - Type your question to get an answer") print(" - 'history' - Show conversation history") print(" - 'search ' - Search through saved memories") print(" - 'addkb ' - Add text to knowledge base") print(" - 'exit' or 'quit' - Exit the program") print("\n" + "=" * 60 + "\n") def main(): """Main CLI loop""" print_welcome() try: agent = AlchemystKnowledgeAgent() except Exception as e: print(f"\n❌ Failed to initialize agent: {e}") print("\nPlease ensure you have set the following environment variables:") print(" - OPENAI_API_KEY") print(" - ALCHEMYST_AI_API_KEY") return ``` -------------------------------- ### Clone the repository Source: https://getalchemystai.com/docs/example-projects/community/company_research Initial step to download the project source code and navigate to the directory. ```bash git clone cd company_research ``` -------------------------------- ### Example Query Patterns Source: https://getalchemystai.com/docs/integrations/data-sources/databases/Postgresql Examples of how natural language queries are mapped to database filters and semantic searches. ```text "Show me all high-priority support tickets from last month" → Filters: groupName includes "support_tickets", metadata.priority="high" "Find customer payment issues" → Semantic search across content for payment-related problems "What's the resolution pattern for login errors?" → Retrieves similar resolved tickets and identifies common solutions ``` -------------------------------- ### Add context with nested parameters Source: https://getalchemystai.com/docs/integrations/sdk/python-sdk Demonstrates initializing the client and adding context using nested metadata parameters. ```python from alchemyst_ai import AlchemystAI client = AlchemystAI() response = client.v1.context.add( metadata={}, ) print(response.metadata) ``` -------------------------------- ### Install Alchemyst LangChain Package Source: https://getalchemystai.com/docs/integrations/third-party/langchain/js Commands to install the required package using various Node.js package managers. ```sh npm i @alchemystai/langchain-js ``` ```sh yarn add @alchemystai/langchain-js ``` ```sh pnpm add @alchemystai/langchain-js ``` ```sh bun add @alchemystai/langchain-js ``` -------------------------------- ### Configure Environment Variables Source: https://getalchemystai.com/docs/example-projects/community/prompt-evaluator Create a .env.local file in the project root to store necessary API keys. ```text GOOGLE_API_KEY=your-google-generative-ai-key ALCHEMYST_API_KEY=your-alchemystai-sdk-key ``` -------------------------------- ### Set up an MCP Client with Vercel AI SDK Source: https://getalchemystai.com/docs/integrations/third-party/aisdk Initializes an MCP client using SSE transport and custom authentication headers. ```ts import { experimental_createMCPClient as createMCPClient } from 'ai'; const mcpClient = await createMCPClient({ transport: { type: 'sse', url: 'https://mcp.getalchemystai.com/sse', // Configure HTTP headers, e.g. for authentication headers: { Authorization: 'Bearer YOUR_ALCHEMYST_AI_API_KEY', }, }, }); ``` -------------------------------- ### GET /api/docs/list Source: https://getalchemystai.com/docs/example-projects/team/zendocs Retrieves a list of all available documents. ```APIDOC ## GET /api/docs/list ### Description List all documents stored in the system. ### Method GET ### Endpoint /api/docs/list ``` -------------------------------- ### GET /api/v1/context/view Source: https://getalchemystai.com/docs/api-reference/endpoint/api/v1/context/view/get Retrieves the context information for the authenticated user. ```APIDOC ## GET /api/v1/context/view ### Description Gets the context information for the authenticated user. ### Method GET ### Endpoint /api/v1/context/view ### Parameters #### Query Parameters - **file_name** (string) - Optional - Name of the file to retrieve context for - **magic_key** (string) - Optional - Magic key for context retrieval ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful - **contexts** (array) - List of context items #### Response Example { "success": true, "contexts": [ { "content": "Customer asked about pricing for the Scale plan.", "metadata": { "fileName": "support_thread_TCK-1234.txt", "fileType": "text/plain", "groupName": ["support", "pricing"], "lastModified": "2025-01-10T12:34:56.000Z", "fileSize": 2048 } } ] } ``` -------------------------------- ### Handle unauthorized error Source: https://getalchemystai.com/docs/getting-started/quickstart Example of a 401 unauthorized error response. ```json { "error": "Invalid API key", "code": "UNAUTHORIZED", "status": 401 } ``` -------------------------------- ### Complete Memory Integration Example Source: https://getalchemystai.com/docs/getting-started/quickstart-memory A full implementation showing initialization and usage of memory-enabled text generation across multiple sessions. ```typescript import { generateText } from 'ai'; import { withAlchemyst } from '@alchemystai/aisdk'; const generateTextWithMemory = withAlchemyst(generateText, { apiKey: process.env.ALCHEMYST_AI_API_KEY, }); async function main() { // Day 1: Learn preference const response1 = await generateTextWithMemory({ model: "openai:gpt-4", prompt: "I love science fiction movies", userId: "bob", sessionId: "preferences" }); console.log("AI:", response1.text); // Output: "Great! I'll remember you enjoy sci-fi films." // Day 2: Use preference const response2 = await generateTextWithMemory({ model: "openai:gpt-4", prompt: "Recommend a movie", userId: "bob", sessionId: "movie_night" }); console.log("AI:", response2.text); // Output: "How about Interstellar? You mentioned you love sci-fi." } main(); ``` -------------------------------- ### Initialize Alchemyst AI Client Source: https://getalchemystai.com/docs/integrations/third-party/agnoagi Sets up the Alchemyst AI client using an API key from environment variables. ```python import os from alchemystai import AlchemystAI # Initialize Alchemyst AI client for memory management alchemyst_client = AlchemystAI( api_key=os.getenv("ALCHEMYST_AI_API_KEY") ) ``` -------------------------------- ### GET /api/docs/[docSlug]/chat/history Source: https://getalchemystai.com/docs/example-projects/team/zendocs Retrieves the chat history for a specific document. ```APIDOC ## GET /api/docs/[docSlug]/chat/history ### Description Get the chat history associated with a specific document. ### Method GET ### Endpoint /api/docs/[docSlug]/chat/history ### Parameters #### Path Parameters - **docSlug** (string) - Required - The unique identifier for the document. ``` -------------------------------- ### GET /api/docs/[docSlug] Source: https://getalchemystai.com/docs/example-projects/team/zendocs Retrieves the details of a specific document using its slug. ```APIDOC ## GET /api/docs/[docSlug] ### Description Get a specific document by its unique slug. ### Method GET ### Endpoint /api/docs/[docSlug] ### Parameters #### Path Parameters - **docSlug** (string) - Required - The unique identifier for the document. ``` -------------------------------- ### GET /api/v1/context/traces Source: https://getalchemystai.com/docs/api-reference/endpoint/api/v1/context/traces/get Retrieves a list of traces for the authenticated user within their organization. ```APIDOC ## GET /api/v1/context/traces ### Description Returns paginated traces for the authenticated user within their organization. ### Method GET ### Endpoint /api/v1/context/traces ### Parameters #### Query Parameters - **page** (integer) - Optional - Page number for pagination (default: 1) - **limit** (integer) - Optional - Number of traces per page (default: 10) ### Response #### Success Response (200) - **traces** (array) - List of trace objects - **pagination** (object) - Pagination metadata #### Response Example { "traces": [ { "_id": "trace_123", "userId": "user_123", "organizationId": "org_123", "type": "context.search", "data": { "query": "What did the customer ask about pricing for the Scale plan?", "source": "support-inbox", "fileName": "support_thread_TCK-1234.txt" }, "createdAt": "2025-01-10T12:35:10.000Z", "updatedAt": "2025-01-10T12:35:10.000Z" } ], "pagination": { "page": 1, "limit": 10, "total": 1, "totalPages": 1, "hasNextPage": false, "hasPrevPage": false } } ``` -------------------------------- ### Clone the Repository Source: https://getalchemystai.com/docs/contribution/contributing Commands to clone the documentation repository and navigate into the directory. ```bash git clone https://github.com/YOUR-USERNAME/docs.git cd docs ``` -------------------------------- ### Complete Alchemyst-LangChain Integration Example Source: https://getalchemystai.com/docs/integrations/third-party/langchain/python Demonstrates initializing AlchemystMemory, configuring a LangChain ConversationChain, and persisting conversation context across messages. ```python from dotenv import load_dotenv import os from langchain_openai import ChatOpenAI from langchain.chains import ConversationChain from alchemyst_langchain import AlchemystMemory import uuid load_dotenv() def main(): print("Alchemyst-LangChain Integration Demo") print("=" * 50) # Use a consistent session_id to continue previous conversations # or generate a new one for a fresh start session_id = str(uuid.uuid4()) print(f"Session ID: {session_id}\n") # Initialize Alchemyst Memory memory = AlchemystMemory( api_key=os.getenv("ALCHEMYST_AI_API_KEY"), session_id=session_id ) # Initialize your preferred LLM model = ChatOpenAI( model="gpt-4o-mini", temperature=0, ) # Create conversation chain chain = ConversationChain(llm=model, memory=memory) # Test conversation with context persistence test_messages = [ "Hi, my name is Alice and I'm from New York.", "I'm a software engineer working on AI applications.", "What do you remember about me?" ] for i, message in enumerate(test_messages, 1): print(f"[Message {i}] User: {message}") response = chain.invoke({"input": message}) print(f"Assistant: {response.get('response', response)}\n") print("=" * 50) print(f"Session {session_id} completed!") print("Use the same session_id to continue this conversation later.") # Optional: Clear memory when done # memory.clear() if __name__ == "__main__": main() ``` -------------------------------- ### Required Memory Parameters Source: https://getalchemystai.com/docs/getting-started/quickstart-memory Example of providing the mandatory userId and sessionId in a memory-enabled request. ```typescript await generateTextWithMemory({ model: "openai:gpt-4", prompt: "Hello", userId: "user_123", // ✅ Required sessionId: "chat_456" // ✅ Required }); ``` -------------------------------- ### GET /api/v1/context/view/docs Source: https://getalchemystai.com/docs/api-reference/endpoint/api/v1/context/view/docs/get Fetches documents view for authenticated user with optional organization context. ```APIDOC ## GET /api/v1/context/view/docs ### Description Fetches documents view for authenticated user with optional organization context. ### Method GET ### Endpoint /api/v1/context/view/docs ### Parameters #### Query Parameters - **magic_key** (string) - Optional - Optional magic key for special access or filtering ### Response #### Success Response (200) - **documents** (array) - List of documents - **fileName** (string) - Name of the file - **fileType** (string) - Type/MIME of the file - **groupName** (array) - Array of group names to which the file belongs - **lastModified** (string) - Last modified timestamp (ISO format) - **fileSize** (number) - Size of the file in bytes #### Response Example { "documents": [ { "fileName": "support_thread_TCK-1234.txt", "fileType": "text/plain", "groupName": ["support", "pricing"], "lastModified": "2025-01-10T12:34:56.000Z", "fileSize": 2048 } ] } ``` -------------------------------- ### Configure Environment Variables Source: https://getalchemystai.com/docs/example-projects/team/syllabai Required environment variables for connecting the frontend to the backend service. ```bash NEXT_PUBLIC_BACKEND_URL=https://your-backend.example.com NEXT_PUBLIC_API_KEY=your_api_key_here # Optional: configure timeouts, storage endpoints, and dev ports ```