DrishtiSharma commited on
Commit
5c1f206
Β·
verified Β·
1 Parent(s): f22913a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -6
app.py CHANGED
@@ -37,12 +37,36 @@ class LLMCallbackHandler(BaseCallbackHandler):
37
  with self.log_path.open("a", encoding="utf-8") as file:
38
  file.write(json.dumps({"event": "llm_end", "text": generation, "timestamp": datetime.now().isoformat()}) + "\n")
39
 
40
- llm = ChatGroq(
41
- temperature=0,
42
- model_name="groq/llama-3.3-70b-versatile",
43
- max_tokens=100,
44
- callbacks=[LLMCallbackHandler(Path("prompts.jsonl"))],
45
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  st.title("Blah Blah App Using CrewAI πŸš€")
48
  st.write("Analyze datasets using natural language queries powered by SQL and CrewAI.")
 
37
  with self.log_path.open("a", encoding="utf-8") as file:
38
  file.write(json.dumps({"event": "llm_end", "text": generation, "timestamp": datetime.now().isoformat()}) + "\n")
39
 
40
+ #llm = ChatGroq(
41
+ # temperature=0,
42
+ # model_name="groq/llama-3.3-70b-versatile",
43
+ # max_tokens=100,
44
+ # callbacks=[LLMCallbackHandler(Path("prompts.jsonl"))],
45
+ #)
46
+
47
+ # Initialize LLM
48
+ llm = None
49
+
50
+ # Model Selection
51
+ model_choice = st.radio("Select LLM", ["GPT-4o", "llama-3.3-70b"], index=0, horizontal=True)
52
+
53
+
54
+ # API Key Validation and LLM Initialization
55
+ groq_api_key = os.getenv("GROQ_API_KEY")
56
+ openai_api_key = os.getenv("OPENAI_API_KEY")
57
+
58
+ if model_choice == "llama-3.3-70b":
59
+ if not groq_api_key:
60
+ st.error("Groq API key is missing. Please set the GROQ_API_KEY environment variable.")
61
+ llm = None
62
+ else:
63
+ llm = ChatGroq(groq_api_key=groq_api_key, model="groq/llama-3.3-70b-versatile")
64
+ elif model_choice == "GPT-4o":
65
+ if not openai_api_key:
66
+ st.error("OpenAI API key is missing. Please set the OPENAI_API_KEY environment variable.")
67
+ llm = None
68
+ else:
69
+ llm = ChatOpenAI(api_key=openai_api_key, model="gpt-4o")
70
 
71
  st.title("Blah Blah App Using CrewAI πŸš€")
72
  st.write("Analyze datasets using natural language queries powered by SQL and CrewAI.")