File size: 905 Bytes
7fa1518 5293772 758d95a 56513c3 758d95a 56513c3 758d95a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import os
from abc import ABC, abstractmethod
from typing import Any, Dict
from groq import Groq
client = Groq()
class BaseAgent(ABC):
def __init__(self, model_name: str = "llama3.2:3b"):
self.model_name = model_name
async def get_completion(self, prompt: str) -> str:
try:
response = client.chat.completions.create(groq_api_key=os.getenv("GROQ_API_KEY"), messages=[{'role': 'user', 'content': prompt}], model=self.model_name)
return response.choices[0].message.content
except Exception as e:
raise Exception(f"Error getting completion: {str(e)}")
class MainAgent(BaseAgent):
@abstractmethod
async def process(self, input_data: Any) -> Dict[str, Any]:
pass
class ValidatorAgent(BaseAgent):
@abstractmethod
async def validate(self, input_data: Any, output_data: Any) -> Dict[str, bool]:
pass |