Spaces:
Sleeping
Sleeping
Update llm.py
Browse files
llm.py
CHANGED
|
@@ -12,6 +12,16 @@ if not GEMINI_API_KEY:
|
|
| 12 |
|
| 13 |
GEMINI_API_KEY = os.getenv('GEMINI_API_KEY')
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# Get API key from environment variable
|
| 16 |
# Check GC LOL -molt
|
| 17 |
def build_prompt_from_counts(class_counts: Dict[str, int], sample_type: str = "Blood smear", stain: str = "Giemsa", magnification: str = "1000x") -> str:
|
|
|
|
| 12 |
|
| 13 |
GEMINI_API_KEY = os.getenv('GEMINI_API_KEY')
|
| 14 |
|
| 15 |
+
# Add proxy settings (use a US proxy — test free ones or get paid)
|
| 16 |
+
os.environ['HTTP_PROXY'] = 'http://51.79.87.144:54395' # e.g., 'http://123.45.67.89:8080' (free from free-proxy-list.net)
|
| 17 |
+
os.environ['HTTPS_PROXY'] = 'http://51.79.87.144:54395'
|
| 18 |
+
|
| 19 |
+
# Force REST transport for proxy compatibility
|
| 20 |
+
genai.configure(
|
| 21 |
+
api_key=GEMINI_API_KEY,
|
| 22 |
+
transport='rest' # Switches from gRPC to HTTP — required for proxies
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
# Get API key from environment variable
|
| 26 |
# Check GC LOL -molt
|
| 27 |
def build_prompt_from_counts(class_counts: Dict[str, int], sample_type: str = "Blood smear", stain: str = "Giemsa", magnification: str = "1000x") -> str:
|