Skip to content

Commit 5f3bf93

Browse files
merge
2 parents 81596f7 + 7307436 commit 5f3bf93

3 files changed

Lines changed: 56 additions & 241 deletions

File tree

.github/workflows/release.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,25 @@ on:
66
- "v*"
77

88
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Install uv
14+
uses: astral-sh/setup-uv@v4
15+
with:
16+
enable-cache: true
17+
- run: uv python install 3.12
18+
- run: uv sync --all-extras
19+
- run: uv run ruff format --check .
20+
- run: uv run ruff check .
21+
- run: uv run pytest
22+
923
release:
24+
needs: test
1025
runs-on: ubuntu-latest
1126
permissions:
12-
id-token: write # Required for trusted publishing
27+
id-token: write
1328

1429
steps:
1530
- uses: actions/checkout@v4
@@ -27,4 +42,3 @@ jobs:
2742

2843
- name: Publish to PyPI
2944
uses: pypa/gh-action-pypi-publish@release/v1
30-

README.md

Lines changed: 39 additions & 238 deletions
Original file line numberDiff line numberDiff line change
@@ -1,283 +1,84 @@
1-
# Edgee Gateway SDK
1+
# Edgee Python SDK
22

3-
Lightweight Python SDK for Edgee AI Gateway with built-in tool execution support.
3+
Lightweight, type-safe Python SDK for the [Edgee AI Gateway](https://www.edgee.cloud).
4+
5+
[![PyPI version](https://img.shields.io/pypi/v/edgee.svg)]( )
6+
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
47

58
## Installation
69

710
```bash
811
pip install edgee
912
```
1013

11-
## Usage
14+
## Quick Start
1215

1316
```python
1417
import os
1518
from edgee import Edgee
1619

17-
edgee = Edgee(os.environ.get("EDGEE_API_KEY"))
18-
```
19-
20-
### Simple Input
20+
edgee = Edgee("your-api-key")
2121

22-
```python
22+
# Send a simple request
2323
response = edgee.send(
2424
model="gpt-4o",
25-
input="What is the capital of France?",
25+
input="What is the capital of France?"
2626
)
2727

2828
print(response.text)
29+
# "The capital of France is Paris."
2930
```
3031

31-
### Full Input with Messages
32-
33-
```python
34-
response = edgee.send(
35-
model="gpt-4o",
36-
input={
37-
"messages": [
38-
{"role": "system", "content": "You are a helpful assistant."},
39-
{"role": "user", "content": "Hello!"},
40-
],
41-
},
42-
)
43-
```
32+
## Send Method
4433

45-
## Tools
46-
47-
The SDK supports two modes for working with tools:
48-
49-
### Simple Mode: Automatic Tool Execution
50-
51-
Use the `Tool` class with Pydantic models for automatic tool execution. The SDK will handle the entire agentic loop for you:
34+
The `send()` method makes non-streaming chat completion requests:
5235

5336
```python
54-
from pydantic import BaseModel
55-
from edgee import Edgee, Tool
56-
57-
edgee = Edgee(os.environ.get("EDGEE_API_KEY"))
58-
59-
# Define tool parameters with Pydantic
60-
class WeatherParams(BaseModel):
61-
location: str
62-
63-
# Define the tool handler
64-
def get_weather(params: WeatherParams) -> dict:
65-
# Your implementation here
66-
return {"temperature": 22, "condition": "sunny", "location": params.location}
67-
68-
# Create the tool
69-
weather_tool = Tool(
70-
name="get_weather",
71-
description="Get the current weather for a location",
72-
schema=WeatherParams,
73-
handler=get_weather,
74-
)
75-
76-
# The SDK automatically:
77-
# 1. Sends the request with tools
78-
# 2. Executes tools when the model requests them
79-
# 3. Sends results back to the model
80-
# 4. Returns the final response
8137
response = edgee.send(
8238
model="gpt-4o",
83-
input="What's the weather in Paris?",
84-
tools=[weather_tool],
39+
input="Hello, world!"
8540
)
8641

87-
print(response.text)
88-
# "The weather in Paris is sunny with a temperature of 22°C."
42+
# Access response
43+
print(response.text) # Text content
44+
print(response.finish_reason) # Finish reason
45+
print(response.tool_calls) # Tool calls (if any)
8946
```
9047

91-
#### Multiple Tools
92-
93-
```python
94-
from typing import Literal
95-
from pydantic import BaseModel
96-
97-
class CalculatorParams(BaseModel):
98-
operation: Literal["add", "subtract", "multiply", "divide"]
99-
a: float
100-
b: float
101-
102-
def calculate(params: CalculatorParams) -> dict:
103-
ops = {
104-
"add": params.a + params.b,
105-
"subtract": params.a - params.b,
106-
"multiply": params.a * params.b,
107-
"divide": params.a / params.b if params.b != 0 else "Error: division by zero",
108-
}
109-
return {"result": ops[params.operation]}
48+
## Stream Method
11049

111-
calculator_tool = Tool(
112-
name="calculate",
113-
description="Perform arithmetic operations",
114-
schema=CalculatorParams,
115-
handler=calculate,
116-
)
117-
118-
response = edgee.send(
119-
model="gpt-4o",
120-
input="What's 25 * 4, and what's the weather in London?",
121-
tools=[weather_tool, calculator_tool],
122-
)
123-
```
124-
125-
#### Configuration Options
50+
The `stream()` method enables real-time streaming responses:
12651

12752
```python
128-
response = edgee.send(
129-
model="gpt-4o",
130-
input="Complex query requiring multiple tool calls",
131-
tools=[tool1, tool2],
132-
max_tool_iterations=15, # Default: 10
133-
)
134-
```
135-
136-
### Advanced Mode: Manual Tool Handling
137-
138-
For full control over tool execution, use the advanced mode with raw tool definitions:
139-
140-
```python
141-
response = edgee.send(
142-
model="gpt-4o",
143-
input={
144-
"messages": [{"role": "user", "content": "What's the weather in Paris?"}],
145-
"tools": [
146-
{
147-
"type": "function",
148-
"function": {
149-
"name": "get_weather",
150-
"description": "Get weather for a location",
151-
"parameters": {
152-
"type": "object",
153-
"properties": {
154-
"location": {"type": "string"},
155-
},
156-
},
157-
},
158-
},
159-
],
160-
"tool_choice": "auto",
161-
},
162-
)
163-
164-
# Handle tool calls manually
165-
if response.tool_calls:
166-
print(response.tool_calls)
167-
# Execute tools and send results back...
168-
```
169-
170-
## Streaming
171-
172-
```python
173-
for chunk in edgee.stream(model="gpt-4o", input="Tell me a story"):
53+
for chunk in edgee.stream("gpt-4o", "Tell me a story"):
17454
if chunk.text:
17555
print(chunk.text, end="", flush=True)
176-
```
17756

178-
#### Alternative: Using send(stream=True)
179-
180-
```python
181-
for chunk in edgee.send(model="gpt-4o", input="Tell me a story", stream=True):
182-
if chunk.text:
183-
print(chunk.text, end="", flush=True)
57+
if chunk.finish_reason:
58+
print(f"\nFinished: {chunk.finish_reason}")
18459
```
18560

186-
## Response
61+
## Features
18762

188-
```python
189-
@dataclass
190-
class SendResponse:
191-
choices: list[Choice]
192-
usage: Usage | None
63+
-**Type-safe** - Full type hints with dataclasses
64+
-**OpenAI-compatible** - Works with any model supported by Edgee
65+
-**Streaming** - Real-time response streaming with generators
66+
-**Tool calling** - Full support for function calling
67+
-**Flexible input** - Accept strings, dicts, or InputObject
68+
-**Zero dependencies** - Uses only Python standard library
19369

194-
# Convenience properties
195-
text: str | None # choices[0].message["content"]
196-
message: dict | None # choices[0].message
197-
finish_reason: str | None # choices[0].finish_reason
198-
tool_calls: list | None # choices[0].message["tool_calls"]
70+
## Documentation
19971

200-
@dataclass
201-
class Choice:
202-
index: int
203-
message: dict # {"role": str, "content": str | None, "tool_calls": list | None}
204-
finish_reason: str | None
72+
For complete documentation, examples, and API reference, visit:
20573

206-
@dataclass
207-
class InputTokenDetails:
208-
cached_tokens: int
74+
**👉 [Official Python SDK Documentation](https://www.edgee.cloud/docs/sdk/python)**
20975

210-
@dataclass
211-
class OutputTokenDetails:
212-
reasoning_tokens: int
76+
The documentation includes:
77+
- [Configuration guide](https://www.edgee.cloud/docs/sdk/python/configuration) - Multiple ways to configure the SDK
78+
- [Send method](https://www.edgee.cloud/docs/sdk/python/send) - Complete guide to non-streaming requests
79+
- [Stream method](https://www.edgee.cloud/docs/sdk/python/stream) - Streaming responses guide
80+
- [Tools](https://www.edgee.cloud/docs/sdk/python/tools) - Function calling guide
21381

214-
@dataclass
215-
class Usage:
216-
prompt_tokens: int
217-
completion_tokens: int
218-
total_tokens: int
219-
input_tokens_details: InputTokenDetails
220-
output_tokens_details: OutputTokenDetails
221-
```
222-
223-
### Streaming Response
224-
225-
```python
226-
@dataclass
227-
class StreamChunk:
228-
choices: list[StreamChoice]
82+
## License
22983

230-
# Convenience properties
231-
text: str | None # choices[0].delta.content
232-
role: str | None # choices[0].delta.role
233-
finish_reason: str | None # choices[0].finish_reason
234-
235-
@dataclass
236-
class StreamChoice:
237-
index: int
238-
delta: StreamDelta
239-
finish_reason: str | None
240-
241-
@dataclass
242-
class StreamDelta:
243-
role: str | None
244-
content: str | None
245-
tool_calls: list[dict] | None
246-
```
247-
248-
## API Reference
249-
250-
### `Tool` Class
251-
252-
```python
253-
from pydantic import BaseModel
254-
from edgee import Tool
255-
256-
class MyParams(BaseModel):
257-
param1: str
258-
param2: int
259-
260-
tool = Tool(
261-
name="my_tool", # Unique tool name
262-
description="...", # Tool description for the model
263-
schema=MyParams, # Pydantic model for parameters
264-
handler=my_function, # Function to execute
265-
)
266-
267-
# Methods
268-
tool.to_dict() # Convert to OpenAI tool format
269-
tool.execute(args) # Validate and execute handler
270-
```
271-
272-
### `create_tool` Helper
273-
274-
```python
275-
from edgee import create_tool
276-
277-
tool = create_tool(
278-
name="my_tool",
279-
schema=MyParams,
280-
handler=my_function,
281-
description="...",
282-
)
283-
```
84+
Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "edgee"
3-
version = "0.1.1"
3+
version = "1.0.0"
44
description = "Lightweight Python SDK for Edgee AI Gateway"
55
readme = "README.md"
66
license = "Apache-2.0"

0 commit comments

Comments
 (0)