-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect example in the documentation #126
Comments
Thanks for reporting an issue! This was intended that asking weather can be achieved using |
What weather services do you use? I am getting false returns from both weather.openweathermap and weather.pirateweather |
Although I'm using naver_weather which is designed to support Korea only, ![]() Have you exposed |
It is exposed and says that it is referencing the correct Entity when I ask where it derived it's data from. But it keeps giving 25F (-4C) as the forecasted temperature for any request (Example: What will the temp be at 7am tomorrow / What will the coldest day be next week?) when the temps are more in the 60F (15C) range. |
Update: |
Further update: That wasn't the issue the symptom has returned. Assist: How can I assist? Me: What will the temp be at 8am tomorrow? Assist:I'm unable to provide the weather forecast for tomorrow at 8 am without access to an external weather service. If you have a weather sensor integrated into your smart home system, I can retrieve the current temperature for you. Me: why didn't you use weather.openweathermap? Assist: My apologies for the oversight. The forecasted temperature for tomorrow at 8 am is approximately 62.73°F based on the OpenWeatherMap integration in your smart home system. It is giving me the current weather. Sometimes it will look at the forecast and other times return current temp as forecasted temp. |
When asked about forecast, it seems gpt doesn't call I think this is because gpt calls date or time relevent functions if exist rather than calls |
use this as a function. Seems to work for me where there are updated weather services to the new HA spec where service call to get_forecasts is needed:
For reference, im using Pirate Weather as my weather service. |
Could you repost that with the code function to keep formatting? |
I think if you have it copied with the formatting (say from your notepad++) then it keeps that formatting if you select code block. |
that didnt work but i did figure it out. 3 ticks on each end
|
good to hear!
|
@TBTHEDBA can you test something? when i do it i get a WILD token error: |
Same response as you.
…On Thu, Feb 15, 2024 at 2:55 PM Scags ***@***.***> wrote:
@TBTHEDBA <https://github.com/TBTHEDBA> can you test something?
Ask it "what is the weather in 3 hours"
when i do it i get a WILD token error:
Sorry, I had a problem talking to OpenAI: Error code: 400 - {'error':
{'message': "This model's maximum context length is 16385 tokens. However,
your messages resulted in 23954 tokens (23269 in the messages, 685 in the
functions). Please reduce the length of the messages or functions.",
'type': 'invalid_request_error', 'param': 'messages', 'code':
'context_length_exceeded'}}
—
Reply to this email directly, view it on GitHub
<#126 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJXIGPWPJTDTSHJK5YTKQCLYTZY2LAVCNFSM6AAAAABCRH2AMKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBXGMZDINRYGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@jekalmin can you comment on what the issue may be given the function posted above and the token error? Thanks |
I switched the model to gpt-4-0125-preview and got the proper response back. |
tried that model but get a different error now:
|
Thanks @Scags104 for your help! I wasn't aware that
Since we need only one row of data, we have to narrow all hourly data into one to reduce token size. - spec:
name: get_weather_forecast
description: get weather forecast
parameters:
type: object
properties:
datetime:
type: string
description: The date time like "2024-02-16T14:00:00+00:00".
type:
type: string
description: the type of forecast
enum:
- daily
- hourly
required:
- type
function:
type: composite
sequence:
- type: script
sequence:
- service: weather.get_forecasts
data:
type: "{{type}}"
target:
entity_id: weather.pirateweather
response_variable: _function_result
response_variable: result
- type: template
value_template: "{{result['weather.pirateweather'].forecast | selectattr('datetime', 'contains', datetime) | list}}" It should be something like above.
Although it works with hourly forecast, it doesn't work with daily forecast in my case. ![]() |
tried yours with no success either, then i tried limiting yours to hours and mine to days to cover both scenarios, no luck there either. A mix of Tool Errors, script errors, bad yaml errors (of my own making) and not picking up either function at all and telling me it cant predict the weather. Youre definately onto something with the heafty amount of data though. no wonder its not working. |
hourly works great. similarly to your screenshot above, but daily is not working. can not see future daily forecasts do we need 2 separate functions? |
go figure, now its working! Maybe i mistyped something before Thank you! |
Hey guys, Was having some issues with this (would throw an error) when asking something like 'whens it going to rain', please see extra function below which has been modified based on above! This can probably be turned into a composite (daily/hourly/event) but this works for me (requires integration that works with get_forecasts - change below): - spec:
name: get_weather_forecast
description: get weather forecast
parameters:
type: object
properties:
datetime:
type: string
description: The date time like "2024-02-16T14:00:00+00:00".
type:
type: string
description: the type of forecast
enum:
- daily
- hourly
required:
- type
function:
type: composite
sequence:
- type: script
sequence:
- service: weather.get_forecasts
data:
type: "{{type}}"
target:
entity_id: weather.pirateweather
response_variable: _function_result
response_variable: result
- type: template
value_template: >-
{%- set forecasts = result['weather.pirateweather'].forecast | selectattr('datetime', 'contains', as_timestamp(datetime) | timestamp_custom('%Y-%m-%dT%H:00:00+00:00', false, 'UTC')) | list %}
{%- for forecast in forecasts %}
{{ dict(forecast, datetime=forecast.datetime | as_timestamp | timestamp_custom('%Y-%m-%dT%H:%M:%S')) }}
{%- endfor %}
- spec:
name: get_weather_events
description: get forecasted weather events such as rain, thunder, sun, clouds, etc
parameters:
type: object
properties:
event:
type: string
description: The type of weather event such as rain, thunder, sun, clouds, etc.
required:
- event
function:
type: composite
sequence:
- type: script
sequence:
- service: weather.get_forecasts
data:
type: "hourly"
target:
entity_id: weather.pirateweather
response_variable: _function_result
response_variable: result
- type: template
value_template: >-
{%- set forecasts = result['weather.pirateweather'].forecast | selectattr('condition', 'contains', event) | list %}
{%- for forecast in forecasts %}
{{ dict(forecast, datetime=forecast.datetime | as_timestamp | timestamp_custom('%Y-%m-%dT%H:%M:%S')) }}
{%- endfor %} |
In the documentation at:
https://github.com/jekalmin/extended_openai_conversation/blob/main/examples/function/weather/README.md#function
The get_attributes function is pasted instead of weather function.
The text was updated successfully, but these errors were encountered: