Skip to content
Discussion options

You must be logged in to vote

For local LLMs, use the below helper function

async def generate_aiohttp(router_address: str, prompt_text: str, sampling_params: dict):
    models_url = f"http://{router_address}/v1/models"
    completions_url = f"http://{router_address}/v1/completions"
    
    async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=60)) as session:
        try:
            async with session.get(models_url) as model_resp:
                model_resp.raise_for_status()
                models_data = await model_resp.json()
                model_name = models_data["data"][0]["id"]
        except Exception as e:
            logger.error(f"Failed to fetch model: {e}")
            return {}
      …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nnp02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant