Skip to main content

The official Python library for the nexusflowai API

Project description

NexusflowAI Python API library

PyPI version

Welcome to the NexusflowAI API by Nexusflow.ai!

pip install nexusflowai

This package is based on and extends from the OpenAI Python Library. Cheers to the OpenAI team for an amazing API library and SDK!

Usage

Completions

from nexusflowai import NexusflowAI


nf = NexusflowAI(api_key="<api key>")


response = nf.completions.create(
    model="nexus-tool-use-20240816",
    prompt="""Function:
def get_weather(city_name: str):
\"\"\"
\"\"\"


User Query: i am in berkeley.<human_end>Call:""",
    stop=["<bot_end>"],
    max_tokens=10,
)
print(response)

ChatCompletions with Tools

from nexusflowai import NexusflowAI


nf = NexusflowAI(api_key="<api key>")


response = nf.chat.completions.create(
    model="nexus-tool-use-20240816",
    messages=[
        {
            "role": "user",
            "content": "i am in berkeley.",
        },
    ],
    tools=[
        {
            "type": "function",
            "function": {
                "name": "get_weather",
                "description": "",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "city_name": {
                            "type": "string",
                            "description": "",
                        },
                    },
                    "required": ["city_name"],
                    "additionalProperties": False,
                }
            }
        }
    ],
)
print(response)

ChatCompletions with Structured Outputs

from typing import List, Dict, Tuple

from pydantic import BaseModel, Field

from nexusflowai import NexusflowAI


nf = NexusflowAI(api_key="<api key>")


class GasDistributionNetwork(BaseModel):
    networkID: str = Field(
        ...,
        description="The identifier for the gas distribution network.",
        title="Network ID",
    )
    pipelineValues: Dict[str, Tuple[int, int]] = Field(
        description="The mapping with key pipeline_1, pipeline_2, etc ... to tuple of (total length in kilometers, maximum amount of gas that can be distributed in cubic meters).",
        title="Pipeline Values",
    )
    maintenanceSchedules: List[str] = Field(
        ...,
        description="The schedule detailing when maintenance activities are to be performed.",
        title="Maintenance Schedule",
    )


response = nf.chat.completions.create(
    model="nexus-tool-use-20240816",
    messages=[
        {
            "role": "user",
            "content": """I am currently working on a project that involves mapping out a gas distribution network for a new residential area. The network is quite extensive and includes several pipelines that distribute natural gas to various sectors of the community. I need to create a JSON object that captures the essential details of this network. The information I have includes a unique identifier for the network, which is 'GDN-4521'. The total length of the pipeline_1 is 275 kilometers with a capacity 500,000 cubic meters. Pipeline 2 is 17 kilometers long and has a capacity of 12,000 cubic meters. Additionally, there is a detailed maintenance schedule, which includes quarterly inspections in January, April, July, and October.""",
        },
    ],
    response_format=GasDistributionNetwork,
)
print(response.raw_prompt)
print(response.choices[0].message.parsed)

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

nexusflowai-0.1.3.tar.gz (161.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nexusflowai-0.1.3-py3-none-any.whl (46.4 kB view details)

Uploaded Python 3

File details

Details for the file nexusflowai-0.1.3.tar.gz.

File metadata

  • Download URL: nexusflowai-0.1.3.tar.gz
  • Upload date:
  • Size: 161.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for nexusflowai-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1e3d7d267e31766d0336baacaaa2d87e9d2c4be69bfe753426b43b602041451a
MD5 26974c9e4c5784216f7fdc2f39c708c5
BLAKE2b-256 220710b993c627ac66515970b039e3d9aba4f641eb1447937527fa8959731a87

See more details on using hashes here.

File details

Details for the file nexusflowai-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: nexusflowai-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 46.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for nexusflowai-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7b5badd5413ec3e6785462029b3756985a6d537df1880f83b31c48ab0a736521
MD5 64c1fbe1270a336448cb5726e9df4ba0
BLAKE2b-256 c200e00dace826a8c79a78478fdb64709cd262e82d86c05ecda4bf9319c8cec1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page