Skip to content

Commit

Permalink
Support Azure Open AI #64 Use openai python library
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinfrlch committed Nov 13, 2024
1 parent 02a1534 commit e499200
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 184 deletions.
10 changes: 4 additions & 6 deletions custom_components/llmvision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
DURATION,
MAX_FRAMES,
TEMPERATURE,
DETAIL,
INCLUDE_FILENAME,
EXPOSE_IMAGES,
SENSOR_ENTITY,
Expand Down Expand Up @@ -231,7 +230,6 @@ def __init__(self, data_call):
self.target_width = data_call.data.get(TARGET_WIDTH, 3840)
self.temperature = float(data_call.data.get(TEMPERATURE, 0.3))
self.max_tokens = int(data_call.data.get(MAXTOKENS, 100))
self.detail = str(data_call.data.get(DETAIL, "auto"))
self.include_filename = data_call.data.get(INCLUDE_FILENAME, False)
self.expose_images = data_call.data.get(EXPOSE_IMAGES, False)
self.sensor_entity = data_call.data.get(SENSOR_ENTITY)
Expand All @@ -252,7 +250,7 @@ async def image_analyzer(data_call):
message=call.message,
max_tokens=call.max_tokens,
temperature=call.temperature,
detail=call.detail)
)

# Fetch and preprocess images
processor = MediaProcessor(hass, client)
Expand All @@ -278,7 +276,7 @@ async def video_analyzer(data_call):
message=call.message,
max_tokens=call.max_tokens,
temperature=call.temperature,
detail=call.detail)
)
processor = MediaProcessor(hass, client)
client = await processor.add_videos(video_paths=call.video_paths,
event_ids=call.event_id,
Expand All @@ -300,7 +298,7 @@ async def stream_analyzer(data_call):
message=call.message,
max_tokens=call.max_tokens,
temperature=call.temperature,
detail=call.detail)
)
processor = MediaProcessor(hass, client)
client = await processor.add_streams(image_entities=call.image_entities,
duration=call.duration,
Expand Down Expand Up @@ -350,7 +348,7 @@ def is_number(s):
message=message,
max_tokens=call.max_tokens,
temperature=call.temperature,
detail=call.detail)
)
processor = MediaProcessor(hass, client)
client = await processor.add_visual_data(image_entities=call.image_entities,
image_paths=call.image_paths,
Expand Down
1 change: 0 additions & 1 deletion custom_components/llmvision/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
INTERVAL = 'interval'
DURATION = 'duration'
MAX_FRAMES = 'max_frames'
DETAIL = 'detail'
TEMPERATURE = 'temperature'
INCLUDE_FILENAME = 'include_filename'
EXPOSE_IMAGES = 'expose_images'
Expand Down
3 changes: 2 additions & 1 deletion custom_components/llmvision/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"domain": "llmvision",
"name": "LLM Vision",
"codeowners": ["@valentinfrlch"],
"requirements": ["openai==1.54.3"],
"config_flow": true,
"documentation": "https://github.com/valentinfrlch/ha-llmvision",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/valentinfrlch/ha-llmvision/issues",
"version": "1.3.1"
"version": "1.3.2"
}
Loading

0 comments on commit e499200

Please sign in to comment.