Skip to content

Commit 410f7e3

Browse files
committed
docs: add AI Assistant resource and entities
1 parent fc95cd2 commit 410f7e3

File tree

5 files changed

+73
-9
lines changed

5 files changed

+73
-9
lines changed

docs/02-configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ $api = new OpenWeatherMap('yourapikey', [
7272
> To get to know about all the available methods, make sure to check the documentation [here](https://github.com/programmatordev/php-api-sdk?tab=readme-ov-file#documentation).
7373
7474
The following sections have examples of some of the most important methods,
75-
particularly related with the configuration of the client, cache and logger.
75+
particularly related to the configuration of the client, cache and logger.
7676

7777
### `setClientBuilder`
7878

docs/03-supported-apis.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
- [getWeatherByDate](#getweatherbydate)
77
- [getWeatherSummaryByDate](#getweathersummarybydate)
88
- [getWeatherOverviewByDate](#getweatheroverviewbydate)
9+
- [AI Assistant](#ai-assistant)
10+
- [startSession](#startsession)
11+
- [resumeSession](#resumesession)
912
- [Weather](#weather)
1013
- [getCurrent](#getcurrent)
1114
- [getForecast](#getforecast)
@@ -84,6 +87,36 @@ Returns a [`WeatherOverview`](05-entities.md#weatheroverview) object:
8487
$weatherOverview = $api->oneCall()->getWeatherOverviewByDate(50, 50, new \DateTime('today'));
8588
```
8689

90+
### AI Assistant
91+
92+
#### `startSession`
93+
94+
```php
95+
startSession(string $prompt): Answer
96+
```
97+
98+
Start a new session (create a new conversation) with the Weather AI Assistant.
99+
100+
Returns a [`Answer`](05-entities.md#answer) object:
101+
102+
```php
103+
$answer = $api->assistant()->startSession('How is the weather today in Lisbon?');
104+
```
105+
106+
#### `resumeSession`
107+
108+
```php
109+
resumeSession(string $sessionId, string $prompt): Answer
110+
```
111+
112+
Resume a session (continue a conversation) with the Weather AI Assistant.
113+
114+
Returns a [`Answer`](05-entities.md#answer) object:
115+
116+
```php
117+
$answer = $api->assistant()->resumeSession('session-id', 'Do I need an umbrella?');
118+
```
119+
87120
### Weather
88121

89122
#### `getCurrent`
@@ -192,7 +225,7 @@ $locations = $api->geocoding()->getByLocationName('lisbon');
192225
getByCoordinate(float $latitude, float $longitude, int $numResults = 5): array
193226
```
194227

195-
Get name of the location (city name or area name) by using geographical coordinates (latitude, longitude).
228+
Get the name of the location (city name or area name) by using geographical coordinates (latitude, longitude).
196229

197230
Returns an array of [`Location`](05-entities.md#location) objects.
198231

@@ -261,7 +294,7 @@ withCacheTtl(?int $ttl): self
261294
Makes a request and saves into cache for the provided duration in seconds.
262295

263296
Semantics of values:
264-
- `0`, the response will not be cached (if the servers specifies no `max-age`).
297+
- `0`, the response will not be cached (if the server specifies no `max-age`).
265298
- `null`, the response will be cached for as long as it can (forever).
266299

267300
> [!NOTE]

docs/05-entities.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44
- [Weather](#weather)
55
- [WeatherMoment](#weathermoment)
66
- [WeatherSummary](#weathersummary)
7+
- [WeatherOverview](#weatheroverview)
78
- [WeatherData](#weatherdata)
89
- [MinuteData](#minutedata)
910
- [HourData](#hourdata)
1011
- [DayData](#daydata)
1112
- [Alert](#alert)
1213
- [MoonPhase](#moonphase)
1314
- [Temperature](#temperature)
15+
- [AI Assistant](#ai-assistant)
16+
- [Answer](#answer)
17+
- [WeatherData](#weatherdata-1)
1418
- [Weather](#weather-1)
1519
- [Weather](#weather-2)
1620
- [WeatherCollection](#weathercollection)
17-
- [WeatherData](#weatherdata)
21+
- [WeatherData](#weatherdata-2)
1822
- [Air Pollution](#air-pollution)
1923
- [AirPollution](#airpollution)
2024
- [AirPollutionCollection](#airpollutioncollection)
@@ -171,6 +175,33 @@
171175
- `getMin()`: `?float`
172176
- `getMax()`: `?float`
173177

178+
## AI Assistant
179+
180+
### Answer
181+
182+
- `getAnswer()`: `string`
183+
- `getSessionId()`: `string`
184+
- `getData()`: [`WeatherData[]`](#weatherdata-1)
185+
186+
### WeatherData
187+
188+
- `getLocationName()`: `string`
189+
- `getDateTime()`: `\DateTimeImmutable`
190+
- `getTemperature()`: `float`
191+
- `getTemperatureFeelsLike()`: `float`
192+
- `getAtmosphericPressure()`: `int`
193+
- `getVisibility()`: `?int`
194+
- `getHumidity()`: `int`
195+
- `getDewPoint()`: `float`
196+
- `getUltraVioletIndex()`: `?float`
197+
- `getCloudiness()`: `int`
198+
- `getWind()`: [`Wind`](#wind)
199+
- `getConditions()`: [`Condition[]`](#condition)
200+
- `getRainVolume()`: `?float`
201+
- `getSnowVolume()`: `?float`
202+
- `getSunriseAt()`: `?\DateTimeImmutable`
203+
- `getSunsetAt()`: `?\DateTimeImmutable`
204+
174205
## Weather
175206

176207
### Weather

src/OpenWeatherMap.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ public function __construct(
3939
$this->configureApi();
4040
}
4141

42-
public function assistant(): AssistantResource
42+
public function oneCall(): OneCallResource
4343
{
44-
return new AssistantResource($this);
44+
return new OneCallResource($this);
4545
}
4646

47-
public function oneCall(): OneCallResource
47+
public function assistant(): AssistantResource
4848
{
49-
return new OneCallResource($this);
49+
return new AssistantResource($this);
5050
}
5151

5252
public function weather(): WeatherResource

src/Resource/AssistantResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class AssistantResource extends Resource
1111
{
1212
/**
13-
* Start a new session (create a news conversation) with the Weather AI Assistant
13+
* Start a new session (create a new conversation) with the Weather AI Assistant
1414
*
1515
* @throws ClientExceptionInterface
1616
*/

0 commit comments

Comments
 (0)