Posts

Showing posts from April, 2026

pool

Idea  Get schema MetaData Layout  Pattern Testcase Loops --- Pattern  Detailed plan Document for Plan Sample Reference  Testcase Loops Execute Plan Refine it  PublishTest Result  using System; using System.Collections.Generic; using System.Linq; public class ManagedConnection<T> where T : class {     public T Connection { get; }     public DateTime? DeadUntil { get; set; }     public ManagedConnection(T connection)     {         Connection = connection;         DeadUntil = null;     }     public bool IsAvailable => !DeadUntil.HasValue || DateTime.UtcNow > DeadUntil.Value; } public class RoundRobinPool<T> where T : class {     private readonly List<ManagedConnection<T>> _pool;     private readonly object _lock = new object();     private int _currentIndex = 0;     private readonly TimeSpan _...

ha

I need a python code: 1) A genai client factory 2) config file in config.json, 3) will drive from a usecase 4) usecase will have a pool of genai clients 5) genai client of multiple provider 6)genai provider has custom logic to call LLM and generate text. 7) At at usecase call, a client will be served on round robin logic import json import os from abc import ABC, abstractmethod from typing import Dict, List, Optional, Any from dataclasses import dataclass # Install deps: pip install groq openai ollama @dataclass class GenerationResponse:     content: str     provider: str     model: str class GenAIProvider(ABC):     """Abstract base for GenAI providers."""          @abstractmethod     def generate(self, prompt: str, model: str = None) -> GenerationResponse:         pass class GroqProvider(GenAIProvider):     def __init__(self, config: Dict[str, Any]):         ...

code 2

PS C:\Lab\Python\python_code_v1>  & 'c:\Python314\python.exe' 'c:\Users\PijushBiswas\.vscode\extensions\ms-python.debugpy-2025.18.0-win32-x64\bundled\libs\debugpy\launcher' '62198' '--' 'C:\Lab\Python\python_code_v1\api.py'  PS C:\Lab\Python\python_code_v1> pip install requests Requirement already satisfied: requests in c:\python312\lib\site-packages (2.32.5) Requirement already satisfied: charset_normalizer<4,>=2 in c:\python312\lib\site-packages (from requests) (3.4.4) Requirement already satisfied: idna<4,>=2.5 in c:\python312\lib\site-packages (from requests) (3.11) Requirement already satisfied: urllib3<3,>=1.21.1 in c:\python312\lib\site-packages (from requests) (2.6.3) Requirement already satisfied: certifi>=2017.4.17 in c:\python312\lib\site-packages (from requests) (2026.2.25) [notice] A new release of pip is available: 24.3.1 -> 26.0.1     [notice] To update, run: python.exe -m pip install --upgrade pip...

code

  import requests import json # 1. Replace with your actual API Key from https://aistudio.google.com/ api_key = "AIzaSyCZhXBp1i15IwTX2BpAZkeoqPNKRvGZ_b8" print ( "API Testing for Google AIs - Gemini 1.0 Pro" ) url = f "https://generativelanguage.googleapis.com/v1beta/models?key= { api_key } " response = requests . get ( url ) if response . status_code == 200 :     data = response . json ()     print ( f " { 'Model Name' :<30} | { 'Methods Supported' } " )     print ( "-" * 60 )     for model in data [ 'models' ]:         # We look for 'generateContent' as that is the method used for AI chat         if "generateContent" in model [ 'supportedGenerationMethods' ]:             print ( f " { model [ 'name' ] :<30} | { model [ 'version' ] } ..." ) else :     print ( f "Error: { response . status_code } " )     print ( response . ...