### Install Dependencies and Configure API Keys Source: https://context7.com/synthetic-sciences/synsci-context-bench/llms.txt Installs project dependencies using 'uv sync' and copies an example environment file for API key configuration. Users must edit the '.env.local' file with their specific API keys for the engines and LLM. ```bash # Install dependencies uv sync # Configure API keys in .env.local cp benchmarks/.env.local.example benchmarks/.env.local # Edit benchmarks/.env.local with your API keys: # SYNSC_API_KEY=your_delphie_key # NIA_API_KEY=your_nia_key # CONTEXT7_ENABLED=true # BENCH_LLM_API_KEY=your_llm_api_key ``` -------------------------------- ### Discover and Install AI Skills using ctx7 CLI Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/CONTEXT7.md Commands to search the Context7 registry, view repository information, and install specific skills into your AI coding assistant. These commands support both interactive and direct installation methods. ```bash # Search the registry by keyword ctx7 skills search pdf ctx7 skills search "react testing" # Browse all skills in a specific repository ctx7 skills info /anthropics/skills # Install a skill interactively (prompts you to pick) ctx7 skills install /anthropics/skills # Install a specific skill by name ctx7 skills install /anthropics/skills pdf # Get suggestions based on your project's dependencies ctx7 skills suggest ``` -------------------------------- ### Minimal Makefile and Source Implementation Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0243.txt A simplified approach to Makefile configuration using implicit rules. This example shows a minimal Makefile alongside a basic C source file. ```Makefile CFLAGS = -g -O0 all: main ``` ```c int main() {} ``` -------------------------------- ### Context7 CLI Skill Management Commands Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/CONTEXT7.md Demonstrates basic commands for interacting with Context7 skills using the CLI. Includes searching for skills and installing a specific skill. ```bash # Quick start npx ctx7 skills search pdf npx ctx7 skills install /anthropics/skills pdf ``` -------------------------------- ### Fetch Data with Express Router (Node.js) Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0170.txt This example demonstrates setting up an Express.js application with a router to handle POST requests. It shows how to define a POST endpoint and process incoming requests. ```javascript var express = require('express'); var router = express.Router(); var app = express() app.use('api1.abc.com', router); router.post('/v1', function(req, res) { // process res }); ``` -------------------------------- ### Receive Data with Express Router (Node.js) Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0170.txt This snippet shows how to set up a GET endpoint using Express.js and a router to receive data. It includes a placeholder for processing logic and renders a view. ```javascript router.get('/v1', function(req, res) { // TODO res.render('something'); }); ``` -------------------------------- ### Manage Installed Skills using ctx7 CLI Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/CONTEXT7.md Commands to list currently installed skills within a project or for specific clients, and to remove skills that are no longer needed. ```bash # List skills installed in the current project ctx7 skills list # List skills installed for a specific client ctx7 skills list --claude ctx7 skills list --cursor # Remove a skill ctx7 skills remove pdf ``` -------------------------------- ### Start Local Python Server Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0484.txt This command starts a simple HTTP server using Python in the current directory on port 8888. This is useful for serving local HTML, CSS, and JavaScript files, especially when dealing with cross-origin restrictions or loading local data files. ```bash python -m SimpleHTTPServer 8888 & ``` -------------------------------- ### GET /api/v2/context Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/CONTEXT7.md Retrieves documentation context for a specific library based on a natural language query. ```APIDOC ## GET /api/v2/context ### Description Fetches relevant documentation snippets or context for a specific library ID based on a provided query. ### Method GET ### Endpoint https://context7.com/api/v2/context ### Parameters #### Query Parameters - **libraryId** (string) - Required - The unique ID of the library (e.g., /facebook/react). - **query** (string) - Required - The specific question or topic to search for. - **type** (string) - Optional - The format of the returned content (e.g., txt). ### Request Example curl "https://context7.com/api/v2/context?libraryId=/facebook/react&query=useEffect&type=txt" \ -H "Authorization: Bearer CONTEXT7_API_KEY" ### Response #### Success Response (200) - **title** (string) - The title of the documentation section. - **content** (string) - The relevant documentation content. #### Response Example [ { "title": "Using useEffect", "content": "The useEffect Hook lets you perform side effects in function components..." } ] ``` -------------------------------- ### Perform POST Request with 'request' Library Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0252.txt This snippet demonstrates making a POST request using the 'request' library. It sends JSON data to a specified URL and logs the response body if the request is successful (status code 200) and there are no errors. Ensure the 'request' library is installed (`npm install request`). ```javascript const request = require('request'); var url = 'blabla'; request.post( url , { json: { api: url } } , function (err, res, bdy) { if (!err && res.statusCode == 200) console.log(bdy) } ); ``` -------------------------------- ### Perform POST Request with Axios Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0252.txt This snippet shows how to make a POST request to a '/user' endpoint using the axios library. It handles both successful responses and errors by logging the outcome to the console. Ensure axios is installed (`npm install axios`). ```javascript var axios = require('axios'); axios.post('/user', { firstName: 'Fred', lastName: 'Flintstone' }) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }); ``` -------------------------------- ### Retrieve Documentation Context via API Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/CONTEXT7.md Fetches documentation content for a specific library using a query string. Requires an Authorization header with a valid API key. ```bash curl "https://context7.com/api/v2/context?libraryId=/facebook/react&query=useEffect&type=txt" \ -H "Authorization: Bearer CONTEXT7_API_KEY" ``` -------------------------------- ### PHP Judy STRING_TO_MIXED Example with Profiling Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0268.txt This snippet demonstrates the usage of the Judy class with the STRING_TO_MIXED type in PHP. It includes operations like inserting key-value pairs, deleting a key, retrieving a value, and checking the size of the Judy array. Memory usage and execution time are also profiled. ```php echo "\n-- Judy STRING_TO_INT \n"; echo "Mem usage: ". memory_get_usage() . "\n"; echo "Mem real: ". memory_get_usage(true) . "\n"; $s=microtime(true); $judy = new Judy(Judy::STRING_TO_MIXED); for ($i=0; $i<500; $i++) $judy["$i"] = 'test'; var_dump($judy); unset($judy["102"]); echo $judy["192"]; var_dump($judy["102"]); echo "Size: ".$judy->size()."\n"; $e=microtime(true); echo "Elapsed time: ".($e - $s)." sec.\n"; echo "Mem usage: ". memory_get_usage() . "\n"; echo "Mem real: ". memory_get_usage(true) . "\n"; echo "\n"; unset($judy); ``` -------------------------------- ### Retrieve Documentation Context Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/CONTEXT7.md Fetches specific documentation snippets for a given library ID and query. The response can be returned in JSON or plain text format. ```bash # JSON format (default) curl "https://context7.com/api/v2/context?libraryId=/facebook/react&query=useEffect" \ -H "Authorization: Bearer CONTEXT7_API_KEY" ``` -------------------------------- ### Context Enrichment Example in Python Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/BENCHMARK_REPORT.md Demonstrates how search results are augmented with structural context, including function signatures and docstrings, prepended to actual code chunks. This aims to improve LLM understanding of code purpose. ```python # function: async def app(request: Request) -> Response: # Docstring: Takes a function or coroutine func(request) -> response, # and returns an ASGI application. # preceding context: # if not errors: # response_field = dependant.response_field # ... ``` -------------------------------- ### Context7 CLI Authentication Commands Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/CONTEXT7.md Illustrates the commands used to log out and log back into the Context7 CLI, which is useful for resolving authentication issues or expired tokens. ```bash ctx7 logout ctx7 login ``` -------------------------------- ### Search for Libraries via API Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/CONTEXT7.md Retrieves library metadata and identifiers by querying the search endpoint. This is the first step in finding the correct library ID for further documentation lookups. ```bash curl "https://context7.com/api/v2/libs/search?libraryName=react&query=hooks" \ -H "Authorization: Bearer CONTEXT7_API_KEY" ``` -------------------------------- ### Configure Benchmark Environment and Settings Source: https://context7.com/synthetic-sciences/synsci-context-bench/llms.txt Demonstrates how to manage benchmark configurations via environment variables and the Python configuration loader. This includes setting API endpoints, LLM model matrices, and evaluation parameters. ```bash SYNSC_API_URL=http://localhost:8000 SYNSC_API_KEY=your_delphie_api_key BENCH_LLM_PROVIDER=anthropic BENCH_LLM_MODEL=claude-sonnet-4-6 ``` ```python from benchmarks.config import BenchmarkConfig config = BenchmarkConfig() print(f"Delphie URL: {config.synsc_api_url}") models = config.load_model_matrix() config.top_k_values = [1, 3, 5, 10, 20] ``` -------------------------------- ### GET /api/v2/libs/search Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/CONTEXT7.md Search for available libraries by name to retrieve their unique identifiers and metadata. ```APIDOC ## GET /api/v2/libs/search ### Description Search for available libraries by name. Use this to find the correct library ID before fetching documentation. ### Method GET ### Endpoint /api/v2/libs/search ### Parameters #### Query Parameters - **query** (string) - Required - Your question or task (used for relevance ranking) - **libraryName** (string) - Required - Library name to search for (e.g., "react", "nextjs") ### Request Example curl "https://context7.com/api/v2/libs/search?libraryName=react&query=hooks" \ -H "Authorization: Bearer CONTEXT7_API_KEY" ### Response #### Success Response (200) - **id** (string) - The unique library identifier - **name** (string) - The library name - **description** (string) - Brief library description - **totalSnippets** (number) - Total available snippets - **trustScore** (number) - Reliability score - **benchmarkScore** (number) - Performance benchmark score - **versions** (array) - List of available versions #### Response Example [ { "id": "/facebook/react", "name": "React", "description": "A JavaScript library for building user interfaces", "totalSnippets": 1250, "trustScore": 95, "benchmarkScore": 88, "versions": ["v18.2.0", "v17.0.2"] } ] ``` -------------------------------- ### Run Full Benchmark Suite Source: https://context7.com/synthetic-sciences/synsci-context-bench/llms.txt Executes all benchmark suites across all configured engines using the CLI entry point. This command initiates the comprehensive evaluation process for all engines and suites. ```bash # Run full benchmark suite uv run python -m benchmarks # Example output: # Benchmarking engines: synsc-context, nia, context7 # === Retrieval Quality Benchmark (Precision@K / NDCG / MRR) === # Running 3 engines concurrently... # --- synsc-context --- # MRR: 0.817 # Precision@1: 0.800 # NDCG@10: 0.941 ``` -------------------------------- ### GET /api/v2/libs/search Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/CONTEXT7.md Searches for libraries based on a name or query string to retrieve their unique library IDs. ```APIDOC ## GET /api/v2/libs/search ### Description Searches for available libraries in the Context7 registry to find the correct library ID for subsequent context queries. ### Method GET ### Endpoint https://context7.com/api/v2/libs/search ### Parameters #### Query Parameters - **libraryName** (string) - Required - The name of the library to search for. - **query** (string) - Optional - A natural language description of the functionality or topic. ### Request Example GET https://context7.com/api/v2/libs/search?libraryName=react&query=state+management ### Response #### Success Response (200) - **id** (string) - The unique identifier for the library. - **name** (string) - The display name of the library. #### Response Example [ { "id": "/facebook/react", "name": "React" } ] ``` -------------------------------- ### GET /api/v2/context Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/CONTEXT7.md Retrieve specific documentation context for a library based on a query, returning either JSON or plain text. ```APIDOC ## GET /api/v2/context ### Description Retrieve documentation context for a specific library. Returns relevant documentation snippets based on your query. ### Method GET ### Endpoint /api/v2/context ### Parameters #### Query Parameters - **query** (string) - Required - Your question or task (used for relevance ranking) - **libraryId** (string) - Required - Library identifier from search (e.g., "/facebook/react") - **type** (string) - Optional - Response format: "json" (default) or "txt" ### Request Example curl "https://context7.com/api/v2/context?libraryId=/facebook/react&query=useEffect" \ -H "Authorization: Bearer CONTEXT7_API_KEY" ### Response #### Success Response (200) - **title** (string) - Snippet title - **content** (string) - Documentation content - **source** (string) - Original documentation URL #### Response Example [ { "title": "Using the Effect Hook", "content": "The Effect Hook lets you perform side effects...", "source": "react.dev/reference/react/useEffect" } ] ``` -------------------------------- ### Search and Fetch Documentation Workflow Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/CONTEXT7.md Demonstrates a complete workflow using the Python requests library to search for a library by name and subsequently retrieve documentation context for a specific query. ```python import requests headers = {"Authorization": "Bearer CONTEXT7_API_KEY"} # Step 1: Search for the library search_response = requests.get( "https://context7.com/api/v2/libs/search", headers=headers, params={"libraryName": "react", "query": "I need to manage state"} ) libraries = search_response.json() best_match = libraries[0] print(f"Found: {best_match['name']} ({best_match['id']})") # Step 2: Get documentation context context_response = requests.get( "https://context7.com/api/v2/context", headers=headers, params={"libraryId": best_match["id"], "query": "How do I use useState?"} ) docs = context_response.json() for doc in docs: print(f"Title: {doc['title']}") print(f"Content: {doc['content'][:200]}...") ``` -------------------------------- ### Iterate and Access Object Properties in JavaScript Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0329.txt Provides examples for accessing object properties and iterating through arrays stored within object properties. ```javascript var candidate = { "name": "lokesh", "skills": ["Java", "Node Js"] }; // Accessing properties var name = candidate.name; // Iterating through an array property for (var i = 0; i < candidate.skills.length; i++) { var skill = candidate.skills[i]; console.log(skill); } ``` -------------------------------- ### Implement Custom Context Engine Adapter in Python Source: https://context7.com/synthetic-sciences/synsci-context-bench/llms.txt Demonstrates how to create a custom engine adapter by inheriting from `ContextEngineAdapter`. This involves defining methods for searching code, indexing repositories, and listing available repositories. It uses `httpx` for asynchronous HTTP requests to interact with a custom API. ```python from benchmarks.adapters.base import ( ContextEngineAdapter, SearchResult, IndexResult, ) import httpx import time class MyEngineAdapter(ContextEngineAdapter): """Adapter for a custom context engine.""" name = "my-engine" def __init__(self, api_url: str, api_key: str): self.api_url = api_url.rstrip("/") self._client = httpx.AsyncClient( base_url=self.api_url, headers={"Authorization": f"Bearer {api_key}"}, timeout=120.0, ) async def search_code( self, query: str, top_k: int = 10, repo_ids: list[str] | None = None, language: str | None = None, ) -> tuple[list[SearchResult], float]: """Search code and return (results, latency_ms).""" payload = {"query": query, "limit": top_k} if repo_ids: payload["repositories"] = repo_ids start = time.perf_counter() resp = await self._client.post("/api/search", json=payload) latency = (time.perf_counter() - start) * 1000 resp.raise_for_status() data = resp.json() results = [ SearchResult( id=r["id"], content=r["code"], score=r["score"], file_path=r.get("path", ""), language=r.get("language", ""), repo_name=r.get("repo", ""), ) for r in data["results"] ] return results, latency async def search_papers( self, query: str, top_k: int = 10, ) -> tuple[list[SearchResult], float]: """Search indexed papers.""" return [], 0.0 # Not supported async def index_repository(self, repo_url: str) -> IndexResult: """Index a GitHub repository.""" start = time.perf_counter() resp = await self._client.post( "/api/index", json={"url": repo_url}, timeout=600.0, ) duration = (time.perf_counter() - start) * 1000 if resp.status_code >= 400: return IndexResult(success=False, error=resp.text, duration_ms=duration) data = resp.json() return IndexResult( success=True, resource_id=data.get("id", ""), duration_ms=duration, ) async def index_paper(self, arxiv_id: str) -> IndexResult: return IndexResult(success=False, error="Not supported") async def list_repositories(self) -> list[dict]: resp = await self._client.get("/api/repositories") resp.raise_for_status() return resp.json().get("repositories", []) async def cleanup(self) -> None: await self._client.aclose() ``` -------------------------------- ### Fixing Directory Permissions for Skills Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/CONTEXT7.md Provides a bash command to correct directory ownership issues, often encountered when permission errors arise during skill installation or removal. ```bash # Fix directory permissions sudo chown -R $(whoami) ~/.claude/skills ``` -------------------------------- ### Download Benchmark Datasets via CLI Source: https://context7.com/synthetic-sciences/synsci-context-bench/llms.txt Fetches industry-standard datasets from HuggingFace for evaluation. Users can download all datasets or control sample sizes for specific datasets. ```bash # Download all datasets uv run python -m benchmarks --download-datasets # Control sample sizes uv run python -m benchmarks --download-datasets --dataset-max-samples 1000 ``` -------------------------------- ### Ensuring Client Configuration Directories Exist Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/CONTEXT7.md Shows bash commands to create necessary directories for AI coding assistants like Claude Code and Cursor, resolving 'Client Not Detected' errors. ```bash # For Claude Code mkdir -p .claude # For Cursor mkdir -p .cursor ``` -------------------------------- ### Manage Status Bar with Capacitor Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0003.txt Installs and utilizes the Capacitor status bar plugin to programmatically control the status bar style and handle tap events. ```bash npm install @capacitor/status-bar npx cap sync ``` ```typescript import { StatusBar, Style } from '@capacitor/status-bar'; window.addEventListener('statusTap', function () { console.log('statusbar tapped'); }); const setStatusBarStyleDark = async () => { await StatusBar.setStyle({ style: Style.Dark }); }; ``` -------------------------------- ### Get and Clean CSS Property Value (jQuery) Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0314.txt The .css() method returns the value of a CSS property. The returned value may need to be cleaned, for example, by removing 'px' units, to be used in calculations. ```javascript $("#11a").css("top").replace("px", ""); ``` -------------------------------- ### Sequential jQuery Animations with Callback Counter Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0277.txt This example demonstrates a more robust method for sequential animations using a counter. It increments a counter when an animation starts and decrements it when it finishes, allowing for a check when all animations are complete. ```javascript var animations = 0; checkAnimation(1); $('#Div1').slideDown('fast', function(){ checkAnimation(-1); }); checkAnimation(count){ animations += count; if(count == 0) //animations complete } else { //still animating } } ``` -------------------------------- ### Initialize Twilio Client Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0413.txt Correct syntax for importing the Twilio Client and initializing it with account credentials. This snippet addresses common traceback errors occurring at the client instantiation line. ```python from twilio.rest import Client # Initialize the client with your credentials twilioClient = Client(account_sid, auth_token) ``` -------------------------------- ### Implement RxJS Timeout in Service Methods Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0198.txt Demonstrates how to apply the timeout operator within an RxJS pipe to limit the execution time of an API call. Includes an example of using catchError to handle timeout exceptions gracefully. ```typescript import { timeout, catchError } from 'rxjs/operators'; import { of } from 'rxjs/observable/of'; getTxnInfo(headers: any[], params: any[]) { return this.apiService.get(environment.rm_url + 'rm-analytics-api/dashboard/txn-info', headers, params) .pipe( timeout(20000), catchError(e => { return of(null); }) ); } ``` -------------------------------- ### SQL: Filter by Explicit Date and Hour Range Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0194.txt This method uses explicit logical operators (OR and AND) to define a date and hour range. It handles cases where the start and end dates are the same by comparing hours. No external dependencies are required. ```SQL where (date > xxxx or (date = xxxx and hour >= hhhh)) and (date < yyyy or (date = yyyy and hour < hhhh)) ``` -------------------------------- ### Execute Java PageRank Class Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0375.txt Runs the PageRank class, expecting a filename as a command-line argument. This command is executed from the 'src' directory. ```shell java pagerank.PageRank ``` -------------------------------- ### SQL: Calculate Ratio with Subquery and Division by Zero Handling Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0429.txt This SQL query calculates the ratio of items starting with 'A' to items starting with 'B' within each group. It uses a subquery to first count 'A' and 'B' prefixed items per ID, and the outer query calculates the ratio, safely handling division by zero by checking if B is 0. This approach ensures robustness against missing 'B' rows. ```sql SELECT ID, CASE WHEN B = 0 THEN 0 ELSE A/B END AS Ratio FROM ( SELECT ID, SUM(CASE WHEN Name LIKE 'A%' THEN 1 ELSE 0 END) AS A, SUM(CASE WHEN Name LIKE 'B%' THEN 1 ELSE 0 END) AS B FROM my_table GROUP BY ID ) AS grouped; ``` -------------------------------- ### Initialize Speech Recognizer with C++ SDK Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0460.txt This snippet demonstrates how to configure the Speech SDK, set up audio input from the default microphone, and perform a single speech recognition task. It requires the Microsoft Cognitive Services Speech SDK headers to be included in the project's VC++ directories. ```cpp #include #include using namespace std; using namespace Microsoft::CognitiveServices::Speech::Audio; using namespace Microsoft::CognitiveServices::Speech; auto config = SpeechConfig::FromSubscription("real_sub_id", "region"); int main() { std::cout << "Hello World!\n"; auto audioCofig = AudioConfig::FromDefaultMicrophoneInput(); auto recognizer = SpeechRecognizer::FromConfig(config, audioCofig); cout << "Speak " << endl; auto result = recognizer->RecognizeOnceAsync().get(); cout << "RECOGNIZED: Text=" << result->Text; } ``` -------------------------------- ### Programmatic Dataset Download (Python) Source: https://context7.com/synthetic-sciences/synsci-context-bench/llms.txt Enables programmatic downloading of benchmark datasets using functions from 'benchmarks.dataset_loader'. Supports downloading specific datasets with custom parameters like languages, sample limits, and random seeds, or downloading all datasets at once. ```python from benchmarks.dataset_loader import ( download_codesearchnet, download_cosqa, download_advtest, download_all, ) # Download specific dataset with custom parameters path = download_codesearchnet( languages=["python", "javascript"], max_per_language=500, seed=42, ) # Returns: Path to benchmarks/datasets/codesearchnet_benchmark.json # Download all datasets paths = download_all( csn_max_per_lang=500, cosqa_max=500, advtest_max=500, staqc_max=500, coir_max=500, seed=42, ) # Returns: {"codesearchnet": Path(...), "cosqa": Path(...), ...} ``` -------------------------------- ### Open GDAL Raster for Writing (JavaScript) Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0166.txt This snippet demonstrates how to open a GDAL raster file in update mode using the `gdal.GA_Update` flag in JavaScript. This is necessary when you intend to modify the contents of the raster file. Ensure the GDAL library is correctly installed and accessible. ```javascript const gdal = require('gdal-async'); // Open the raster file in update mode const dataset = gdal.open('raster.bip', gdal.GA_Update); // Now you can perform write operations on the dataset // For example: dataset.bands.get(1).pixels.write(...); // Remember to close the dataset when done dataset.close(); ``` -------------------------------- ### C# Client-Side File Upload Call Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0306.txt Demonstrates how to call the Refit client to upload a file. It involves opening a file stream, creating a `StreamPart` object with the stream and file name, and then invoking the `AddFile` method on the Refit client. Error handling for `ApiException` is included. ```csharp using System.IO; using System.Threading.Tasks; // Assuming request is an object with File, FileName, FilePath, Description properties // Assuming _filesClient is an instance of IFilesClient { System.IO.Stream FileStream = request.File.OpenReadStream(); StreamPart sp = new StreamPart(FileStream, request.FileName); try { await _filesClient.AddFile(request.FilePath, request.Description, sp); } catch (ApiException ae) { // Handle API exception throw new Exception("Refit FileClient API Exception", ae); } } ``` -------------------------------- ### Implement Custom List Starting Points with CSS Classes Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0254.txt This approach uses specific CSS classes to define starting points for ordered lists. While it provides granular control, it requires manual maintenance of class definitions for each starting index. ```css ol.start4 { counter-reset: item 4; counter-increment: item -1; } ol.start6 { counter-reset: item 6; counter-increment: item -1; } ``` -------------------------------- ### Interact with Textarea using Watir Webdriver (Ruby) Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0341.txt Demonstrates how to open a browser, navigate to a URL, and set text content within a textarea element using Watir Webdriver. This is suitable for standard HTML textarea elements. ```ruby require "watir-webdriver" browser = Watir::Browser.new browser.goto "ideone.com" browser.div(:id => "file_div").textarea.set "1=1" ``` -------------------------------- ### Install Twilio and Pip Dependencies Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0413.txt Commands to install the Twilio library and the Python package manager on a Raspberry Pi. These commands require administrative privileges to ensure system-wide availability. ```bash sudo apt-get install python3-pip sudo pip install twilio ``` -------------------------------- ### Run Specific Benchmark Suites via CLI Source: https://context7.com/synthetic-sciences/synsci-context-bench/llms.txt Allows targeting individual benchmark suites for focused evaluation or quick iteration. Options include running retrieval quality, LLM-as-judge, hallucination benchmarks, skipping indexing, and selecting specific validated datasets. ```bash # Run only retrieval quality benchmark uv run python -m benchmarks --retrieval-only --engines synsc context7 # Run only LLM-as-judge evaluation uv run python -m benchmarks --judge-only --engines synscnia --max-queries 100 # Run enhanced judge with position debiasing uv run python -m benchmarks --enhanced-judge-only --engines synsc context7 # Run hallucination benchmark across multiple model tiers uv run python -m benchmarks --hallucination-only --multi-model # Skip indexing for repeated runs uv run python -m benchmarks --skip-indexing --validated-only # Run specific validated dataset uv run python -m benchmarks --validated-only --dataset cosqa ``` -------------------------------- ### Pre-embedding Enrichment Example Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/docs/BENCHMARK_REPORT.md An example of structural metadata prepended to code chunks before embedding. This metadata includes file path, scope, defined elements, dependencies, and ordering relative to other code elements. It aims to provide richer context for retrieval. ```text # File: src/auth/middleware.py # Scope: AuthMiddleware > validate_token # Defines: validate_token, decode_jwt # Uses: import jwt, import datetime # After: refresh_token, revoke_token # Before: AuthMiddleware.__init__ ``` -------------------------------- ### Set Linear Gradient Fill in Swift 4 Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0092.txt Demonstrates how to set a linear gradient fill for a chart dataset in Swift 4. This example defines two distinct colors for the gradient and applies it using Fill.fillWithLinearGradient. ```swift let colorTop = UIColor(red: 255.0/255.0, green: 149.0/255.0, blue: 0.0/255.0, alpha: 1.0).cgColor let colorBottom = UIColor(red: 255.0/255.0, green: 94.0/255.0, blue: 58.0/255.0, alpha: 1.0).cgColor let gradientColors = [colorTop, colorBottom] as CFArray let colorLocations:[CGFloat] = [0.0, 1.0] let gradient = CGGradient.init(colorsSpace: CGColorSpaceCreateDeviceRGB(), colors: gradientColors, locations: colorLocations) // Gradient Object yourDataSetName.fill = Fill.fillWithLinearGradient(gradient!, angle: 90.0) ``` -------------------------------- ### Filter Posts by ID and Order by Creation Date (Ruby) Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0282.txt Retrieves 10 posts with an ID greater than a specified value, ordered by their creation date in ascending order. This is an alternative to ordering by ID. ```ruby Post.where('id > ?', start_id).order('created_at').limit(10) ``` -------------------------------- ### HTML Structure for Currency Converter Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0007.txt This HTML snippet provides the basic structure for the currency converter interface. It includes input fields for the amount, dropdowns for selecting currencies, a convert button, and an unordered list to display the conversion results. It also includes links to jQuery and money.js libraries. ```html Amount:
From:
To:
``` -------------------------------- ### Set Linear Gradient Fill in Swift 3.1 (ios-charts 3.0.1) Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0092.txt Code example for setting a linear gradient fill for a chart dataset using Swift 3.1 and ios-charts version 3.0.1. It utilizes CGGradient.init and Fill.fillWithLinearGradient. ```swift let gradientColors = [UIColor.cyan.cgColor, UIColor.clear.cgColor] as CFArray // Colors of the gradient let colorLocations:[CGFloat] = [1.0, 0.0] // Positioning of the gradient let gradient = CGGradient.init(colorsSpace: CGColorSpaceCreateDeviceRGB(), colors: gradientColors, locations: colorLocations) // Gradient Object yourDataSetName.fill = Fill.fillWithLinearGradient(gradient!, angle: 90.0) // Set the Gradient set.drawFilledEnabled = true // Draw the Gradient ``` -------------------------------- ### Execute Java PageRankTester Class Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0375.txt Runs the PageRankTester class to execute various test methods. This command is executed from the 'src' directory. ```shell java pagerank.PageRankTester ``` -------------------------------- ### Non-Greedy Delimiter Matching Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0116.txt This regex pattern uses a non-greedy approach to match content between 'Start' and 'End' delimiters. The addition of '?' after '*' quantifiers prevents the pattern from matching across multiple pairs of delimiters, ensuring it captures only the content within the nearest 'Start' and 'End'. ```regex Start(.*?.*?)End ``` -------------------------------- ### Compile Java Code using Javac Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0375.txt Compiles all Java files within the 'pagerank' package located in the 'src' directory. This command is executed from the 'src' directory. ```shell javac pagerank/*.java ``` -------------------------------- ### Adding Lang Parameter to Omniauth-Twitter Call (URL Example) Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0077.txt This example shows how to include a language parameter when initiating an Omniauth authentication with Twitter. By adding the `lang` parameter to the Twitter API call, you can influence the language of the responses received from Twitter, facilitating internationalization. ```text lang=ru ``` -------------------------------- ### jQuery delay for chaining class additions Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0487.txt This example demonstrates an alternative approach using jQuery's delay method to chain class additions with a time delay. This can simplify the code compared to using setTimeout directly for sequential class manipulations. ```javascript $(this).addClass("door").delay(2000).addClass("doorstatic", "slow"); ``` -------------------------------- ### Implement Synchronous TCP Server with Boost.Asio Source: https://github.com/synthetic-sciences/synsci-context-bench/blob/main/corpus/stackoverflow-qa/snippet_0297.txt A compact implementation of a TCP server that accepts connections and processes incoming requests synchronously. It utilizes tcp::iostream to handle socket communication as a standard stream, facilitating easier parsing and data transfer. ```cpp struct Sync { void run_server(); void save(Request const& req); private: Conf const *conf = &s_config; tcp::iostream socket; }; void Sync::run_server() { ba::io_service io_service; tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v4(), conf->def_port)); acceptor.accept(*socket.rdbuf()); for (Request req; socket >> std::noskipws >> req; std::cout << req << " handled\n") save(req); } void Sync::save(Request const& req) { char buf[1024]; size_t remain = req.data_size, n = 0; for (std::ofstream of(req.get_filename(), std::ios::binary); socket.read(buf, std::min(sizeof(buf), remain)), (n = socket.gcount()); remain -= n) { if (!of.write(buf, n)) break; } } int main() { Sync().run_server(); } ```