DrishtiSharma's picture
Update agents/base_agent.py
c9f0210 verified
raw
history blame contribute delete
868 Bytes
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-8b-8192"):
self.model_name = model_name
async def get_completion(self, prompt: str) -> str:
try:
response = client.chat.completions.create(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