@@ -24,7 +24,7 @@ response = edgee.send(
2424 input = " What is the capital of France?" ,
2525)
2626
27- print (response.choices[ 0 ].message[ " content " ] )
27+ print (response.text )
2828```
2929
3030### Full Input with Messages
@@ -67,8 +67,40 @@ response = edgee.send(
6767 },
6868)
6969
70- if response.choices[0 ].message.get(" tool_calls" ):
71- print (response.choices[0 ].message[" tool_calls" ])
70+ if response.tool_calls:
71+ print (response.tool_calls)
72+ ```
73+
74+ ### Streaming
75+
76+ Access chunk properties for streaming:
77+
78+ ``` python
79+ for chunk in edgee.stream(model = " gpt-4o" , input = " Tell me a story" ):
80+ if chunk.text:
81+ print (chunk.text, end = " " , flush = True )
82+ ```
83+
84+ #### Alternative: Using send(stream=True)
85+
86+ ``` python
87+ for chunk in edgee.send(model = " gpt-4o" , input = " Tell me a story" , stream = True ):
88+ if chunk.text:
89+ print (chunk.text, end = " " , flush = True )
90+ ```
91+
92+ #### Accessing Full Chunk Data
93+
94+ When you need complete access to the streaming response:
95+
96+ ``` python
97+ for chunk in edgee.stream(model = " gpt-4o" , input = " Hello" ):
98+ if chunk.role:
99+ print (f " Role: { chunk.role} " )
100+ if chunk.text:
101+ print (chunk.text, end = " " , flush = True )
102+ if chunk.finish_reason:
103+ print (f " \n Finish: { chunk.finish_reason} " )
72104```
73105
74106## Response
@@ -79,6 +111,12 @@ class SendResponse:
79111 choices: list[Choice]
80112 usage: Optional[Usage]
81113
114+ # Convenience properties for easy access
115+ text: str | None # Shortcut for choices[0].message["content"]
116+ message: dict | None # Shortcut for choices[0].message
117+ finish_reason: str | None # Shortcut for choices[0].finish_reason
118+ tool_calls: list | None # Shortcut for choices[0].message["tool_calls"]
119+
82120@dataclass
83121class Choice :
84122 index: int
@@ -91,3 +129,30 @@ class Usage:
91129 completion_tokens: int
92130 total_tokens: int
93131```
132+
133+ ### Streaming Response
134+
135+ ``` python
136+ @dataclass
137+ class StreamChunk :
138+ choices: list[StreamChoice]
139+
140+ # Convenience properties for easy access
141+ text: str | None # Shortcut for choices[0].delta.content
142+ role: str | None # Shortcut for choices[0].delta.role
143+ finish_reason: str | None # Shortcut for choices[0].finish_reason
144+
145+ @dataclass
146+ class StreamChoice :
147+ index: int
148+ delta: StreamDelta
149+ finish_reason: str | None
150+
151+ @dataclass
152+ class StreamDelta :
153+ role: str | None # Only present in first chunk
154+ content: str | None
155+ tool_calls: list[dict ] | None
156+ ```
157+
158+ To learn more about this SDK, please refer to the [ dedicated documentation] ( https://www.edgee.cloud/docs/sdk/python ) .
0 commit comments