Skip to main content

Smart g4f provider selector

Project description

SmartG4F

View on GitHub

A python package that selects g4f providers for you.

Use pip install smartg4f to install the package

Instead of supplying a provider, enter await get_provider(). This function will validate each g4f provider and return a RetryProvider list

import g4f
from smartg4f import get_provider

response = g4f.ChatCompletion.create(
    model=model,
    provider=await get_provider(),
    messages=messages,
)
get_provider(
    prompt: String #Prompt that tests the providers (Default: "Say hello")
    validation: Function #Validation function (Default: returns True if the output is of type str)
    model: ModelType #(Default: gpt-4o)
    timeout: Integer #When a provider is too slow (Default: 15 seconds)
    log: Boolean #Log providers
)

# Example usage
get_provider(
    prompt="How is the weather today?",
    model="gpt-4",
    timeout=5,
    log=False,
)

Troubleshooting

  1. Use await get_provider()
  2. Use async in function
  3. If outside a function, use asyncio.run()
  4. Make sure you have g4f installed

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

smartg4f-1.1.1.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

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

smartg4f-1.1.1-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

Details for the file smartg4f-1.1.1.tar.gz.

File metadata

  • Download URL: smartg4f-1.1.1.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.0

File hashes

Hashes for smartg4f-1.1.1.tar.gz
Algorithm Hash digest
SHA256 8c9ad1f55e5b3d1330cd478a648bfe29c585fa143a612af622a22a68b82f6d58
MD5 2e96874472df651dbe986bcf62da00e5
BLAKE2b-256 fa5d50fca881f10879756dac6914f207ae338d2a57350502cd77db75e5443774

See more details on using hashes here.

File details

Details for the file smartg4f-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: smartg4f-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.0

File hashes

Hashes for smartg4f-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dc340156854381415e41b4418cd1ad99f5f462d2083966f19c537142f6babb7e
MD5 407028537ac3c244f362ae522fa76e6e
BLAKE2b-256 22849b4c96a64d49c8d118f73a3e50b9b61170159c0b0e68a5b89509aa8a2517

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