Skip to content

Commit 8541b3a

Browse files
Update openapi
1 parent a4efe9e commit 8541b3a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2584
-333
lines changed

examples/poet_chat/main.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,28 @@
22

33
from poet_chat.agent import poet_runner
44
from poet_chat.config import (
5-
PEER_OPTIONS,
5+
AGENT_OPTIONS,
66
fishjam_client,
77
)
88
from poet_chat.notifier import make_notifier
99

10-
from fishjam.agent import AudioTrackOptions
10+
from fishjam.agent import OutgoingAudioTrackOptions
1111

1212

1313
async def main():
1414
room = fishjam_client.create_room()
15-
_, token = fishjam_client.create_peer(room.id, PEER_OPTIONS)
15+
_, token = fishjam_client.create_peer(room.id)
1616
print(f"Join the chat with the following token: {token}")
1717

18-
agent = fishjam_client.create_agent(room.id)
18+
agent = fishjam_client.create_agent(room.id, AGENT_OPTIONS)
1919
async with (
2020
agent.connect() as fishjam_session,
2121
await poet_runner.run() as openai_session,
2222
):
2323
track = await fishjam_session.add_track(
24-
AudioTrackOptions(sample_rate=24000, metadata={"type": "microphone"})
24+
OutgoingAudioTrackOptions(
25+
sample_rate=24000, metadata={"type": "microphone"}
26+
)
2527
)
2628

2729
async def _openai_recv():

examples/poet_chat/poet_chat/config.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
import os
22
from pathlib import Path
33

4-
from fishjam import FishjamClient, PeerOptions
5-
from fishjam.peer import SubscribeOptions, SubscribeOptionsAudioSampleRate
4+
from fishjam import AgentOptions, AgentOutputOptions, FishjamClient
65

76
FISHJAM_ID = os.environ["FISHJAM_ID"]
87
FISHJAM_TOKEN = os.environ["FISHJAM_MANAGEMENT_TOKEN"]
98
FISHJAM_URL = os.getenv("FISHJAM_URL")
109

11-
PEER_OPTIONS = PeerOptions(
12-
subscribe=SubscribeOptions(
13-
audio_sample_rate=SubscribeOptionsAudioSampleRate.VALUE_24000
14-
)
15-
)
10+
AGENT_OPTIONS = AgentOptions(output=AgentOutputOptions(audio_sample_rate=24000))
1611

1712
OPENAI_MODEL = "gpt-realtime"
1813

examples/transcription/main.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
from transcription.room import RoomService, fishjam
77
from transcription.worker import async_worker
88

9-
from fishjam import PeerOptions
10-
from fishjam.peer import SubscribeOptions
11-
129
_room_service: RoomService | None = None
1310

1411

@@ -34,8 +31,5 @@ async def lifespan(_app: FastAPI):
3431

3532
@app.get("/")
3633
def get_peer(room_service: Annotated[RoomService, Depends(get_room_service)]):
37-
_peer, token = fishjam.create_peer(
38-
room_service.get_room().id,
39-
PeerOptions(subscribe=SubscribeOptions()),
40-
)
34+
_peer, token = fishjam.create_peer(room_service.get_room().id)
4135
return token

