automated browsing
Project description
BrowserLite 🌐
BrowserLite is a powerful Python library for browser-based AI chat model interactions, supporting ChatGPT and HuggingChat. It provides a seamless interface for automated browser interactions with popular AI chat services.
🚀 Features
- 🤖 Easy integration with ChatGPT and HuggingChat
- 🌐 Support for multiple browsers (Chrome, Edge, Firefox)
- 📝 Stream responses in real-time
- 🛠️ Batch processing capabilities
- 🔄 OpenAI-like API interface
- 🔍 Optional web search integration
📦 Installation
pip install browserlite
🏃♂️ Quick Start
Simple Chat Completion
from browserlite import completion
# Basic usage
response = completion(
prompt="What is the capital of France?",
model="chatgpt" # or "huggingchat"
)
print(response)
# Using with system prompt
response = completion(
prompt="Explain quantum computing",
system_prompt="You are a quantum physics expert",
model="chatgpt"
)
Direct Browser Interface
from browserlite import chatgpt, huggingchat
# Using ChatGPT
response = chatgpt("Write a poem about coding")
# Using HuggingChat
response = huggingchat("Explain machine learning in simple terms")
Streaming Responses
from browserlite import pp_completion
# Print response in real-time
pp_completion(
prompt="Write a story about AI",
model="chatgpt",
stream=True
)
Advanced Usage with Messages
from browserlite import genai
messages = [
{"role": "system", "content": "You are a helpful coding assistant"},
{"role": "user", "content": "Write a Python function to sort a list"},
{"role": "assistant", "content": "Here's a simple sorting function:..."},
{"role": "user", "content": "Can you add error handling?"}
]
response = genai(
messages=messages,
model="chatgpt")
Custom Browser Configuration
from browserlite import AIBrowserClient
client = AIBrowserClient(
browser='microsoft-edge-stable', # or 'google-chrome', 'firefox'
default_sleep=30,
default_batch_settings={
"each_chat_start_wait_time": 0,
"batch_wait_size": 4,
"batch_wait_time": 10
}
)
response = client.chat.create(
messages=[{"role": "user", "content": "Hello!"}],
model="chatgpt"
)
🔧 Configuration Options
Available Models
chatgpt: OpenAI's ChatGPThuggingchat: HuggingFace's Chat Interface
Supported Browsers
microsoft-edge-stablegoogle-chromefirefox
Batch Processing Settings
batch_settings = {
"each_chat_start_wait_time": 0, # Wait time before each chat
"batch_wait_size": 4, # Number of requests before batch wait
"batch_wait_time": 10 # Wait time between batches
}
🌟 Advanced Features
Web Search Integration
response = completion(
prompt="What's the latest news about AI?",
web_search=True
)
Streaming with Custom Processing
client = AIBrowserClient()
stream = client.chat.create(
messages=[{"role": "user", "content": "Tell me a story"}],
model="chatgpt",
stream=True
)
for chunk in stream:
# Process each chunk as it arrives
content = chunk.choices[0].delta.content
if content:
process_chunk(content)
Multiple Formats Support
# String input
response = completion("Hello, how are you?")
# Dictionary format
response = completion({
"role": "user",
"content": "Hello!"
})
# List of messages
response = completion([
{"role": "system", "content": "You are a helpful assistant"},
{"role": "user", "content": "Hi!"}
])
📝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Thanks to the Python community
- Special thanks to all contributors
🔗 Links
- GitHub: browserlite
- Documentation: docs
- PyPI: browserlite
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 browserlite-0.0.43.tar.gz.
File metadata
- Download URL: browserlite-0.0.43.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.11.0rc1 Linux/6.8.0-49-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
303f665e9be987d732f6768cf0b980df1388e2512e3a5b2d4d316f1da725fe12
|
|
| MD5 |
2f5da5efe4e72f4369ae7a0e0a4af635
|
|
| BLAKE2b-256 |
2a469382ea09e8e959ad18415900681c6a3e3e930fe203038656e1bca108f076
|
File details
Details for the file browserlite-0.0.43-py3-none-any.whl.
File metadata
- Download URL: browserlite-0.0.43-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.11.0rc1 Linux/6.8.0-49-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bebb1b9186d821b053fec178c633498cb090afa35475a210736ef74b916e392
|
|
| MD5 |
cdd07dc4c7ef77648d36ad6d9ab0c371
|
|
| BLAKE2b-256 |
49005eeaa80247dc048c65549daa2974d41c902519c6acc33bd4502a0f307b11
|