Spaces:
Running
Running
Gaurav vashistha
commited on
Commit
Β·
842ca78
1
Parent(s):
c6137f0
Final Release: Updated README and Sync
Browse files- README.md +23 -10
- check_basic.py +20 -0
- check_gemini.py +26 -0
- check_gemini_clean.py +24 -0
- check_groq_models.py +14 -0
- check_groq_vision.py +36 -0
- check_idefics.py +33 -0
- check_idefics_raw.py +29 -0
- check_idefics_v2.py +31 -0
- check_idefics_v3.py +30 -0
- check_llama.py +33 -0
- check_llava.py +33 -0
- check_models_list.py +15 -0
- check_qwen.py +48 -0
- check_qwen_raw.py +52 -0
- scan_vision_models.py +44 -0
- start_n8n.ps1 +7 -0
- test_gemini_fix.py +48 -0
- test_vision_hf.py +41 -0
README.md
CHANGED
|
@@ -1,10 +1,23 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# MerchFlow AI - Open Source E-Commerce Agent
|
| 2 |
+
|
| 3 |
+

|
| 4 |
+

|
| 5 |
+
|
| 6 |
+
## About
|
| 7 |
+
MerchFlow AI is a **Multi-Agent System built in Pure Python (No LangChain)** that automates product listing generation using Enterprise-Grade Computer Vision. It leverages advanced visual analysis to streamline e-commerce workflows.
|
| 8 |
+
|
| 9 |
+
## Architecture
|
| 10 |
+
The system operates through a coordinated pipeline:
|
| 11 |
+
1. **Input Image** β Raw processing
|
| 12 |
+
2. **Visual Analyst (Gemini 1.5)** β Extracts visual features and metadata
|
| 13 |
+
3. **Manager Agent** β Orchestrates data flow and decision making
|
| 14 |
+
4. **n8n Webhook (Self-Hosted)** β Triggers downstream automation and integration
|
| 15 |
+
|
| 16 |
+
## Open Source Notice
|
| 17 |
+
This project is open source under the MIT License. Feel free to fork and contribute.
|
| 18 |
+
|
| 19 |
+
## Setup
|
| 20 |
+
To run this project, you need to configure the following Environment Variables:
|
| 21 |
+
|
| 22 |
+
* `GOOGLE_API_KEY`: Your Google Gemini API Key.
|
| 23 |
+
* `N8N_WEBHOOK_URL`: The URL for your self-hosted n8n webhook connector.
|
check_basic.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
|
| 5 |
+
load_dotenv()
|
| 6 |
+
|
| 7 |
+
api_key = os.getenv("HF_TOKEN")
|
| 8 |
+
client = InferenceClient(api_key=api_key)
|
| 9 |
+
|
| 10 |
+
print(f"Testing token with microsoft/resnet-50")
|
| 11 |
+
|
| 12 |
+
try:
|
| 13 |
+
# Pass the URL directly as the input (InferenceClient handles URLs for image tasks)
|
| 14 |
+
result = client.image_classification(
|
| 15 |
+
model="microsoft/resnet-50",
|
| 16 |
+
image="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
|
| 17 |
+
)
|
| 18 |
+
print("Success:", result)
|
| 19 |
+
except Exception as e:
|
| 20 |
+
print("Failed:", e)
|
check_gemini.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import google.generativeai as genai
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
|
| 5 |
+
load_dotenv()
|
| 6 |
+
|
| 7 |
+
api_key = os.getenv("GEMINI_API_KEY") or os.getenv("GOOGLE_API_KEY")
|
| 8 |
+
genai.configure(api_key=api_key)
|
| 9 |
+
|
| 10 |
+
print("Listing available Gemini models...")
|
| 11 |
+
try:
|
| 12 |
+
for m in genai.list_models():
|
| 13 |
+
if 'generateContent' in m.supported_generation_methods:
|
| 14 |
+
print(m.name)
|
| 15 |
+
except Exception as e:
|
| 16 |
+
print(f"List models failed: {e}")
|
| 17 |
+
|
| 18 |
+
model_name = "gemini-1.5-flash"
|
| 19 |
+
print(f"\nTesting model: {model_name}")
|
| 20 |
+
|
| 21 |
+
try:
|
| 22 |
+
model = genai.GenerativeModel(model_name)
|
| 23 |
+
response = model.generate_content("Hello, can you see this?")
|
| 24 |
+
print("Response:", response.text)
|
| 25 |
+
except Exception as e:
|
| 26 |
+
print(f"Test failed: {e}")
|
check_gemini_clean.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import google.generativeai as genai
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
|
| 5 |
+
load_dotenv()
|
| 6 |
+
|
| 7 |
+
api_key = os.getenv("GEMINI_API_KEY") or os.getenv("GOOGLE_API_KEY")
|
| 8 |
+
genai.configure(api_key=api_key)
|
| 9 |
+
|
| 10 |
+
candidates = [
|
| 11 |
+
"gemini-2.0-flash",
|
| 12 |
+
"gemini-2.0-flash-exp",
|
| 13 |
+
"models/gemini-2.0-flash"
|
| 14 |
+
]
|
| 15 |
+
|
| 16 |
+
for model_name in candidates:
|
| 17 |
+
print(f"\nTesting model: {model_name}")
|
| 18 |
+
try:
|
| 19 |
+
model = genai.GenerativeModel(model_name)
|
| 20 |
+
response = model.generate_content("Hello")
|
| 21 |
+
print(f"β
Success with {model_name}: {response.text}")
|
| 22 |
+
break
|
| 23 |
+
except Exception as e:
|
| 24 |
+
print(f"β Failed with {model_name}: {e}")
|
check_groq_models.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from groq import Groq
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
|
| 5 |
+
load_dotenv()
|
| 6 |
+
|
| 7 |
+
try:
|
| 8 |
+
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
| 9 |
+
models = client.models.list()
|
| 10 |
+
print("Available Models:")
|
| 11 |
+
for model in models.data:
|
| 12 |
+
print(f"- {model.id}")
|
| 13 |
+
except Exception as e:
|
| 14 |
+
print(f"Error listing models: {e}")
|
check_groq_vision.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from groq import Groq
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
import base64
|
| 5 |
+
|
| 6 |
+
load_dotenv()
|
| 7 |
+
|
| 8 |
+
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
| 9 |
+
model = "llama-3.2-11b-vision-preview"
|
| 10 |
+
|
| 11 |
+
print(f"Testing Groq Vision model: {model}")
|
| 12 |
+
|
| 13 |
+
# Test 1: Image URL
|
| 14 |
+
print("\n--- Test 1: Image URL ---")
|
| 15 |
+
try:
|
| 16 |
+
image_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
|
| 17 |
+
completion = client.chat.completions.create(
|
| 18 |
+
model=model,
|
| 19 |
+
messages=[
|
| 20 |
+
{
|
| 21 |
+
"role": "user",
|
| 22 |
+
"content": [
|
| 23 |
+
{"type": "text", "text": "What's in this image?"},
|
| 24 |
+
{"type": "image_url", "image_url": {"url": image_url}},
|
| 25 |
+
],
|
| 26 |
+
}
|
| 27 |
+
],
|
| 28 |
+
temperature=1,
|
| 29 |
+
max_tokens=1024,
|
| 30 |
+
top_p=1,
|
| 31 |
+
stream=False,
|
| 32 |
+
stop=None,
|
| 33 |
+
)
|
| 34 |
+
print("Response:", completion.choices[0].message.content)
|
| 35 |
+
except Exception as e:
|
| 36 |
+
print("Groq Vision failed:", e)
|
check_idefics.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
|
| 5 |
+
load_dotenv()
|
| 6 |
+
|
| 7 |
+
api_key = os.getenv("HF_TOKEN")
|
| 8 |
+
client = InferenceClient(api_key=api_key)
|
| 9 |
+
model = "HuggingFaceM4/idefics2-8b"
|
| 10 |
+
|
| 11 |
+
print(f"Testing model: {model}")
|
| 12 |
+
|
| 13 |
+
# Test 1: Image URL
|
| 14 |
+
print("\n--- Test 1: Image URL ---")
|
| 15 |
+
try:
|
| 16 |
+
image_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
|
| 17 |
+
messages = [
|
| 18 |
+
{
|
| 19 |
+
"role": "user",
|
| 20 |
+
"content": [
|
| 21 |
+
{"type": "image_url", "image_url": {"url": image_url}},
|
| 22 |
+
{"type": "text", "text": "What is in this image?"}
|
| 23 |
+
]
|
| 24 |
+
}
|
| 25 |
+
]
|
| 26 |
+
completion = client.chat.completions.create(
|
| 27 |
+
model=model,
|
| 28 |
+
messages=messages,
|
| 29 |
+
max_tokens=100
|
| 30 |
+
)
|
| 31 |
+
print("Response:", completion.choices[0].message.content)
|
| 32 |
+
except Exception as e:
|
| 33 |
+
print("Image URL failed:", e)
|
check_idefics_raw.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import requests
|
| 3 |
+
import json
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
+
|
| 6 |
+
load_dotenv()
|
| 7 |
+
|
| 8 |
+
api_key = os.getenv("HF_TOKEN")
|
| 9 |
+
model = "HuggingFaceM4/idefics2-8b"
|
| 10 |
+
url = f"https://router.huggingface.co/models/{model}"
|
| 11 |
+
|
| 12 |
+
headers = {"Authorization": f"Bearer {api_key}"}
|
| 13 |
+
|
| 14 |
+
print(f"Testing URL: {url}")
|
| 15 |
+
|
| 16 |
+
# Test A: Simple text inputs
|
| 17 |
+
print("\n--- Test A: Simple Text ---")
|
| 18 |
+
response = requests.post(url, headers=headers, json={"inputs": "Hello"})
|
| 19 |
+
print(f"Status: {response.status_code}")
|
| 20 |
+
print("Response:", response.text)
|
| 21 |
+
|
| 22 |
+
# Test B: Formatted inputs (Standard for some VLM APIs)
|
| 23 |
+
# Often they accept { "inputs": "User: ...", "parameters": ... }
|
| 24 |
+
print("\n--- Test B: Formatted Prompt ---")
|
| 25 |
+
image_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
|
| 26 |
+
prompt = f"User:  Describe this image.<end_of_utterance>\nAssistant:"
|
| 27 |
+
response = requests.post(url, headers=headers, json={"inputs": prompt, "parameters": {"max_new_tokens": 50}})
|
| 28 |
+
print(f"Status: {response.status_code}")
|
| 29 |
+
print("Response:", response.text)
|
check_idefics_v2.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
|
| 5 |
+
load_dotenv()
|
| 6 |
+
|
| 7 |
+
api_key = os.getenv("HF_TOKEN")
|
| 8 |
+
client = InferenceClient(api_key=api_key)
|
| 9 |
+
model = "HuggingFaceM4/idefics2-8b"
|
| 10 |
+
|
| 11 |
+
print(f"Testing model: {model}")
|
| 12 |
+
|
| 13 |
+
image_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
|
| 14 |
+
|
| 15 |
+
# Format for Idefics2:
|
| 16 |
+
# User:  <text><end_of_utterance>\nAssistant:
|
| 17 |
+
prompt = f"User:  Describe this image.<end_of_utterance>\nAssistant:"
|
| 18 |
+
|
| 19 |
+
print(f"\n--- Testing with text_generation and specific prompt ---")
|
| 20 |
+
print(f"Prompt: {prompt}")
|
| 21 |
+
|
| 22 |
+
try:
|
| 23 |
+
# Use text_generation for models that don't support chat
|
| 24 |
+
response = client.text_generation(
|
| 25 |
+
prompt=prompt,
|
| 26 |
+
model=model,
|
| 27 |
+
max_new_tokens=100
|
| 28 |
+
)
|
| 29 |
+
print("Response:", response)
|
| 30 |
+
except Exception as e:
|
| 31 |
+
print("Failed:", e)
|
check_idefics_v3.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import traceback
|
| 3 |
+
from huggingface_hub import InferenceClient
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
+
|
| 6 |
+
load_dotenv()
|
| 7 |
+
|
| 8 |
+
api_key = os.getenv("HF_TOKEN")
|
| 9 |
+
client = InferenceClient(api_key=api_key)
|
| 10 |
+
model = "HuggingFaceM4/idefics2-8b"
|
| 11 |
+
|
| 12 |
+
print(f"Testing model: {model}")
|
| 13 |
+
|
| 14 |
+
print("\n--- Test 1: Image to Text (Captioning) ---")
|
| 15 |
+
try:
|
| 16 |
+
# This might work if the API treats it as captioning
|
| 17 |
+
res = client.image_to_text(
|
| 18 |
+
"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true",
|
| 19 |
+
model=model
|
| 20 |
+
)
|
| 21 |
+
print("Response:", res)
|
| 22 |
+
except Exception:
|
| 23 |
+
traceback.print_exc()
|
| 24 |
+
|
| 25 |
+
print("\n--- Test 2: Text Generation (Simple) ---")
|
| 26 |
+
try:
|
| 27 |
+
res = client.text_generation("describe a car", model=model, max_new_tokens=50)
|
| 28 |
+
print("Response:", res)
|
| 29 |
+
except Exception:
|
| 30 |
+
traceback.print_exc()
|
check_llama.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
|
| 5 |
+
load_dotenv()
|
| 6 |
+
|
| 7 |
+
api_key = os.getenv("HF_TOKEN")
|
| 8 |
+
client = InferenceClient(api_key=api_key)
|
| 9 |
+
model = "meta-llama/Llama-3.2-11B-Vision-Instruct"
|
| 10 |
+
|
| 11 |
+
print(f"Testing model: {model}")
|
| 12 |
+
|
| 13 |
+
# Test 1: Image URL (Llama Vision)
|
| 14 |
+
print("\n--- Test 1: Image URL ---")
|
| 15 |
+
try:
|
| 16 |
+
image_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
|
| 17 |
+
messages = [
|
| 18 |
+
{
|
| 19 |
+
"role": "user",
|
| 20 |
+
"content": [
|
| 21 |
+
{"type": "image_url", "image_url": {"url": image_url}},
|
| 22 |
+
{"type": "text", "text": "What is in this image?"}
|
| 23 |
+
]
|
| 24 |
+
}
|
| 25 |
+
]
|
| 26 |
+
completion = client.chat.completions.create(
|
| 27 |
+
model=model,
|
| 28 |
+
messages=messages,
|
| 29 |
+
max_tokens=100
|
| 30 |
+
)
|
| 31 |
+
print("Response:", completion.choices[0].message.content)
|
| 32 |
+
except Exception as e:
|
| 33 |
+
print("Image URL failed:", e)
|
check_llava.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
|
| 5 |
+
load_dotenv()
|
| 6 |
+
|
| 7 |
+
api_key = os.getenv("HF_TOKEN")
|
| 8 |
+
client = InferenceClient(api_key=api_key)
|
| 9 |
+
model = "llava-hf/llava-1.5-7b-hf"
|
| 10 |
+
|
| 11 |
+
print(f"Testing model: {model}")
|
| 12 |
+
|
| 13 |
+
# Test 1: Image URL
|
| 14 |
+
print("\n--- Test 1: Image URL ---")
|
| 15 |
+
try:
|
| 16 |
+
image_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
|
| 17 |
+
messages = [
|
| 18 |
+
{
|
| 19 |
+
"role": "user",
|
| 20 |
+
"content": [
|
| 21 |
+
{"type": "image_url", "image_url": {"url": image_url}},
|
| 22 |
+
{"type": "text", "text": "What is in this image?"}
|
| 23 |
+
]
|
| 24 |
+
}
|
| 25 |
+
]
|
| 26 |
+
completion = client.chat.completions.create(
|
| 27 |
+
model=model,
|
| 28 |
+
messages=messages,
|
| 29 |
+
max_tokens=100
|
| 30 |
+
)
|
| 31 |
+
print("Response:", completion.choices[0].message.content)
|
| 32 |
+
except Exception as e:
|
| 33 |
+
print("Image URL failed:", e)
|
check_models_list.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import google.generativeai as genai
|
| 2 |
+
import os
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
|
| 5 |
+
load_dotenv()
|
| 6 |
+
|
| 7 |
+
api_key = os.getenv("GEMINI_API_KEY")
|
| 8 |
+
if not api_key:
|
| 9 |
+
print("β API Key not found")
|
| 10 |
+
else:
|
| 11 |
+
genai.configure(api_key=api_key)
|
| 12 |
+
print("Listing available models...")
|
| 13 |
+
for m in genai.list_models():
|
| 14 |
+
if 'generateContent' in m.supported_generation_methods:
|
| 15 |
+
print(m.name)
|
check_qwen.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
|
| 5 |
+
load_dotenv()
|
| 6 |
+
|
| 7 |
+
api_key = os.getenv("HF_TOKEN")
|
| 8 |
+
client = InferenceClient(api_key=api_key)
|
| 9 |
+
model = "Qwen/Qwen2-VL-7B-Instruct"
|
| 10 |
+
|
| 11 |
+
print(f"Testing model: {model}")
|
| 12 |
+
|
| 13 |
+
# Test 1: Text only
|
| 14 |
+
print("\n--- Test 1: Text Only ---")
|
| 15 |
+
try:
|
| 16 |
+
messages = [
|
| 17 |
+
{"role": "user", "content": "Hello, are you working?"}
|
| 18 |
+
]
|
| 19 |
+
completion = client.chat.completions.create(
|
| 20 |
+
model=model,
|
| 21 |
+
messages=messages,
|
| 22 |
+
max_tokens=100
|
| 23 |
+
)
|
| 24 |
+
print("Response:", completion.choices[0].message.content)
|
| 25 |
+
except Exception as e:
|
| 26 |
+
print("Text only failed:", e)
|
| 27 |
+
|
| 28 |
+
# Test 2: Image (using a public URL to avoid base64 issues first)
|
| 29 |
+
print("\n--- Test 2: Image URL ---")
|
| 30 |
+
try:
|
| 31 |
+
image_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true"
|
| 32 |
+
messages = [
|
| 33 |
+
{
|
| 34 |
+
"role": "user",
|
| 35 |
+
"content": [
|
| 36 |
+
{"type": "image_url", "image_url": {"url": image_url}},
|
| 37 |
+
{"type": "text", "text": "What is in this image?"}
|
| 38 |
+
]
|
| 39 |
+
}
|
| 40 |
+
]
|
| 41 |
+
completion = client.chat.completions.create(
|
| 42 |
+
model=model,
|
| 43 |
+
messages=messages,
|
| 44 |
+
max_tokens=100
|
| 45 |
+
)
|
| 46 |
+
print("Response:", completion.choices[0].message.content)
|
| 47 |
+
except Exception as e:
|
| 48 |
+
print("Image URL failed:", e)
|
check_qwen_raw.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import requests
|
| 3 |
+
import json
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
+
|
| 6 |
+
load_dotenv()
|
| 7 |
+
|
| 8 |
+
api_key = os.getenv("HF_TOKEN")
|
| 9 |
+
model = "Qwen/Qwen2-VL-7B-Instruct"
|
| 10 |
+
# Update URL to router
|
| 11 |
+
url = f"https://router.huggingface.co/models/{model}"
|
| 12 |
+
|
| 13 |
+
headers = {"Authorization": f"Bearer {api_key}"}
|
| 14 |
+
|
| 15 |
+
print(f"Testing URL: {url}")
|
| 16 |
+
|
| 17 |
+
# Test 1: Simple text generation payload (inputs string)
|
| 18 |
+
data_text = {
|
| 19 |
+
"inputs": "Hello",
|
| 20 |
+
"parameters": {"max_new_tokens": 50}
|
| 21 |
+
}
|
| 22 |
+
print("\n--- Test 1: Text Generation (inputs string) ---")
|
| 23 |
+
response = requests.post(url, headers=headers, json=data_text)
|
| 24 |
+
print(f"Status: {response.status_code}")
|
| 25 |
+
print("Response:", response.text)
|
| 26 |
+
|
| 27 |
+
# Test 2: VQA format
|
| 28 |
+
data_vqa = {
|
| 29 |
+
"inputs": {
|
| 30 |
+
"image": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?download=true",
|
| 31 |
+
"question": "What is in this image?"
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
print("\n--- Test 2: VQA Format ---")
|
| 35 |
+
response = requests.post(url, headers=headers, json=data_vqa)
|
| 36 |
+
print(f"Status: {response.status_code}")
|
| 37 |
+
print("Response:", response.text)
|
| 38 |
+
|
| 39 |
+
# Test 3: Chat Completions API (OpenAI style)
|
| 40 |
+
url_chat = f"https://router.huggingface.co/models/{model}/v1/chat/completions"
|
| 41 |
+
print(f"\nTesting URL: {url_chat}")
|
| 42 |
+
data_chat = {
|
| 43 |
+
"model": model, # Sometimes required in body
|
| 44 |
+
"messages": [
|
| 45 |
+
{"role": "user", "content": "Hello"}
|
| 46 |
+
],
|
| 47 |
+
"max_tokens": 50
|
| 48 |
+
}
|
| 49 |
+
print("\n--- Test 3: Chat Completion ---")
|
| 50 |
+
response = requests.post(url_chat, headers=headers, json=data_chat)
|
| 51 |
+
print(f"Status: {response.status_code}")
|
| 52 |
+
print("Response:", response.text)
|
scan_vision_models.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import requests
|
| 3 |
+
import json
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
+
|
| 6 |
+
load_dotenv()
|
| 7 |
+
|
| 8 |
+
api_key = os.getenv("HF_TOKEN")
|
| 9 |
+
headers = {"Authorization": f"Bearer {api_key}"}
|
| 10 |
+
|
| 11 |
+
candidates = [
|
| 12 |
+
"HuggingFaceM4/idefics2-8b",
|
| 13 |
+
"HuggingFaceM4/idefics2-8b-chatty",
|
| 14 |
+
"llava-hf/llava-1.5-7b-hf",
|
| 15 |
+
"llava-hf/llava-v1.6-mistral-7b-hf",
|
| 16 |
+
"microsoft/Phi-3-vision-128k-instruct",
|
| 17 |
+
"NousResearch/Nous-Hermes-2-Vision-Alpha",
|
| 18 |
+
"OpenGVLab/InternVL-Chat-V1-5",
|
| 19 |
+
"Qwen/Qwen2.5-VL-7B-Instruct",
|
| 20 |
+
"google/paligemma-3b-mix-224"
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
print("Scanning for working Serverless Vision Models...\n")
|
| 24 |
+
|
| 25 |
+
for model in candidates:
|
| 26 |
+
url = f"https://router.huggingface.co/models/{model}"
|
| 27 |
+
print(f"Testing: {model}")
|
| 28 |
+
try:
|
| 29 |
+
# Simple probe payload
|
| 30 |
+
response = requests.post(url, headers=headers, json={"inputs": "Hello"})
|
| 31 |
+
if response.status_code == 200:
|
| 32 |
+
print(f"β
WORKS! {model} (Status: 200)")
|
| 33 |
+
print(f"Response: {response.text[:100]}...")
|
| 34 |
+
elif response.status_code == 400:
|
| 35 |
+
# 400 might mean it Exists but input format is wrong (which is good!)
|
| 36 |
+
print(f"β οΈ EXISTS but 400 (Bad Request): {model}")
|
| 37 |
+
print(f"Response: {response.text[:100]}...")
|
| 38 |
+
elif response.status_code == 404:
|
| 39 |
+
print(f"β 404 Not Found: {model}")
|
| 40 |
+
else:
|
| 41 |
+
print(f"β Error {response.status_code}: {model}")
|
| 42 |
+
except Exception as e:
|
| 43 |
+
print(f"β Exception: {e}")
|
| 44 |
+
print("-" * 30)
|
start_n8n.ps1
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Write-Host "π Killing stuck Node.js processes..." -ForegroundColor Yellow
|
| 2 |
+
Stop-Process -Name "node" -Force -ErrorAction SilentlyContinue
|
| 3 |
+
Write-Host "β
Ports cleared." -ForegroundColor Green
|
| 4 |
+
|
| 5 |
+
Write-Host "π Starting n8n with Tunnel..." -ForegroundColor Yellow
|
| 6 |
+
# This starts n8n and keeps the window open
|
| 7 |
+
npx n8n start --tunnel
|
test_gemini_fix.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import os
|
| 3 |
+
import json
|
| 4 |
+
from agents.visual_analyst import VisualAnalyst
|
| 5 |
+
|
| 6 |
+
def test_gemini_visual_analyst():
|
| 7 |
+
print("π Starting Visual Analyst Test (Gemini 1.5 Flash)...")
|
| 8 |
+
|
| 9 |
+
# 1. Initialize
|
| 10 |
+
try:
|
| 11 |
+
agent = VisualAnalyst()
|
| 12 |
+
except Exception as e:
|
| 13 |
+
print(f"β Failed to initialize VisualAnalyst: {e}")
|
| 14 |
+
return
|
| 15 |
+
|
| 16 |
+
# 2. Define Image Path (Use a known existing image or creating dummy if needed,
|
| 17 |
+
# but better to use one if available. previous context showed 'test_image.jpg')
|
| 18 |
+
image_path = "test_image.jpg"
|
| 19 |
+
if not os.path.exists(image_path):
|
| 20 |
+
print(f"β οΈ {image_path} not found. Using 'screen.jpg' if available or skipping.")
|
| 21 |
+
image_path = "screen.jpg"
|
| 22 |
+
if not os.path.exists(image_path):
|
| 23 |
+
print("β No test image found.")
|
| 24 |
+
return
|
| 25 |
+
|
| 26 |
+
print(f"πΈ Analyzing image: {image_path}")
|
| 27 |
+
|
| 28 |
+
# 3. Analyze
|
| 29 |
+
try:
|
| 30 |
+
result = agent.analyze_image(image_path)
|
| 31 |
+
print("β
Raw Result:", result)
|
| 32 |
+
|
| 33 |
+
# 4. Verify Structure
|
| 34 |
+
required_keys = ["main_color", "product_type", "design_style", "visual_features"]
|
| 35 |
+
missing = [k for k in required_keys if k not in result]
|
| 36 |
+
|
| 37 |
+
if missing:
|
| 38 |
+
print(f"β Missing keys in JSON: {missing}")
|
| 39 |
+
else:
|
| 40 |
+
print("β
JSON Structure Validated")
|
| 41 |
+
print("π¨ Main Color:", result.get("main_color"))
|
| 42 |
+
print("π¦ Product Type:", result.get("product_type"))
|
| 43 |
+
|
| 44 |
+
except Exception as e:
|
| 45 |
+
print(f"β Analysis failed with exception: {e}")
|
| 46 |
+
|
| 47 |
+
if __name__ == "__main__":
|
| 48 |
+
test_gemini_visual_analyst()
|
test_vision_hf.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
|
| 5 |
+
# Load env variables (for HF_TOKEN)
|
| 6 |
+
load_dotenv()
|
| 7 |
+
|
| 8 |
+
# Add project root to path so we can import agents
|
| 9 |
+
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
| 10 |
+
|
| 11 |
+
from agents.visual_analyst import VisualAnalyst
|
| 12 |
+
|
| 13 |
+
def test_hf_vision():
|
| 14 |
+
image_path = "test_image.jpg"
|
| 15 |
+
|
| 16 |
+
if not os.path.exists(image_path):
|
| 17 |
+
print(f"β '{image_path}' not found. Please provide a test image.")
|
| 18 |
+
return
|
| 19 |
+
|
| 20 |
+
print(f"π Testing Hugging Face Qwen2-VL Vision Analyst with {image_path}...")
|
| 21 |
+
|
| 22 |
+
try:
|
| 23 |
+
analyst = VisualAnalyst()
|
| 24 |
+
result = analyst.analyze_image(image_path)
|
| 25 |
+
|
| 26 |
+
print("\nβ
Analysis Result:")
|
| 27 |
+
print(result)
|
| 28 |
+
|
| 29 |
+
required_keys = ["main_color", "product_type", "design_style", "visual_features"]
|
| 30 |
+
missing_keys = [k for k in required_keys if k not in result]
|
| 31 |
+
|
| 32 |
+
if missing_keys:
|
| 33 |
+
print(f"\nβ Missing keys in response: {missing_keys}")
|
| 34 |
+
else:
|
| 35 |
+
print("\nπ Output format verified!")
|
| 36 |
+
|
| 37 |
+
except Exception as e:
|
| 38 |
+
print(f"\nβ Test Failed: {e}")
|
| 39 |
+
|
| 40 |
+
if __name__ == "__main__":
|
| 41 |
+
test_hf_vision()
|