From 7669549eb671e8c683eb905e1abf29d7bdf94288 Mon Sep 17 00:00:00 2001 From: Felix Quinque <40171911+Hollyqui@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:43:36 +0100 Subject: [PATCH 1/2] Hotfix: Update README.md (#532) Fixing missing link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 33cd8cee..abcd12ff 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ The miner is given a question based on a random web page and must return a scrap # API Documentation -For detailed information on the available API endpoints, request/response formats, and usage examples, please refer to the [API Documentation](./api/API.md). +For detailed information on the available API endpoints, request/response formats, and usage examples, please refer to the [API Documentation](./validator_api/API_docs.md). # Contribute
From c8434066654f121cdd64c6cbfb58a532c9e03f70 Mon Sep 17 00:00:00 2001 From: Felix Quinque <40171911+Hollyqui@users.noreply.github.com> Date: Fri, 10 Jan 2025 13:03:02 +0100 Subject: [PATCH 2/2] Improving API docs (#533) --- README.md | 2 +- validator_api/API_docs.md | 58 ++++++++++++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index abcd12ff..8178968e 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Validators and miners are based on large language models (LLM). The validation p
-**[For Validators](./assets/validator.md)** · **[For Miners](./assets/miner.md)** +**[For Validators](./assets/validator.md)** · **[For Miners](./assets/miner.md)** · **[API Documentation](./validator_api/API_docs.md)**
diff --git a/validator_api/API_docs.md b/validator_api/API_docs.md index bf609989..1a2f7f4e 100644 --- a/validator_api/API_docs.md +++ b/validator_api/API_docs.md @@ -111,27 +111,71 @@ bash run_api.sh ## Chat Endpoints -### Mixture of Agents +### Proxy Chat Completions -**Endpoint:** `POST /mixture_of_agents` +**Endpoint:** `POST /v1/chat/completions` -**Description:** Combines multiple agents for a task. +**Description:** Proxies chat completions to an underlying GPT model. **Parameters:** - **api-key** (header, required): API key for authorization (string). +Example call using the OpenAI client: + +```python +def make_header(api_key: str): + return { + "api-key": f"{api_key}", + "Content-Type": "application/json", + } + +client = openai.AsyncOpenAI( + base_url=f"http://213.173.105.104:11198/v1", + max_retries=0, + timeout=Timeout(30, connect=10, read=20), + http_client=openai.DefaultAsyncHttpxClient( + headers=make_header(API_KEY) # Pass the headers here + ), + api_key=API_KEY +) + +result = await client.chat.completions.create( + model="hugging-quants/Meta-Llama-3.1-70B-Instruct-AWQ-INT4", + messages=[ + {"role": "user", "content": """How are you?"""}, + ], + stream=True, + temperature=0.7, + extra_body={ + "task": "InferenceTask", + "sampling_parameters": { + "mixture": False, + "max_new_tokens": 256, + "do_sample": True, + }, + }, + seed=42, + extra_headers=make_header(API_KEY), +) + +``` + +You can pass `"mixture": True` in the extra_body to use SN1's mixture of miners mode. + --- -### Proxy Chat Completions +Web Retrieval -**Endpoint:** `POST /v1/chat/completions` +**Endpoint:** `GET /web_retrieval` -**Description:** Proxies chat completions to an underlying GPT model. +**Description:** Retrieves a list websites about a search query **Parameters:** -- **api-key** (header, required): API key for authorization (string). +- **search_query** (str): The search term you'd like to look up +- **n_miners** (int, optional): How many miners to query +- **uids**: (list[int], optional): which specific uids to query (Deprecated) ---