Update agents/base_agent.py
Browse files- agents/base_agent.py +5 -5
agents/base_agent.py
CHANGED
|
@@ -2,7 +2,9 @@
|
|
| 2 |
|
| 3 |
from abc import ABC, abstractmethod
|
| 4 |
from typing import Any, Dict
|
| 5 |
-
import
|
|
|
|
|
|
|
| 6 |
|
| 7 |
class BaseAgent(ABC):
|
| 8 |
def __init__(self, model_name: str = "llama3.2:3b"):
|
|
@@ -10,10 +12,8 @@ class BaseAgent(ABC):
|
|
| 10 |
|
| 11 |
async def get_completion(self, prompt: str) -> str:
|
| 12 |
try:
|
| 13 |
-
response =
|
| 14 |
-
|
| 15 |
-
])
|
| 16 |
-
return response['message']['content']
|
| 17 |
except Exception as e:
|
| 18 |
raise Exception(f"Error getting completion: {str(e)}")
|
| 19 |
|
|
|
|
| 2 |
|
| 3 |
from abc import ABC, abstractmethod
|
| 4 |
from typing import Any, Dict
|
| 5 |
+
from groq import Groq
|
| 6 |
+
client = Groq()
|
| 7 |
+
|
| 8 |
|
| 9 |
class BaseAgent(ABC):
|
| 10 |
def __init__(self, model_name: str = "llama3.2:3b"):
|
|
|
|
| 12 |
|
| 13 |
async def get_completion(self, prompt: str) -> str:
|
| 14 |
try:
|
| 15 |
+
response = client.chat.completions.create(groq_api_key=os.getenv("GROQ_API_KEY"), messages=[{'role': 'user', 'content': prompt}], model=self.model_name)
|
| 16 |
+
return response.choices[0].message.content
|
|
|
|
|
|
|
| 17 |
except Exception as e:
|
| 18 |
raise Exception(f"Error getting completion: {str(e)}")
|
| 19 |
|