Vidhi00 commited on
Commit
6f49ee8
·
verified ·
1 Parent(s): c0cbdeb

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +19 -20
app.py CHANGED
@@ -41,6 +41,12 @@ model_name = "gpt-4o-mini"
41
  api_key = os.getenv("OPENAI_API_KEY")
42
  endpoint = os.getenv("OPENAI_API_BASE")
43
 
 
 
 
 
 
 
44
  # Define the location of the SQLite database
45
  db_loc = 'ecomm.db'
46
 
@@ -108,13 +114,6 @@ full_prompt = ChatPromptTemplate.from_messages(
108
  ]
109
  )
110
 
111
- #Initialize the ChatOpenAI model with the extracted configuration
112
- llm = ChatOpenAI(
113
- openai_api_base=endpoint,
114
- openai_api_key=api_key,
115
- model="gpt-4o-mini", # Fill in the deployment name (e.g., gpt-4o-mini)
116
- streaming=False)
117
-
118
 
119
  # Create the SQL agent using the ChatOpenAI model, database, and prompt template
120
  sqlite_agent = create_sql_agent(
@@ -260,10 +259,10 @@ retriever = vector_store.as_retriever(
260
  search_kwargs={'k': 5}
261
  )
262
 
263
- client = OpenAI(
264
- api_key=api_key,
265
- base_url=endpoint
266
- )
267
 
268
  @tool
269
  def rag(user_input: str) -> str:
@@ -290,7 +289,7 @@ def rag(user_input: str) -> str:
290
  }
291
  ]
292
  try:
293
- response = client.chat.completions.create(
294
  model="gpt-4o-mini",
295
  messages=prompt
296
  )
@@ -550,15 +549,15 @@ def chatbot_interface():
550
  tools = [sql_tool,defer_to_human, rag, register_feedback, days_since]
551
 
552
 
553
- chatbot = ChatOpenAI(
554
- openai_api_base=endpoint,
555
- openai_api_key=api_key,
556
- model="gpt-4o-mini",
557
- streaming=False, # Explicitly disabling streaming
558
- temperature=0
559
- )
560
 
561
- agent = create_tool_calling_agent(chatbot, tools, prompt)
562
  agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
563
 
564
  # Display chat messages from history on app rerun
 
41
  api_key = os.getenv("OPENAI_API_KEY")
42
  endpoint = os.getenv("OPENAI_API_BASE")
43
 
44
+ llm = ChatOpenAI(
45
+ openai_api_base=endpoint, # Fill in the endpoint
46
+ openai_api_key=api_key, # Fill in the API key
47
+ model="gpt-4o-mini", # Fill in the deployment name (e.g., gpt-4o-mini)
48
+ streaming=False)
49
+
50
  # Define the location of the SQLite database
51
  db_loc = 'ecomm.db'
52
 
 
114
  ]
115
  )
116
 
 
 
 
 
 
 
 
117
 
118
  # Create the SQL agent using the ChatOpenAI model, database, and prompt template
119
  sqlite_agent = create_sql_agent(
 
259
  search_kwargs={'k': 5}
260
  )
261
 
262
+ # client = OpenAI(
263
+ # api_key=api_key,
264
+ # base_url=endpoint
265
+ # )
266
 
267
  @tool
268
  def rag(user_input: str) -> str:
 
289
  }
290
  ]
291
  try:
292
+ response = llm.chat.completions.create(
293
  model="gpt-4o-mini",
294
  messages=prompt
295
  )
 
549
  tools = [sql_tool,defer_to_human, rag, register_feedback, days_since]
550
 
551
 
552
+ # chatbot = ChatOpenAI(
553
+ # openai_api_base=endpoint,
554
+ # openai_api_key=api_key,
555
+ # model="gpt-4o-mini",
556
+ # streaming=False, # Explicitly disabling streaming
557
+ # temperature=0
558
+ # )
559
 
560
+ agent = create_tool_calling_agent(llm, tools, prompt)
561
  agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
562
 
563
  # Display chat messages from history on app rerun