### Start the Server Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md Commands to start the development server, with a specific command for streaming-only configuration. ```bash npm run dev ``` ```bash # or for streaming-specific config: npm run serve:streaming ``` -------------------------------- ### Quick Start CLI Commands Source: https://github.com/piyook/llm-mock/blob/main/README.md Commands to create a new project, install dependencies, and start the LLMock server. ```bash npm create llmock@latest my-project cd my-project npm install npm run llmock:start ``` -------------------------------- ### Install Dependencies Source: https://github.com/piyook/llm-mock/blob/main/create-llmock/templates/README.md Installs the necessary packages for the project. ```bash npm install ``` -------------------------------- ### Start Mock Server Source: https://github.com/piyook/llm-mock/blob/main/create-llmock/templates/README.md Starts the LLMock server. ```bash npm run llmock:start ``` -------------------------------- ### Static Mode Request Example Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md Example cURL command to make a request in static mode (STREAM=false). ```bash curl -X POST http://localhost:8001/chatgpt/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o", "messages": [{"role": "user", "content": "Hello world"}], "temperature": 1, "n": 1, "stream": false }' ``` -------------------------------- ### Docker Start Command Source: https://github.com/piyook/llm-mock/blob/main/README.md Command to start LLMock using Docker after scaffolding a project. ```bash npm create llmock@latest my-project cd my-project npm run docker:start ``` -------------------------------- ### Unit Tests Command Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md Command to run unit tests. ```bash npm run test:unit ``` -------------------------------- ### Run with ChatGPT Model Source: https://github.com/piyook/llm-mock/blob/main/create-llmock/templates/README.md Starts the LLMock server configured for ChatGPT model. ```bash npm run llmock:chatgpt ``` -------------------------------- ### Starting with a Custom Model Source: https://github.com/piyook/llm-mock/blob/main/README.md Command to start the LLM Mock Server using a custom model. ```bash llmock start --model=my-model ``` -------------------------------- ### Start and Test LLM Mock Source: https://github.com/piyook/llm-mock/blob/main/README.md Commands to start the LLM Mock server and test it with curl. ```bash llmock start --model=mymodel curl http://localhost:8001/api/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{"model": "my-custom-model-v1", "messages": [{"role": "user", "content": "Hello"}]}' ``` -------------------------------- ### Build and Run UI and Mock Server Source: https://github.com/piyook/llm-mock/blob/main/UI-Dev.md Command to build the UI and start the mock server together. ```bash npm run dev ``` -------------------------------- ### Embeddings with OpenAI Client Libraries (JavaScript/Node.js) Source: https://github.com/piyook/llm-mock/blob/main/docs/embeddings.md Example of creating embeddings using the OpenAI client library in JavaScript/Node.js. ```javascript import { OpenAI } from 'openai'; const openai = new OpenAI({ baseURL: 'http://localhost:8001/v1', apiKey: 'sk-mock-key' // Mock key for development }); const response = await openai.embeddings.create({ model: 'text-embedding-ada-002', input: 'Your text here' }); console.log(response.data[0].embedding); // Should be array of numbers ``` -------------------------------- ### Embeddings with LangChain (JavaScript) Source: https://github.com/piyook/llm-mock/blob/main/docs/embeddings.md Example of creating embeddings using LangChain with OpenAIEmbeddings in JavaScript. ```javascript import { OpenAIEmbeddings } from '@langchain/openai'; const embeddings = new OpenAIEmbeddings({ openAIApiKey: 'sk-mock-key', modelName: 'text-embedding-ada-002', configuration: { baseURL: 'http://localhost:8001/v1', }, }); const result = await embeddings.embedQuery("Hello world"); console.log(result); // Should be array of numbers ``` -------------------------------- ### Run with Gemini Model Source: https://github.com/piyook/llm-mock/blob/main/create-llmock/templates/README.md Starts the LLMock server configured for Gemini model. ```bash npm run llmock:gemini ``` -------------------------------- ### Run with Streaming Responses Source: https://github.com/piyook/llm-mock/blob/main/create-llmock/templates/README.md Starts the LLMock server configured for streaming responses. ```bash npm run llmock:streaming ``` -------------------------------- ### Embeddings with OpenAI Client Libraries (Python) Source: https://github.com/piyook/llm-mock/blob/main/docs/embeddings.md Example of creating embeddings using the OpenAI client library in Python. ```python from openai import OpenAI client = OpenAI( base_url="http://localhost:8001/v1", api_key="sk-mock-key" ) response = client.embeddings.create( model="text-embedding-ada-002", input="Your text here" ) print(response.data[0].embedding) # Should be array of numbers ``` -------------------------------- ### Run with Embeddings Model Source: https://github.com/piyook/llm-mock/blob/main/create-llmock/templates/README.md Starts the LLMock server configured for embeddings model. ```bash npm run llmock:embeddings ``` -------------------------------- ### JavaScript/Fetch - Static Mode Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md Example of making a static (non-streaming) chat completion request using JavaScript's Fetch API. ```javascript // Static mode const response = await fetch('http://localhost:8001/chatgpt/chat/completions', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'gpt-4o', messages: [{ role: 'user', content: 'Hello' }], temperature: 1, n: 1, stream: false }) }); const result = await response.json(); console.log(result); ``` -------------------------------- ### Streaming Response Example Source: https://github.com/piyook/llm-mock/blob/main/README.md Example of Server-Sent Events (SSE) stream format. ```text data: {"id":"chatcmpl-123","object":"chat.completion.chunk","choices":[{"delta":{"role":"assistant"}}]} data: {"id":"chatcmpl-124","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"}}]} data: [DONE] ``` -------------------------------- ### GET Request Test Source: https://github.com/piyook/llm-mock/blob/main/docs/embeddings.md Tests the embeddings endpoint using a GET request with query parameters. ```bash curl -X GET "http://localhost:8001/v1/embeddings?model=text-embedding-3-small&input=GET%20test&dimensions=64" ``` -------------------------------- ### Python - Static Mode Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md Example of making a static (non-streaming) chat completion request using Python's requests library. ```python import requests # Static mode response = requests.post( 'http://localhost:8001/chatgpt/chat/completions', json={ 'model': 'gpt-4o', 'messages': [{'role': 'user', 'content': 'Hello'}], 'temperature': 1, 'n': 1, 'stream': False } ) print(response.json()) ``` -------------------------------- ### Debug Commands Source: https://github.com/piyook/llm-mock/blob/main/docs/embeddings.md Useful commands for debugging the embeddings mock server. ```bash # Check server status curl http://localhost:8001/ping # Check UI metadata (includes embeddings status) curl http://localhost:8001/ui-meta # Check logs for detailed request information curl http://localhost:8001/logs ``` -------------------------------- ### JavaScript/Fetch - Streaming Mode Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md Example of making a streaming chat completion request using JavaScript's Fetch API and processing the streamed data. ```javascript // Streaming mode const response = await fetch('http://localhost:8001/chatgpt/chat/completions', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'gpt-4o', messages: [{ role: 'user', content: 'Hello' }], temperature: 1, n: 1, stream: false }) }); const reader = response.body.getReader(); const decoder = new TextDecoder(); while (true) { const { done, value } = await reader.read(); if (done) break; const chunk = decoder.decode(value); const lines = chunk.split('\n'); for (const line of lines) { if (line.startsWith('data: ')) { const data = line.slice(6); if (data === '[DONE]') { console.log('Stream completed'); return; } const parsed = JSON.parse(data); console.log('Chunk:', parsed); } } } ``` -------------------------------- ### Streaming Mode Request Example Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md Example cURL command to make a request in streaming mode (STREAM=true). The -N flag is used to disable the binary interpretation of the output. ```bash curl -N -X POST http://localhost:8001/chatgpt/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o", "messages": [{"role": "user", "content": "Hello world"}], "temperature": 1, "n": 1, "stream": false }' ``` -------------------------------- ### E2E Tests Commands Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md Commands to run end-to-end tests, including specific commands for streaming tests. ```bash # Test all endpoints including streaming npm run test:e2e ``` ```bash # Test only streaming npm run test:streaming ``` -------------------------------- ### Add LLMock to Existing Project (npm install) Source: https://github.com/piyook/llm-mock/blob/main/README.md Instructions to install LLMock as a dependency in an existing Node.js project. ```bash npm install llmock # or globally npm install -g llmock ``` -------------------------------- ### Python - Streaming Mode Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md Example of making a streaming chat completion request using Python's requests library and processing the streamed data. ```python # Streaming mode response = requests.post( 'http://localhost:8001/chatgpt/chat/completions', json={ 'model': 'gpt-4o', 'messages': [{'role': 'user', 'content': 'Hello'}], 'temperature': 1, 'n': 1, 'stream': False }, stream=True ) for line in response.iter_lines(): if line: decoded = line.decode('utf-8') if decoded.startswith('data: '): data = decoded[6:] # Remove 'data: ' prefix if data == '[DONE]': print('Stream completed') break import json chunk = json.loads(data) print('Chunk:', chunk) ``` -------------------------------- ### Verify Determinism - Different Inputs Source: https://github.com/piyook/llm-mock/blob/main/docs/embeddings.md Compares requests with different inputs to ensure distinct outputs. ```bash # Request with different input curl -X POST http://localhost:8001/v1/embeddings \ -H "Content-Type: application/json" \ -d '{"model": "text-embedding-ada-002", "input": "different input"}' > response3.json # Compare (should be different) diff response1.json response3.json ``` -------------------------------- ### Test Environment Variables Source: https://github.com/piyook/llm-mock/blob/main/docs/embeddings.md Demonstrates how to use environment variables to configure the embeddings mock server. ```bash # Disable embeddings echo "ENABLE_EMBEDDINGS_MOCK=false" > .env.test # Restart server and verify endpoint returns 404 # Change dimensions echo "EMBEDDING_DIMENSION=64" > .env.test # Restart server and verify embeddings have 64 dimensions ``` -------------------------------- ### Running Specific Model Presets Source: https://github.com/piyook/llm-mock/blob/main/README.md Commands to start LLMock with different model configurations for testing. ```bash npm run llmock:chatgpt # OpenAI ChatGPT-style (default) npm run llmock:gemini # Google Gemini format npm run llmock:streaming # OpenAI-style with SSE streaming npm run llmock:embeddings # Optimised for embeddings/RAG testing ``` -------------------------------- ### Static Mode Headers Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md Expected HTTP headers for static mode responses. ```http Content-Type: application/json ``` -------------------------------- ### Verify Determinism - Same Input, Same Model Source: https://github.com/piyook/llm-mock/blob/main/docs/embeddings.md Compares two identical requests to ensure deterministic output. ```bash # First request curl -X POST http://localhost:8001/v1/embeddings \ -H "Content-Type: application/json" \ -d '{"model": "text-embedding-ada-002", "input": "determinism test"}' > response1.json # Second request curl -X POST http://localhost:8001/v1/embeddings \ -H "Content-Type: application/json" \ -d '{"model": "text-embedding-ada-002", "input": "determinism test"}' > response2.json # Compare (should be identical) diff response1.json response2.json ``` -------------------------------- ### Chat completions - Streaming Source: https://github.com/piyook/llm-mock/blob/main/README.md Example curl command for streaming chat completions. ```bash curl -N http://localhost:8001/chatgpt/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o-mini", "messages": [{"role": "user", "content": "Hello"}], "stream": true }' ``` -------------------------------- ### Debug Mode Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md Enable detailed logging by setting the DEBUG environment variable. ```bash DEBUG=* ``` -------------------------------- ### Custom Stored Responses Example Source: https://github.com/piyook/llm-mock/blob/main/README.md Example JSON structure for defining custom stored responses. ```json { "responses": [ "This is a custom response for testing.", "Another predefined response for consistency." ] } ``` -------------------------------- ### Verify Determinism - Different Models, Same Input Source: https://github.com/piyook/llm-mock/blob/main/docs/embeddings.md Compares requests with different models but the same input to ensure distinct outputs. ```bash # Request with different model curl -X POST http://localhost:8001/v1/embeddings \ -H "Content-Type: application/json" \ -d '{"model": "text-embedding-3-small", "input": "determinism test"}' > response4.json # Compare (should be different) diff response1.json response4.json ``` -------------------------------- ### Automated Tests Source: https://github.com/piyook/llm-mock/blob/main/docs/embeddings.md Commands to run automated tests for the embeddings feature. ```bash # Unit Tests: npm run test:unit -- src/tests/utilities/response-helpers-embeddings.test.ts # E2E Tests: npm run test:embeddings # All Tests: npm run test:e2e (includes embeddings tests) ``` -------------------------------- ### Cypress Tests Commands Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md Commands to interact with Cypress for testing, including opening the UI and running specific streaming tests. ```bash # Open Cypress UI npm run cypress:open ``` ```bash # Run streaming tests specifically npm run test:streaming ``` -------------------------------- ### Request Template Source: https://github.com/piyook/llm-mock/blob/main/README.md Example JSON structure for a request template. ```json { "model": "string", "messages": [ { "role": "string", "content": "string" } ] } ``` -------------------------------- ### Streaming Mode Headers Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md Expected HTTP headers for streaming mode responses. ```http Content-Type: text/event-stream ``` ```http Cache-Control: no-cache ``` ```http Connection: keep-alive ``` ```http Access-Control-Allow-Origin: * ``` ```http Access-Control-Allow-Headers: Cache-Control ``` -------------------------------- ### Basic Single Input Test Source: https://github.com/piyook/llm-mock/blob/main/docs/embeddings.md Tests the embeddings endpoint with a single input string. ```bash curl -X POST http://localhost:8001/v1/embeddings \ -H "Content-Type: application/json" \ -d '{ "model": "text-embedding-ada-002", "input": "Hello world" }' ``` ```json { "object": "list", "data": [ { "object": "embedding", "index": 0, "embedding": [0.1234, -0.5678, 0.9012, ...] } ], "model": "text-embedding-ada-002", "usage": { "prompt_tokens": 2, "total_tokens": 2 } } ``` -------------------------------- ### Custom API Path Configuration Source: https://github.com/piyook/llm-mock/blob/main/README.md Examples of configuring custom API endpoint paths. ```json { "endpoint": "chatgpt/chat/completions" } ``` ```json { "endpoint": "models/gemini-pro:generateContent" } ``` -------------------------------- ### Model Preset Configuration Source: https://github.com/piyook/llm-mock/blob/main/README.md Example JSON configuration for a custom model preset in .llmockrc.json. ```json { "models": { "mymodel": { "name": "mymodel", "model": "my-custom-model-v1", "endpoint": "api/v1/chat/completions", "responseType": "lorem", "maxLoremParas": 8, "validateRequests": true, "stream": false, "responseDelay": { "min": 1000, "max": 2000 }, "embeddings": { "enabled": true, "dimensions": 128 } } } } ``` -------------------------------- ### Request Logging Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md Enable detailed request logging and validation, and access logs via a specific URL. ```bash LOG_REQUESTS=ON VALIDATE_REQUESTS=ON ``` -------------------------------- ### Embeddings API - Basic usage Source: https://github.com/piyook/llm-mock/blob/main/README.md Example curl command for the embeddings API. ```bash curl http://localhost:8001/v1/embeddings \ -H "Content-Type: application/json" \ -d '{ "model": "text-embedding-3-small", "input": "Your text string goes here" }' ``` -------------------------------- ### Enable Streaming Mode via .env Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md To enable streaming mode, you can either set the STREAM variable to true in your .env file or copy the provided .env.streaming file to .env. ```bash STREAM=true ``` ```bash cp .env.streaming .env ``` -------------------------------- ### Multiple Inputs Test Source: https://github.com/piyook/llm-mock/blob/main/docs/embeddings.md Tests the embeddings endpoint with an array of input strings. ```bash curl -X POST http://localhost:8001/v1/embeddings \ -H "Content-Type: application/json" \ -d '{ "model": "text-embedding-ada-002", "input": ["First input", "Second input", "Third input"] }' ``` ```json { "object": "list", "data": [ { "object": "embedding", "index": 0, "embedding": [0.1234, -0.5678, 0.9012, ...] }, { "object": "embedding", "index": 1, "embedding": [0.2345, -0.6789, 0.0123, ...] }, { "object": "embedding", "index": 2, "embedding": [0.3456, -0.7890, 0.1234, ...] } ], "model": "text-embedding-ada-002", "usage": { "prompt_tokens": 6, "total_tokens": 6 } } ``` -------------------------------- ### Chat completions - Standard (non-streaming) Source: https://github.com/piyook/llm-mock/blob/main/README.md Example curl command for standard chat completions. ```bash curl http://localhost:8001/chatgpt/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o-mini", "messages": [{"role": "user", "content": "Hello"}], "temperature": 1, "stream": false }' ``` -------------------------------- ### LangChain - ChatOpenAI client configuration for testing Source: https://github.com/piyook/llm-mock/blob/main/README.md Example JavaScript code for configuring LangChain's ChatOpenAI client to use LLMock. ```javascript import { ChatOpenAI } from '@langchain/openai'; const chatModel = new ChatOpenAI({ openAIApiKey: process.env.OPENAI_API_KEY, modelName: 'gpt-3.5-turbo', configuration: process.env.TEST_MODE === 'true' ? { baseURL: process.env.TEST_BASE_URL } // http://localhost:8001/chatgpt : {}, }); ``` -------------------------------- ### Default Configuration File (.llmockrc.json) Source: https://github.com/piyook/llm-mock/blob/main/README.md Example of the default configuration file structure for the LLM Mock Server. ```json { "defaultModel": "chatgpt", "models": { "chatgpt": { "name": "openai", "model": "gpt-4o", "endpoint": "chatgpt/chat/completions", "responseType": "lorem", "maxLoremParas": 8, "validateRequests": true, "logRequests": true, "debug": false, "stream": false, "responseDelay": { "min": 3000, "max": 5000 }, "embeddings": { "enabled": true, "dimensions": 128 } } }, "server": { "port": 8001, "host": "0.0.0.0" } } ``` -------------------------------- ### Foreground Mode Command Source: https://github.com/piyook/llm-mock/blob/main/README.md Command to start LLMock in foreground mode, keeping the server attached to the terminal. ```bash llmock start --foreground ``` -------------------------------- ### Custom Dimensions Test Source: https://github.com/piyook/llm-mock/blob/main/docs/embeddings.md Tests the embeddings endpoint with a specified number of dimensions. ```bash curl -X POST http://localhost:8001/v1/embeddings \ -H "Content-Type: application/json" \ -d '{ "model": "text-embedding-ada-002", "input": "Test custom dimensions", "dimensions": 256 }' ``` -------------------------------- ### Static Mode Expected Response Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md The expected JSON response format for static mode. ```json { "id": "chatcmpl-6sf37lXn5paUcuf8UaurpMIKRMsTe", "object": "chat.completion", "created": 1678485525, "model": "gpt-3.5-turbo-0301", "usage": { "prompt_tokens": 12, "completion_tokens": 99, "total_tokens": 111 }, "choices": [{ "message": { "role": "assistant", "content": "Generated response content here..." }, "finish_reason": "stop", "index": 0 }] } ``` -------------------------------- ### Start LLMock with debug mode enabled Source: https://github.com/piyook/llm-mock/blob/main/README.md Enables verbose console output for debugging. ```bash llmock start --debug=true ``` -------------------------------- ### Troubleshooting Port Conflict Source: https://github.com/piyook/llm-mock/blob/main/README.md Command to start LLM Mock on a different port if the default is in use. ```bash llmock start --port=8002 ``` -------------------------------- ### Response Template Source: https://github.com/piyook/llm-mock/blob/main/README.md Example JSON structure for a response template, using DYNAMIC_CONTENT_HERE as a placeholder. ```json { "id": "chatcmpl-123", "object": "chat.completion", "choices": [ { "message": { "role": "assistant", "content": "DYNAMIC_CONTENT_HERE" }, "finish_reason": "stop" } ] } ``` -------------------------------- ### Embeddings API - Multiple embeddings Source: https://github.com/piyook/llm-mock/blob/main/README.md Example of requesting multiple embeddings in one call. ```bash -d '{"model": "text-embedding-ada-002", "input": ["First text", "Second text"]}' ``` -------------------------------- ### Chat completions - Standard response format Source: https://github.com/piyook/llm-mock/blob/main/README.md Example JSON response for standard chat completions. ```json { "id": "chatcmpl-6sf37lXn5paUcuf8UaurpMIKRMsTe", "object": "chat.completion", "created": 1678485525, "model": "gpt-3.5-turbo-0301", "choices": [{"message": {"role": "assistant", "content": "Generated response"}}] } ``` -------------------------------- ### LangChain - Embeddings configuration for testing Source: https://github.com/piyook/llm-mock/blob/main/README.md Example JavaScript code for configuring LangChain's embeddings to use LLMock. ```javascript class MockEmbeddingsAPI { async embedDocuments(texts) { return Promise.all(texts.map(text => this.embedQuery(text))); } async embedQuery(text) { const response = await fetch(process.env.TEST_EMBEDDING_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ input: text, model: 'text-embedding-ada-002' }), }); const data = await response.json(); return data.data[0].embedding; } } const embeddings = process.env.TEST_MODE === 'true' ? new MockEmbeddingsAPI() : new OpenAIEmbeddings({ openAIApiKey: process.env.OPENAI_API_KEY }); ``` -------------------------------- ### Verify Error Handling - Invalid Request (Missing Input) Source: https://github.com/piyook/llm-mock/blob/main/docs/embeddings.md Tests error response when the 'input' field is missing. ```bash curl -X POST http://localhost:8001/v1/embeddings \ -H "Content-Type: application/json" \ -d '{"model": "text-embedding-ada-002"}' ``` -------------------------------- ### Adding Custom Models Source: https://github.com/piyook/llm-mock/blob/main/README.md Example JSON snippet to extend the 'models' object for a custom model configuration. ```json { "models": { "my-model": { "name": "openai", "model": "gpt-3.5-turbo", "endpoint": "api/v1/chat/completions", "responseType": "stored", "validateRequests": true, "logRequests": false, "debug": true, "stream": false, "responseDelay": { "min": 1000, "max": 2000 }, "embeddings": { "enabled": false, "dimensions": 64 } } } } ``` -------------------------------- ### Embeddings API - Response format Source: https://github.com/piyook/llm-mock/blob/main/README.md Example JSON response format for the embeddings API. ```json { "object": "list", "data": [ { "object": "embedding", "index": 0, "embedding": [0.1234, -0.5678, 0.9012] } ], "model": "text-embedding-3-small", "usage": { "prompt_tokens": 6, "total_tokens": 6 } } ``` -------------------------------- ### Streaming Mode Expected Response Source: https://github.com/piyook/llm-mock/blob/main/docs/streaming.md The expected Server-Sent Events (SSE) stream format for streaming mode. ```text data: {"id":"chatcmpl-6sf37lXn5paUcuf8UaurpMIKRMsTe-0","object":"chat.completion.chunk","created":1678485525,"model":"gpt-3.5-turbo-0301","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]} data: {"id":"chatcmpl-6sf37lXn5paUcuf8UaurpMIKRMsTe-1","object":"chat.completion.chunk","created":1678485525,"model":"gpt-3.5-turbo-0301","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]} data: {"id":"chatcmpl-6sf37lXn5paUcuf8UaurpMIKRMsTe-2","object":"chat.completion.chunk","created":1678485525,"model":"gpt-3.5-turbo-0301","choices":[{"index":0,"delta":{"content":" world"},"finish_reason":null}]} data: {"id":"chatcmpl-6sf37lXn5paUcuf8UaurpMIKRMsTe-final","object":"chat.completion.chunk","created":1678485525,"model":"gpt-3.5-turbo-0301","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]} data: [DONE] ``` -------------------------------- ### Verify Error Handling - Invalid Request (Missing Model) Source: https://github.com/piyook/llm-mock/blob/main/docs/embeddings.md Tests error response when the 'model' field is missing. ```bash curl -X POST http://localhost:8001/v1/embeddings \ -H "Content-Type: application/json" \ -d '{"input": "missing model"}' ``` -------------------------------- ### Usage Source: https://github.com/piyook/llm-mock/blob/main/create-llmock/README.md Scaffolding tool for LLMock projects. ```bash npm create llmock@latest my-project # or npx create-llmock my-project ``` -------------------------------- ### Docker Commands Source: https://github.com/piyook/llm-mock/blob/main/create-llmock/README.md Commands for managing the LLMock Docker container. ```bash npm run docker:start # Start container (detached) npm run docker:stop # Stop container and remove volumes npm run docker:rebuild # Rebuild and restart npm run docker:restart # Stop and start ``` -------------------------------- ### Manual Docker Commands Source: https://github.com/piyook/llm-mock/blob/main/README.md Common manual commands for managing the Docker container. ```bash docker compose up -d --force-recreate # build and start docker compose logs -f # view logs docker compose down --volumes # stop and clean up docker compose down --volumes && docker compose up -d --force-recreate --build # rebuild ``` -------------------------------- ### Streaming Responses CLI Option Source: https://github.com/piyook/llm-mock/blob/main/README.md Command-line option to enable SSE streaming. ```bash llmock start --stream=true ``` -------------------------------- ### Project Structure Source: https://github.com/piyook/llm-mock/blob/main/create-llmock/README.md The generated project structure for an LLMock project. ```bash my-project/ ├── package.json ├── .llmockrc.json ├── README.md ├── requests/ │ ├── openai-chat.json │ └── gemini-chat.json └── responses/ ├── openai-chat-response.json └── gemini-chat-response.json ``` -------------------------------- ### Dashboard Serving URLs Source: https://github.com/piyook/llm-mock/blob/main/UI-Dev.md The compiled dashboard is served at http://localhost:8001/, and it reads configuration and endpoint metadata from http://localhost:8001/ui-meta. ```bash http://localhost:8001/ ``` ```bash http://localhost:8001/ui-meta ``` -------------------------------- ### UI Development Only (Hot Reload) Source: https://github.com/piyook/llm-mock/blob/main/UI-Dev.md Command for live UI development using the dedicated Svelte/Vite dev server. ```bash npm run ui-dev ``` -------------------------------- ### Environment Variables for CI/CD Source: https://github.com/piyook/llm-mock/blob/main/README.md Environment variables to switch between mock and production LLM services. ```bash TEST_MODE=true TEST_BASE_URL=http://localhost:8001/chatgpt TEST_EMBEDDING_URL=http://localhost:8001/v1/embeddings ``` -------------------------------- ### Docker Configuration Update Source: https://github.com/piyook/llm-mock/blob/main/README.md Commands to update the .llmockrc.json file and restart the Docker container. ```bash vim .llmockrc.json npm run docker:restart ``` -------------------------------- ### LLMock CLI Usage Source: https://github.com/piyook/llm-mock/blob/main/README.md Common commands for managing the LLMock server from the command line. ```bash llmock start # default: ChatGPT model, port 8001 llmock start --model=gemini llmock start --port=3000 --stream=true llmock stop llmock config # show current settings llmock help ``` -------------------------------- ### Streaming Responses Configuration Source: https://github.com/piyook/llm-mock/blob/main/README.md JSON configuration to enable Server-Sent Events (SSE) streaming. ```json { "stream": true } ``` -------------------------------- ### Response Delay Simulation Configuration Source: https://github.com/piyook/llm-mock/blob/main/README.md JSON configuration for simulating API response delays. ```json { "responseDelay": { "min": 800, "max": 2500 } } ``` -------------------------------- ### Lorem Ipsum Response Type Configuration Source: https://github.com/piyook/llm-mock/blob/main/README.md JSON configuration for the 'lorem' response type, specifying maximum paragraphs. ```json { "responseType": "lorem", "maxLoremParas": 8 } ``` -------------------------------- ### Stop Mock Server Source: https://github.com/piyook/llm-mock/blob/main/create-llmock/templates/README.md Stops the LLMock server. ```bash npm run llmock:stop ``` -------------------------------- ### Stored Responses Configuration Source: https://github.com/piyook/llm-mock/blob/main/README.md JSON configuration to enable the 'stored' response type. ```json { "responseType": "stored" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.