Skip to main content

Python client for exam

Project description

AIClient - Python Client for Intelligence.io API

PyPI version Python versions License

AIClient is a Python library that provides a simple interface to interact with Intelligence.io's AI API. It simplifies the process of sending requests to various AI models and handling responses, making it easy to integrate AI capabilities into your Python applications.

Features

  • 🚀 Easy-to-use interface for Intelligence.io API
  • 🤖 Support for multiple AI models
  • 🔑 Secure API key management
  • 🔄 Streamlined model selection process
  • 💬 Simple query-response workflow
  • 🛠️ Error handling and validation

Installation

Install the package using pip:

pip install FuClientForExam

Getting Started

Prerequisites

  1. Sign up for an account at Intelligence.io
  2. Obtain your API key from your account dashboard

Basic Usage

from FuClientForExam import AIClient

# Initialize the client with your API key
client = AIClient(api_key="your_api_key_here")

# Send a query to the AI
response = client.ask_AI("What is the capital of France?")
print(response)

Selecting a Model

# List available models and select one interactively
client.set_model()

# Or set a model directly
client.set_model("deepseek-ai/DeepSeek-R1-0528")

Documentation

AIClient Class

__init__(api_key: str)

Initializes the AI client with your API key.

  • api_key: Your Intelligence.io API key (required)

set_model(model_name: str = None)

Sets the AI model to use. If no model name is provided, it will list available models and prompt for selection.

  • model_name: Optional name of the model to use directly

ask_AI(message: str, raw: bool = False) -> str

Sends a message to the AI and returns the response.

  • message: The text to send to the AI
  • raw: If True, returns the raw response without processing (default: False)
  • Returns: The AI's response as a string

Advanced Usage

Handling Raw Responses

# Get the raw response from the API
raw_response = client.ask_AI("Tell me about quantum computing", raw=True)
print("Raw response:", raw_response)

Error Handling

try:
    response = client.ask_AI("What is the meaning of life?")
    print(response)
except Exception as e:
    print(f"An error occurred: {str(e)}")

Checking Available Models

# This will print available models but not change the current selection
client.set_model()

Examples

Simple Chatbot

from FuClientForExam import AIClient


def main():
   client = AIClient(api_key="your_api_key_here")

   print("AI Chatbot (type 'exit' to quit)")
   while True:
      user_input = input("You: ")
      if user_input.lower() == 'exit':
         break

      response = client.ask_AI(user_input)
      print(f"AI: {response}")


if __name__ == "__main__":
   main()

Model Testing Utility

from FuClientForExam import AIClient


def test_models(api_key, test_query="Explain quantum entanglement in simple terms"):
   client = AIClient(api_key=api_key)
   client.set_model()  # Show available models

   original_model = client.model

   # Get available models (re-run set_model to capture output)
   models = [...]  # You would collect models programmatically here

   print("\nTesting models with query:", test_query)
   for model in models:
      try:
         client.set_model(model)
         response = client.ask_AI(test_query)
         print(f"\n=== {model} ===\n{response[:200]}...")  # Print first 200 chars
      except Exception as e:
         print(f"Error with model {model}: {str(e)}")

   # Restore original model
   client.set_model(original_model)


if __name__ == "__main__":
   test_models("your_api_key_here")

Best Practices

  1. Secure API Key Management:

    • Never hardcode API keys in your source code
    • Use environment variables or secret management systems
    import os
    api_key = os.getenv("INTELLIGENCE_API_KEY")
    client = AIClient(api_key=api_key)
    
  2. Rate Limiting:

    • Implement appropriate rate limiting in your application
    • Handle API rate limit errors gracefully
  3. Error Handling:

    • Always wrap API calls in try-except blocks
    • Implement retry logic for transient errors
  4. Model Selection:

    • Test different models for your specific use case
    • Consider performance/cost tradeoffs when choosing models

Troubleshooting

Common Issues

  1. Authentication Errors:

    • Verify your API key is correct
    • Ensure your account is active and has sufficient credits
  2. Model Not Available:

    • Use set_model() to verify available models
    • Check the Intelligence.io status page for service disruptions
  3. Network Issues:

    • Check your internet connection
    • Verify firewall/proxy settings allow outbound connections to api.intelligence.io.solutions

Getting Help

For additional support, please contact:

Contributing

We welcome contributions! Please see our Contribution Guidelines for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

v0.1.0 (Initial Release)

  • Initial implementation of AIClient
  • Basic model selection functionality
  • Simple query-response interface

Note: This library is not officially affiliated with Intelligence.io. It's an unofficial client library created to simplify interaction with the Intelligence.io API.

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

fuclientforexam-0.1.2.tar.gz (5.2 kB view details)

Uploaded Source

File details

Details for the file fuclientforexam-0.1.2.tar.gz.

File metadata

  • Download URL: fuclientforexam-0.1.2.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for fuclientforexam-0.1.2.tar.gz
Algorithm Hash digest
SHA256 85fdf004e5cbc499b016e825264756ab30bf7e46bab96b64e7ab72b2200e33a3
MD5 825922b51f65a84019decfcf0c54ecf1
BLAKE2b-256 cfc166ad39dba84268e1771bdf85523a48e167c55e2803202786e1edcf27e511

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