skjaini commited on
Commit
41588da
·
verified ·
1 Parent(s): 20b762b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -14
app.py CHANGED
@@ -1,24 +1,25 @@
1
  import streamlit as st
2
- from crewai import Crew, Agent, Task, Process, LLM
3
  from langchain_community.tools import DuckDuckGoSearchRun
4
- from langchain_google_genai import ChatGoogleGenerativeAI
5
  import os
6
- import google.generativeai as genai
7
  from langchain.tools import BaseTool
8
 
 
 
 
9
 
10
- # Configure Gemini API Key
11
- GOOGLE_API_KEY = st.secrets["GOOGLE_API_KEY"]
12
- genai.configure(api_key=GOOGLE_API_KEY)
13
 
14
- # Define the LLM using langchain-google-genai
15
- # The CrewAI LLM class has been deprecated. Pass the Langchain LLM directly.
16
- gemini_llm = ChatGoogleGenerativeAI(model="gemini-pro", temperature=0.7, convert_system_message_to_human=True, google_api_key=GOOGLE_API_KEY)
 
17
 
18
 
19
  # Define Tools
20
  search_tool = DuckDuckGoSearchRun()
21
 
 
22
  class ToolWrapper(BaseTool):
23
  """Wrapper for tools to make them compatible with CrewAI."""
24
 
@@ -33,7 +34,7 @@ class ToolWrapper(BaseTool):
33
  return await self.func(*args, **kwargs)
34
 
35
 
36
- # Define Agents - Pass the Langchain LLM directly
37
  inventory_specialist = Agent(
38
  role="Inventory Specialist",
39
  goal="Identify the best matching homes from current inventory based on customer criteria.",
@@ -51,7 +52,7 @@ inventory_specialist = Agent(
51
  description=search_tool.description,
52
  )
53
  ],
54
- llm=gemini_llm, # Pass the Langchain LLM *directly*
55
  )
56
 
57
  communication_specialist = Agent(
@@ -64,7 +65,7 @@ communication_specialist = Agent(
64
  """,
65
  verbose=True,
66
  allow_delegation=True,
67
- llm=gemini_llm, # Pass the Langchain LLM *directly*
68
  )
69
 
70
 
@@ -102,7 +103,7 @@ def create_communication_task(inventory_results):
102
 
103
 
104
  # Streamlit App
105
- st.title("AI-Powered Real Estate Lead Response (Gemini)")
106
 
107
  customer_zipcode = st.text_input("Zip Code:", placeholder="Enter zip code")
108
  customer_bedrooms = st.number_input(
@@ -146,5 +147,5 @@ if st.button("Submit Inquiry"):
146
  except Exception as e:
147
  st.error(f"An error occurred: {e}")
148
  st.write(
149
- "Please check your Gemini API key and ensure it has the necessary permissions."
150
  )
 
1
  import streamlit as st
2
+ from crewai import Crew, Agent, Task, Process
3
  from langchain_community.tools import DuckDuckGoSearchRun
4
+ from langchain_groq import ChatGroq # Import ChatGroq
5
  import os
 
6
  from langchain.tools import BaseTool
7
 
8
+ # Configure Groq API Key (replace with your actual key)
9
+ GROQ_API_KEY = st.secrets["GROQ_API_KEY"]
10
+ # No need for genai.configure anymore
11
 
 
 
 
12
 
13
+ # Define the LLM using langchain-groq
14
+ groq_llm = ChatGroq(
15
+ model_name="groq/deepseek-coder-33b-instruct", temperature=0.7, groq_api_key=GROQ_API_KEY
16
+ )
17
 
18
 
19
  # Define Tools
20
  search_tool = DuckDuckGoSearchRun()
21
 
22
+
23
  class ToolWrapper(BaseTool):
24
  """Wrapper for tools to make them compatible with CrewAI."""
25
 
 
34
  return await self.func(*args, **kwargs)
35
 
36
 
37
+ # Define Agents - Pass the Groq LLM directly
38
  inventory_specialist = Agent(
39
  role="Inventory Specialist",
40
  goal="Identify the best matching homes from current inventory based on customer criteria.",
 
52
  description=search_tool.description,
53
  )
54
  ],
55
+ llm=groq_llm, # Pass the Groq LLM directly
56
  )
57
 
58
  communication_specialist = Agent(
 
65
  """,
66
  verbose=True,
67
  allow_delegation=True,
68
+ llm=groq_llm, # Pass the Groq LLM directly
69
  )
70
 
71
 
 
103
 
104
 
105
  # Streamlit App
106
+ st.title("AI-Powered Real Estate Lead Response (Groq)")
107
 
108
  customer_zipcode = st.text_input("Zip Code:", placeholder="Enter zip code")
109
  customer_bedrooms = st.number_input(
 
147
  except Exception as e:
148
  st.error(f"An error occurred: {e}")
149
  st.write(
150
+ "Please check your Groq API key and ensure it has the necessary permissions."
151
  )