Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Main into Staging #537

Merged
merged 3 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Validators and miners are based on large language models (LLM). The validation p

<div align="center">

**[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)**


</div>
Expand Down Expand Up @@ -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
<div align="center">
Expand Down
58 changes: 51 additions & 7 deletions validator_api/API_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

---

Expand Down
Loading