Python client for exam
Project description
AIClient - Python Client for Intelligence.io API
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
- Sign up for an account at Intelligence.io
- 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 AIraw: 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
-
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)
-
Rate Limiting:
- Implement appropriate rate limiting in your application
- Handle API rate limit errors gracefully
-
Error Handling:
- Always wrap API calls in try-except blocks
- Implement retry logic for transient errors
-
Model Selection:
- Test different models for your specific use case
- Consider performance/cost tradeoffs when choosing models
Troubleshooting
Common Issues
-
Authentication Errors:
- Verify your API key is correct
- Ensure your account is active and has sufficient credits
-
Model Not Available:
- Use
set_model()to verify available models - Check the Intelligence.io status page for service disruptions
- Use
-
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:
- Intelligence.io Support: support@intelligence.io.solutions
- GitHub Issues: https://github.com/yourusername/aiclient/issues
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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52e6af028c7cecb3b935b303819a18b20eaf70ecd560a7fac4d536f9682ce198
|
|
| MD5 |
163d52a0978bdbc1a874aa563de9f880
|
|
| BLAKE2b-256 |
a90bf9dbdd2363aa5a94a6df194688b7efd1fa2056102b4c1507afff3cecb04d
|
File details
Details for the file fuclientforexam-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fuclientforexam-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6419245f6fc1ffe24eb010f479fe385802bcc1c50477828a7d8ff0d47e987aa
|
|
| MD5 |
203d0db6181bff15d6e9d92ddc3312ce
|
|
| BLAKE2b-256 |
625eacf807dc712c3b69daacbc19dee08faf0956bf527d3c506a12add646ec93
|