The official package of AI-X-Net.
Project description
AIXNet Beta
Overview
AIXNet Beta is a Python package that provides an interface to interact with the OpenAI API. It simplifies the process by requiring only the API key and the payload to get started.
Installation
To install the package, use:
pip install aixnet-beta
Usage
Step 1: Import the OpenAIClient
class
from aixnet_beta.fm import OpenAIClient
Step 2: Initialize the client
Initialize the client with your OpenAI API key.
# Replace 'YOUR_API_KEY' with your actual API key
api_key = "YOUR_API_KEY"
# Initialize the OpenAI client
client = OpenAIClient(api_key)
Step 3: Define the payload
Define the payload for your API request. The payload must be a dictionary that represents the request you want to send to the OpenAI API.
payload = {
"model": "gpt-4o-mini",
"messages": [
{"role": "user", "content": "What is 1+1?"}
],
"temperature": 0.7
}
Step 4: Invoke the API and get the response
Use the invoke_api
method of the OpenAIClient
class to send the request and receive a response.
# Invoke the API and get the response
response = client.invoke_api(payload)
# Print the response from the API
print(json.dumps(response, indent=4))
Example
Here is a complete example of using the OpenAIClient
:
from aixnet_beta.fm import OpenAIClient
import json
# Initialize the OpenAI client with the API key
api_key = "alex123" # Replace with your actual API key
client = OpenAIClient(api_key)
# Define the payload for the request
payload = {
"model": "gpt-3.5-turbo",
"messages": [
{"role": "user", "content": "Say this is a test!"}
],
"temperature": 0.7
}
# Invoke the API and get the response
response = client.invoke_api(payload)
# Print the response from the API
print(json.dumps(response, indent=4))
Alternatively, you can run the code and chat with the foundation model in terminal.
# Initialize the OpenAIClient with the API key
api_key = "alex123" # Replace with your actual API key
chatbot = OpenAIClient(api_key)
# Start the chat session
chatbot.start_chatting()
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aixnet_beta-0.1.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 879ef46267cd80379e3263160509900b5ebab931d17440152237b5c989e37569 |
|
MD5 | 78f35692195cc07cd753b878ba57d038 |
|
BLAKE2b-256 | c5adb5e26a42043d04a88843de4f2c247d9044a9cbc365670403e57e14119947 |