Spaces:
Running
Running
Replace HuggingFace model with Groq free API to fix payment required error
Browse files
agent.py
CHANGED
|
@@ -24,8 +24,8 @@ from langgraph.graph import StateGraph, END
|
|
| 24 |
from langgraph.graph.message import add_messages
|
| 25 |
from typing_extensions import TypedDict
|
| 26 |
|
| 27 |
-
#
|
| 28 |
-
from
|
| 29 |
|
| 30 |
# Utils system imports
|
| 31 |
from utils import (
|
|
@@ -68,20 +68,20 @@ class AgentState(TypedDict):
|
|
| 68 |
# =============================================================================
|
| 69 |
|
| 70 |
class LangChainQwen3Brain:
|
| 71 |
-
"""AI Brain using LangChain +
|
| 72 |
|
| 73 |
def __init__(self):
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
api_key=os.environ.get("
|
| 77 |
)
|
| 78 |
-
self.model_name = "
|
| 79 |
|
| 80 |
# Setup parsers
|
| 81 |
self.json_parser = JsonOutputParser()
|
| 82 |
self.str_parser = StrOutputParser()
|
| 83 |
|
| 84 |
-
print("🧠 LangChain
|
| 85 |
|
| 86 |
def _invoke_model(self, messages: List[Dict[str, str]]) -> str:
|
| 87 |
"""Invoke model with messages"""
|
|
@@ -386,7 +386,7 @@ class LangGraphUtilsAgent:
|
|
| 386 |
self.ai_brain = ai_brain
|
| 387 |
|
| 388 |
print("🤖 LangGraph Utils Agent initialized!")
|
| 389 |
-
print("🧠 AI Brain:
|
| 390 |
print("🔧 Tools: YouTube, Image OCR, Audio Transcript, Wikipedia, File Reader, Text Processor")
|
| 391 |
print("⚡ Features: AI-driven routing, Smart tool selection, Multimodal processing")
|
| 392 |
|
|
|
|
| 24 |
from langgraph.graph.message import add_messages
|
| 25 |
from typing_extensions import TypedDict
|
| 26 |
|
| 27 |
+
# Groq imports for free AI model
|
| 28 |
+
from groq import Groq
|
| 29 |
|
| 30 |
# Utils system imports
|
| 31 |
from utils import (
|
|
|
|
| 68 |
# =============================================================================
|
| 69 |
|
| 70 |
class LangChainQwen3Brain:
|
| 71 |
+
"""AI Brain using LangChain + Groq free models"""
|
| 72 |
|
| 73 |
def __init__(self):
|
| 74 |
+
# Use Groq instead of HuggingFace
|
| 75 |
+
self.client = Groq(
|
| 76 |
+
api_key=os.environ.get("GROQ_API_KEY", "")
|
| 77 |
)
|
| 78 |
+
self.model_name = "llama3-8b-8192" # Free Groq model
|
| 79 |
|
| 80 |
# Setup parsers
|
| 81 |
self.json_parser = JsonOutputParser()
|
| 82 |
self.str_parser = StrOutputParser()
|
| 83 |
|
| 84 |
+
print("🧠 LangChain Groq Brain initialized")
|
| 85 |
|
| 86 |
def _invoke_model(self, messages: List[Dict[str, str]]) -> str:
|
| 87 |
"""Invoke model with messages"""
|
|
|
|
| 386 |
self.ai_brain = ai_brain
|
| 387 |
|
| 388 |
print("🤖 LangGraph Utils Agent initialized!")
|
| 389 |
+
print("🧠 AI Brain: Groq free models with LangChain")
|
| 390 |
print("🔧 Tools: YouTube, Image OCR, Audio Transcript, Wikipedia, File Reader, Text Processor")
|
| 391 |
print("⚡ Features: AI-driven routing, Smart tool selection, Multimodal processing")
|
| 392 |
|