You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+92-1Lines changed: 92 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,8 @@ An Free & Unlimited unofficial Python SDK for the OpenAI API, providing seamless
21
21
-[Chat Completion with Audio Preview Model](#chat-completion-with-audio-preview-model)
22
22
-[Image Generation](#image-generation)
23
23
-[Audio Speech Recognition with Whisper Model](#audio-speech-recognition-with-whisper-model)
24
+
-[Function Calling and Tool Usage](#function-calling-and-tool-usage)
25
+
-[Basic Function Calling](#basic-function-calling)
24
26
-[Contributing](#contributing)
25
27
-[License](#license)
26
28
@@ -45,7 +47,7 @@ An Free & Unlimited unofficial Python SDK for the OpenAI API, providing seamless
45
47
Install the package via pip:
46
48
47
49
```bash
48
-
pip install openai-unofficial
50
+
pip install -U openai-unofficial
49
51
```
50
52
51
53
---
@@ -203,6 +205,95 @@ with open("speech.mp3", "rb") as audio_file:
203
205
print("Transcription:", transcription.text)
204
206
```
205
207
208
+
### Function Calling and Tool Usage
209
+
210
+
The SDK supports OpenAI's function calling capabilities, allowing you to define and use tools/functions in your conversations. Here are examples of function calling & tool usage:
211
+
212
+
#### Basic Function Calling
213
+
214
+
> ⚠️ **Important Note**: In the current version (0.1.2), complex or multiple function calling is not yet fully supported. The SDK currently supports basic function calling capabilities. Support for multiple function calls and more complex tool usage patterns will be added in upcoming releases.
215
+
216
+
```python
217
+
from openai_unofficial import OpenAIUnofficial
218
+
import json
219
+
220
+
client = OpenAIUnofficial()
221
+
222
+
# Define your functions as tools
223
+
tools = [
224
+
{
225
+
"type": "function",
226
+
"function": {
227
+
"name": "get_current_weather",
228
+
"description": "Get the current weather in a given location",
229
+
"parameters": {
230
+
"type": "object",
231
+
"properties": {
232
+
"location": {
233
+
"type": "string",
234
+
"description": "The city and state, e.g., San Francisco, CA"
0 commit comments