added groqllm
Browse files
src/langgraphagenticai/LLMS/groqllm.py
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import streamlit as st
|
| 3 |
+
from langchain_groq import ChatGroq
|
| 4 |
+
|
| 5 |
+
class GroqLLM:
|
| 6 |
+
def __init__(self,user_controls_input):
|
| 7 |
+
self.user_controls_input=user_controls_input
|
| 8 |
+
|
| 9 |
+
def get_llm_model(self):
|
| 10 |
+
try:
|
| 11 |
+
groq_api_key=self.user_controls_input['GROQ_API_KEY']
|
| 12 |
+
selected_groq_model=self.user_controls_input['selected_groq_model']
|
| 13 |
+
if groq_api_key=='' and os.environ["GROQ_API_KEY"] =='':
|
| 14 |
+
st.error("Please Enter the Groq API KEY")
|
| 15 |
+
|
| 16 |
+
llm = ChatGroq(api_key=groq_api_key, model=selected_groq_model)
|
| 17 |
+
|
| 18 |
+
except Exception as e:
|
| 19 |
+
raise ValueError(f"Error Occurred with Exception : {e}")
|
| 20 |
+
return llm
|