From 00de2f37bce367d5bd3a05166b211ed47032eb75 Mon Sep 17 00:00:00 2001 From: Kye Date: Wed, 24 Jan 2024 10:54:28 -0500 Subject: [PATCH] [README] --- README.md | 25 +++++++++++++++++ playground/models/llava.py | 16 +++++++++++ swarms/utils/agent_ops_wrapper.py | 45 +++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 playground/models/llava.py create mode 100644 swarms/utils/agent_ops_wrapper.py diff --git a/README.md b/README.md index 8f13e2e7..43407822 100644 --- a/README.md +++ b/README.md @@ -910,6 +910,31 @@ cog_agent = CogAgent() # Run the model on the tests cog_agent.run("Describe this scene", "images/1.jpg") +``` + + +### `QwenVLMultiModal` +A radically simple interface for QwenVLMultiModal comes complete with Quantization to turn it on just set quantize to true! + +```python +from swarms import QwenVLMultiModal + +# Instantiate the QwenVLMultiModal model +model = QwenVLMultiModal( + model_name="Qwen/Qwen-VL-Chat", + device="cuda", + quantize=True, +) + +# Run the model +response = model( + "Hello, how are you?", "https://example.com/image.jpg" +) + +# Print the response +print(response) + + ``` ---- diff --git a/playground/models/llava.py b/playground/models/llava.py new file mode 100644 index 00000000..561b6f88 --- /dev/null +++ b/playground/models/llava.py @@ -0,0 +1,16 @@ +from swarms import QwenVLMultiModal + +# Instantiate the QwenVLMultiModal model +model = QwenVLMultiModal( + model_name="Qwen/Qwen-VL-Chat", + device="cuda", + quantize=True, +) + +# Run the model +response = model( + "Hello, how are you?", "https://example.com/image.jpg" +) + +# Print the response +print(response) diff --git a/swarms/utils/agent_ops_wrapper.py b/swarms/utils/agent_ops_wrapper.py new file mode 100644 index 00000000..c1a019d2 --- /dev/null +++ b/swarms/utils/agent_ops_wrapper.py @@ -0,0 +1,45 @@ +import logging +import agentops + +class AgentOpsWrapper: + """ + A wrapper for the AgentOps client that adds error handling and logging. + """ + + def __init__(self, api_key): + """ + Initialize the AgentOps client with the given API key. + """ + self.client = agentops.Client(api_key) + self.logger = logging.getLogger(__name__) + self.logger.setLevel(logging.INFO) + + def record_action(self, action_name): + """ + Record an action with the given name. + """ + def decorator(func): + def wrapper(*args, **kwargs): + try: + self.client.record_action(action_name) + result = func(*args, **kwargs) + self.logger.info(f"Action {action_name} completed successfully.") + return result + except Exception as e: + self.logger.error(f"Error while recording action {action_name}: {e}") + raise + return wrapper + return decorator + + def end_session(self, status): + """ + End the session with the given status. + """ + try: + self.client.end_session(status) + self.logger.info(f"Session ended with status {status}.") + except Exception as e: + self.logger.error(f"Error while ending session: {e}") + raise + +# agentops = AgentOpsWrapper(api_key) \ No newline at end of file