A Python client for the Interlify API
Project description
Interlify Client
A Python client for the Interlify API.
Installation
Install via pip:
pip install interlify
Usage:
from openai import OpenAI
from interlify import Interlify
client = OpenAI()
# Initialize the client
interlify = Interlify(
api_key="YOUR_API_KEY",
project_id="YOUR_PROJECT_ID",
auth_headers=[
{"Authorization": "Bearer YOUR_TOKEN"}
]
)
# Prepare tools
tools = client.tools()
completion = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "What is the weather like in Paris today?"}],
# Use tools
tools=tools
)
response_message = response.choices[0].message
tool_calls = response_message.tool_calls
messages.append(response_message)
for tool_call in tool_calls:
function_name = tool_call.function.name
function_args = json.loads(tool_call.function.arguments)
# Call the tool using interlify
function_response = interlify.call_tool(function_name, function_args)
print(f"function_response: {function_response}")
messages.append(
{
"role": "tool",
"content": str(function_response),
"tool_call_id": tool_call.id,
}
)
final_response = client.chat.completions.create(
model=model, messages=messages, tools=tools, tool_choice="auto"
)
print(final_response.choices[0].message.content)
To setup the tools and projects, please visit to interlify website.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
interlify-1.0.3.tar.gz
(3.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file interlify-1.0.3.tar.gz.
File metadata
- Download URL: interlify-1.0.3.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d13816bb4c74af28ad20b60e21fe2c169c57be38d29c66f3bc5e122bafa6bf5
|
|
| MD5 |
2c2a521db27e01a86558798e560fe723
|
|
| BLAKE2b-256 |
6f67b5524fc5de854b9b3ab3b4d06f0d575d341051d1757bd1c959962001ef8d
|
File details
Details for the file interlify-1.0.3-py3-none-any.whl.
File metadata
- Download URL: interlify-1.0.3-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56b5f338801a4ad5bdcfeca5d5014ef0c2c2f961e295a730103b1ea7ec10fbe9
|
|
| MD5 |
5f2bbdc0c9eb2379514a93128fbc39d2
|
|
| BLAKE2b-256 |
0055f63ab13b2340cd2d8571f36af1a3c8608ad2872874cb1f1e0ea3d91da893
|