MCPcopy Create free account
hub / github.com/dot-agent/nextpy / _describe_image

Method _describe_image

nextpy/ai/scripts/sceneexplain.py:42–64  ·  view source on GitHub ↗
(self, image: str)

Source from the content-addressed store, hash-verified

40 scenex_api_url: str = "us-central1-causal-diffusion.cloudfunctions.net"
41
42 def _describe_image(self, image: str) -> str:
43 local_image_path = image
44 data = {
45 "data": [
46 {"image": _image_to_data_uri(local_image_path), "features": []},
47 ]
48 }
49
50 headers = {
51 "x-api-key": f"token {self.scenex_api_key}",
52 "content-type": "application/json",
53 }
54
55 connection = http.client.HTTPSConnection(
56 "us-central1-causal-diffusion.cloudfunctions.net"
57 )
58 connection.request("POST", "/describe", json.dumps(data), headers)
59 response = connection.getresponse()
60 response_data = response.read().decode("utf-8")
61 response_data = json.loads(response_data)
62 output = response_data["result"][0]["text"]
63 connection.close()
64 return output
65
66 @root_validator(pre=True)
67 def validate_environment(cls, values: Dict) -> Dict:

Callers 1

runMethod · 0.95

Calls 5

_image_to_data_uriFunction · 0.85
readMethod · 0.80
closeMethod · 0.80
requestMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected