Spaces:
Runtime error
Runtime error
Upload app.py with huggingface_hub
Browse files
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 =
|
| 33 |
-
endpoint =
|
| 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=
|
| 204 |
-
base_url=
|
| 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 |
-
|
|
|
|
| 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 = {
|