Skip to content

Commit

Permalink
Fix README.md, add more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jekalmin committed Jan 19, 2024
1 parent cbb4b3f commit 7d6efa5
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 2 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ Options include [OpenAI Conversation](https://www.home-assistant.io/integrations
- `execute_service`
- `domain`(string): domain to be passed to `hass.services.async_call`
- `service`(string): service to be passed to `hass.services.async_call`
- `service_data`(string): service_data to be passed to `hass.services.async_call`
- `service_data`(object): service_data to be passed to `hass.services.async_call`.
- `entity_id`(string): target entity
- `device_id`(string): target device
- `area_id`(string): target area
- `add_automation`
- `automation_config`(string): An automation configuration in a yaml format
- `get_history`
Expand Down Expand Up @@ -142,6 +145,9 @@ Then you will be able to let OpenAI call your function.
### 1. template
#### 1-1. Get current weather
For real world example, see [weather](https://github.com/jekalmin/extended_openai_conversation/tree/main/examples/function/weather).<br/>
This is just an example from [OpenAI documentation](https://platform.openai.com/docs/guides/function-calling/common-use-cases)
```yaml
- spec:
name: get_current_weather
Expand Down
51 changes: 51 additions & 0 deletions examples/function/area/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@


## Objective
- Call service via area_id

<img width="300" src="https://github.com/jekalmin/extended_openai_conversation/assets/2917984/78a5c829-a6b4-4f76-8c68-9fe0ccdca2e8">


## Function

### get_attributes
```yaml
- spec:
name: execute_services
description: Execute service of devices in Home Assistant.
parameters:
type: object
properties:
list:
type: array
items:
type: object
properties:
domain:
type: string
description: The domain of the service.
service:
type: string
description: The service to be called
service_data:
type: object
description: The service data object to indicate what to control.
properties:
entity_id:
type: array
items:
type: string
description: The entity_id retrieved from available devices. It must start with domain, followed by dot character.
area_id:
type: array
items:
type: string
description: The id retrieved from areas. You can specify only area_id without entity_id to act on all entities in that area
required:
- domain
- service
- service_data
function:
type: native
name: execute_service
```
2 changes: 1 addition & 1 deletion examples/function/attributes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- Get attributes of entity

<img width="300" src="https://github.com/jekalmin/extended_openai_conversation/assets/2917984/5994c7a0-1370-4924-bed8-d2e77ec1d11d">

<img width="300" src="https://github.com/jekalmin/extended_openai_conversation/assets/2917984/177f416e-2194-4a10-a3f6-39a94da942ce">

## Function

Expand Down
37 changes: 37 additions & 0 deletions examples/function/google_search/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Objective
- Search from Google

## Prerequisite
Needs Google API Key

## Function

### search_google

```yaml
- spec:
name: search_google
description: Search Google using the Custom Search API.
parameters:
type: object
properties:
query:
type: string
description: The search query.
required:
- query
function:
type: rest
resource_template: "https://www.googleapis.com/customsearch/v1?key=[GOOGLE_API_KEY]&cx=[GOOGLE_PROGRAMMING_SEARCH_ENGINE]:omuauf_lfve&q={{ query }}&num=3"
value_template: >-
{% if value_json.items %}
```csv
title,link
{% for item in value_json.items %}
"{{ item.title | replace(',', ' ') }}","{{ item.link }}"
{% endfor %}
```
{% else %}
No results found,
{% endif %}
```
28 changes: 28 additions & 0 deletions examples/function/weather/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Objective
- Get current weather and forecasts

<img width="300" src="https://github.com/jekalmin/extended_openai_conversation/assets/2917984/177f416e-2194-4a10-a3f6-39a94da942ce">
<img width="300" src="https://github.com/jekalmin/extended_openai_conversation/assets/2917984/3c861f37-3654-4f6b-bcbf-554f12189051">

## Prerequisite
Expose `weather.xxxxx` entity

## Function

### get_attributes
```yaml
- spec:
name: get_attributes
description: Get attributes of any home assistant entity
parameters:
type: object
properties:
entity_id:
type: string
description: entity_id
required:
- entity_id
function:
type: template
value_template: "{{states[entity_id]}}"
```

0 comments on commit 7d6efa5

Please sign in to comment.