Add application file
Browse files
model.py
CHANGED
|
@@ -1,9 +1,12 @@
|
|
| 1 |
import json
|
|
|
|
| 2 |
import os
|
| 3 |
|
| 4 |
from google import genai
|
| 5 |
from google.genai import types
|
| 6 |
|
|
|
|
|
|
|
| 7 |
# ponytail: key comes from the GEMINI_API_KEY Space secret; fail loud at startup if missing
|
| 8 |
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
|
| 9 |
MODEL = os.environ.get("GEMINI_MODEL", "gemma-4-26b-a4b-it")
|
|
@@ -32,6 +35,7 @@ def extract_contact(image_path):
|
|
| 32 |
)
|
| 33 |
|
| 34 |
text = resp.text
|
|
|
|
| 35 |
start = text.find("{")
|
| 36 |
if start == -1:
|
| 37 |
raise ValueError(f"no JSON in model output: {text!r}")
|
|
|
|
| 1 |
import json
|
| 2 |
+
import logging
|
| 3 |
import os
|
| 4 |
|
| 5 |
from google import genai
|
| 6 |
from google.genai import types
|
| 7 |
|
| 8 |
+
log = logging.getLogger("cardextractor")
|
| 9 |
+
|
| 10 |
# ponytail: key comes from the GEMINI_API_KEY Space secret; fail loud at startup if missing
|
| 11 |
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
|
| 12 |
MODEL = os.environ.get("GEMINI_MODEL", "gemma-4-26b-a4b-it")
|
|
|
|
| 35 |
)
|
| 36 |
|
| 37 |
text = resp.text
|
| 38 |
+
log.info("LLM response: %s", text)
|
| 39 |
start = text.find("{")
|
| 40 |
if start == -1:
|
| 41 |
raise ValueError(f"no JSON in model output: {text!r}")
|