nitind1 commited on
Commit
4498613
·
verified ·
1 Parent(s): d547b0c

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -16,6 +16,11 @@ from langchain_community.utilities.sql_database import SQLDatabase
16
  from langchain_community.agent_toolkits import create_sql_agent
17
  from langchain.agents import create_tool_calling_agent, AgentExecutor
18
  from langchain_core.tools import tool
 
 
 
 
 
19
 
20
 
21
  from huggingface_hub import CommitScheduler
@@ -29,8 +34,8 @@ model_name = "gpt-4o-mini"
29
 
30
  # Extract the OpenAI key and endpoint from the configuration
31
 
32
- api_key = config.get("API_KEY")
33
- endpoint = config.get("OPENAI_API_BASE")
34
 
35
 
36
  # Define the location of the SQLite database
@@ -200,8 +205,8 @@ retriever = vector_store.as_retriever(
200
 
201
 
202
  client = OpenAI(
203
- api_key=creds["API_KEY"],
204
- base_url=creds["OPENAI_API_BASE"]
205
  )
206
 
207
 
@@ -303,7 +308,8 @@ def defer_to_human(customer_id, query, intent, reason):
303
  query (str): The customer's query or issue that needs human intervention.
304
  reason (str): The reason why the query cannot be resolved by the chatbot.
305
  Returns:
306
- str: Success message indicating the deferral was logged.
 
307
  """
308
 
309
  details = {
 
16
  from langchain_community.agent_toolkits import create_sql_agent
17
  from langchain.agents import create_tool_calling_agent, AgentExecutor
18
  from langchain_core.tools import tool
19
+ from langchain.memory import ConversationSummaryBufferMemory
20
+ from openai import OpenAI
21
+ from langchain_openai import ChatOpenAI
22
+ from langchain.embeddings import OpenAIEmbeddings
23
+ from langchain_openai import OpenAIEmbeddings
24
 
25
 
26
  from huggingface_hub import CommitScheduler
 
34
 
35
  # Extract the OpenAI key and endpoint from the configuration
36
 
37
+ api_key = os.environ["API_KEY"]
38
+ endpoint = os.environ["OPENAI_API_BASE"]
39
 
40
 
41
  # Define the location of the SQLite database
 
205
 
206
 
207
  client = OpenAI(
208
+ api_key=api_key,
209
+ base_url=endpoint
210
  )
211
 
212
 
 
308
  query (str): The customer's query or issue that needs human intervention.
309
  reason (str): The reason why the query cannot be resolved by the chatbot.
310
  Returns:
311
+ st
312
+ r: Success message indicating the deferral was logged.
313
  """
314
 
315
  details = {