Spaces:
Runtime error
Runtime error
Update Modules/Agent_HCP.py
Browse files- Modules/Agent_HCP.py +5 -4
Modules/Agent_HCP.py
CHANGED
|
@@ -29,7 +29,7 @@ from langchain_core.runnables import (
|
|
| 29 |
from langchain_core.runnables.history import RunnableWithMessageHistory
|
| 30 |
from typing import Optional
|
| 31 |
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
| 32 |
-
|
| 33 |
|
| 34 |
|
| 35 |
# Load the API_Keys
|
|
@@ -43,11 +43,12 @@ model = ChatGroq(temperature=0,
|
|
| 43 |
model_name="llama3-70b-8192"
|
| 44 |
)
|
| 45 |
try:
|
| 46 |
-
db = SQLDatabase.from_uri("sqlite:///
|
| 47 |
-
except
|
| 48 |
print(f"Database error: {e}")
|
| 49 |
print(f"Database path: {Modules.DATA_BASE}")
|
| 50 |
-
|
|
|
|
| 51 |
|
| 52 |
custom_prompt = PromptTemplate(
|
| 53 |
input_variables=['agent_scratchpad', 'input', 'history'], # Ajout de 'history' comme variable d'entrée
|
|
|
|
| 29 |
from langchain_core.runnables.history import RunnableWithMessageHistory
|
| 30 |
from typing import Optional
|
| 31 |
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
| 32 |
+
import sqlalchemy
|
| 33 |
|
| 34 |
|
| 35 |
# Load the API_Keys
|
|
|
|
| 43 |
model_name="llama3-70b-8192"
|
| 44 |
)
|
| 45 |
try:
|
| 46 |
+
db = SQLDatabase.from_uri(f"sqlite:///{Modules.DATA_BASE}", sample_rows_in_table_info=5)
|
| 47 |
+
except DatabaseError as e:
|
| 48 |
print(f"Database error: {e}")
|
| 49 |
print(f"Database path: {Modules.DATA_BASE}")
|
| 50 |
+
except sqlalchemy.exc.SQLAlchemyError as e:
|
| 51 |
+
print(f"SQLAlchemy error: {e}")
|
| 52 |
|
| 53 |
custom_prompt = PromptTemplate(
|
| 54 |
input_variables=['agent_scratchpad', 'input', 'history'], # Ajout de 'history' comme variable d'entrée
|