Skip to content

Fix mixture endpoint #536

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

Merged
merged 1 commit into from
Jan 13, 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
2 changes: 1 addition & 1 deletion validator_api/chat_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def get_response_from_miner(body: dict[str, any], uid: int) -> tuple:


async def chat_completion(
body: dict[str, any], uids: Optional[int] = None, num_miners: int = 3
body: dict[str, any], uids: Optional[list[int]] = None, num_miners: int = 3
) -> tuple | StreamingResponse:
"""Handle chat completion with multiple miners in parallel."""
# Get multiple UIDs if none specified
Expand Down
6 changes: 3 additions & 3 deletions validator_api/mixture_of_miners.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# Add more task-specific system prompts here.
}

NUM_MIXTURE_MINERS = 5
NUM_MIXTURE_MINERS = 8
TOP_INCENTIVE_POOL = 100


Expand Down Expand Up @@ -67,7 +67,7 @@ async def mixture_of_miners(body: dict[str, any]) -> tuple | StreamingResponse:
raise HTTPException(status_code=503, detail="Failed to get responses from miners")

# Extract completions from the responses.
completions = [response[1][0] for response in valid_responses if response and len(response) > 1]
completions = ["".join(response[1]) for response in valid_responses if response and len(response) > 1]

task_name = body.get("task")
system_prompt = TASK_SYSTEM_PROMPT.get(task_name, DEFAULT_SYSTEM_PROMPT)
Expand All @@ -85,4 +85,4 @@ async def mixture_of_miners(body: dict[str, any]) -> tuple | StreamingResponse:

# Get final response using a random top miner.
final_uid = random.choice(get_uids(sampling_mode="top_incentive", k=TOP_INCENTIVE_POOL))
return await chat_completion(final_body, final_uid)
return await chat_completion(final_body, uids=[int(final_uid)])
Loading