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.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

fuclientforexam-0.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fuclientforexam-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 52e6af028c7cecb3b935b303819a18b20eaf70ecd560a7fac4d536f9682ce198
MD5 163d52a0978bdbc1a874aa563de9f880
BLAKE2b-256 a90bf9dbdd2363aa5a94a6df194688b7efd1fa2056102b4c1507afff3cecb04d

See more details on using hashes here.

File details

Details for the file fuclientforexam-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fuclientforexam-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f6419245f6fc1ffe24eb010f479fe385802bcc1c50477828a7d8ff0d47e987aa
MD5 203d0db6181bff15d6e9d92ddc3312ce
BLAKE2b-256 625eacf807dc712c3b69daacbc19dee08faf0956bf527d3c506a12add646ec93

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