fishjam/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
from fishjam._webhook_notifier import receive_binary
1818
from fishjam._ws_notifier import FishjamNotifier
1919
from fishjam.api._fishjam_client import (
20+
AgentOptions,
21+
AgentOutputOptions,
2022
FishjamClient,
2123
Peer,
2224
PeerOptions,
@@ -31,6 +33,8 @@
3133
"PeerMetadata",
3234
"PeerOptions",
3335
"RoomOptions",
36+
"AgentOptions",
37+
"AgentOutputOptions",
3438
"Room",
3539
"Peer",
3640
"events",
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
from http import HTTPStatus
2+
from typing import Any, Optional, Union, cast
3+
4+
import httpx
5+
6+
from ... import errors
7+
from ...client import AuthenticatedClient, Client
8+
from ...models.error import Error
9+
from ...types import UNSET, Response, Unset
10+
11+
12+
def _get_kwargs(
13+
room_id: str,
14+
id: str,
15+
*,
16+
peer_id: Union[Unset, str] = UNSET,
17+
) -> dict[str, Any]:
18+
params: dict[str, Any] = {}
19+
20+
params["peer_id"] = peer_id
21+
22+
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
23+
24+
_kwargs: dict[str, Any] = {
25+
"method": "post",
26+
"url": "/room/{room_id}/peer/{id}/subscribe_peer".format(
27+
room_id=room_id,
28+
id=id,
29+
),
30+
"params": params,
31+
}
32+
33+
return _kwargs
34+
35+
36+
def _parse_response(
37+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
38+
) -> Optional[Union[Any, Error]]:
39+
if response.status_code == 200:
40+
response_200 = cast(Any, None)
41+
return response_200
42+
if response.status_code == 400:
43+
response_400 = Error.from_dict(response.json())
44+
45+
return response_400
46+
if response.status_code == 401:
47+
response_401 = Error.from_dict(response.json())
48+
49+
return response_401
50+
if response.status_code == 404:
51+
response_404 = Error.from_dict(response.json())
52+
53+
return response_404
54+
if response.status_code == 503:
55+
response_503 = Error.from_dict(response.json())
56+
57+
return response_503
58+
if client.raise_on_unexpected_status:
59+
raise errors.UnexpectedStatus(response.status_code, response.content)
60+
else:
61+
return None
62+
63+
64+
def _build_response(
65+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
66+
) -> Response[Union[Any, Error]]:
67+
return Response(
68+
status_code=HTTPStatus(response.status_code),
69+
content=response.content,
70+
headers=response.headers,
71+
parsed=_parse_response(client=client, response=response),
72+
)
73+
74+
75+
def sync_detailed(
76+
room_id: str,
77+
id: str,
78+
*,
79+
client: AuthenticatedClient,
80+
peer_id: Union[Unset, str] = UNSET,
81+
) -> Response[Union[Any, Error]]:
82+
"""Subscribe peer to another peer's tracks
83+
84+
Args:
85+
room_id (str):
86+
id (str):
87+
peer_id (Union[Unset, str]):
88+
89+
Raises:
90+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
91+
httpx.TimeoutException: If the request takes longer than Client.timeout.
92+
93+
Returns:
94+
Response[Union[Any, Error]]
95+
"""
96+
97+
kwargs = _get_kwargs(
98+
room_id=room_id,
99+
id=id,
100+
peer_id=peer_id,
101+
)
102+
103+
response = client.get_httpx_client().request(
104+
**kwargs,
105+
)
106+
107+
return _build_response(client=client, response=response)
108+
109+
110+
def sync(
111+
room_id: str,
112+
id: str,
113+
*,
114+
client: AuthenticatedClient,
115+
peer_id: Union[Unset, str] = UNSET,
116+
) -> Optional[Union[Any, Error]]:
117+
"""Subscribe peer to another peer's tracks
118+
119+
Args:
120+
room_id (str):
121+
id (str):
122+
peer_id (Union[Unset, str]):
123+
124+
Raises:
125+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
126+
httpx.TimeoutException: If the request takes longer than Client.timeout.
127+
128+
Returns:
129+
Union[Any, Error]
130+
"""
131+
132+
return sync_detailed(
133+
room_id=room_id,
134+
id=id,
135+
client=client,
136+
peer_id=peer_id,
137+
).parsed
138+
139+
140+
async def asyncio_detailed(
141+
room_id: str,
142+
id: str,
143+
*,
144+
client: AuthenticatedClient,
145+
peer_id: Union[Unset, str] = UNSET,
146+
) -> Response[Union[Any, Error]]:
147+
"""Subscribe peer to another peer's tracks
148+
149+
Args:
150+
room_id (str):
151+
id (str):
152+
peer_id (Union[Unset, str]):
153+
154+
Raises:
155+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
156+
httpx.TimeoutException: If the request takes longer than Client.timeout.
157+
158+
Returns:
159+
Response[Union[Any, Error]]
160+
"""
161+
162+
kwargs = _get_kwargs(
163+
room_id=room_id,
164+
id=id,
165+
peer_id=peer_id,
166+
)
167+
168+
response = await client.get_async_httpx_client().request(**kwargs)
169+
170+
return _build_response(client=client, response=response)
171+
172+
173+
async def asyncio(
174+
room_id: str,
175+
id: str,
176+
*,
177+
client: AuthenticatedClient,
178+
peer_id: Union[Unset, str] = UNSET,
179+
) -> Optional[Union[Any, Error]]:
180+
"""Subscribe peer to another peer's tracks
181+
182+
Args:
183+
room_id (str):
184+
id (str):
185+
peer_id (Union[Unset, str]):
186+
187+
Raises:
188+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
189+
httpx.TimeoutException: If the request takes longer than Client.timeout.
190+
191+
Returns:
192+
Union[Any, Error]
193+
"""
194+
195+
return (
196+
await asyncio_detailed(
197+
room_id=room_id,
198+
id=id,
199+
client=client,
200+
peer_id=peer_id,
201+
)
202+
).parsed

0 commit comments

Comments
 (0)