Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -104,22 +104,25 @@ prompt = ChatPromptTemplate.from_messages([
|
|
| 104 |
|
| 105 |
def state_modifier(state) -> list[BaseMessage]:
|
| 106 |
collection_files = "None"
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
)
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
# Create the agent with the Python execution tool
|
| 125 |
agent = create_react_agent(
|
|
|
|
| 104 |
|
| 105 |
def state_modifier(state) -> list[BaseMessage]:
|
| 106 |
collection_files = "None"
|
| 107 |
+
try:
|
| 108 |
+
formatted_prompt = prompt.invoke({
|
| 109 |
+
"collection_files": collection_files,
|
| 110 |
+
"messages": state["messages"]
|
| 111 |
+
})
|
| 112 |
+
|
| 113 |
+
return trim_messages(
|
| 114 |
+
formatted_prompt,
|
| 115 |
+
token_counter=len,
|
| 116 |
+
max_tokens=16000,
|
| 117 |
+
strategy="last",
|
| 118 |
+
start_on="human",
|
| 119 |
+
include_system=True,
|
| 120 |
+
allow_partial=False,
|
| 121 |
+
)
|
| 122 |
+
print(state["messages"])
|
| 123 |
+
except Exception as e:
|
| 124 |
+
print(f"Error in state modifier: {str(e)}")
|
| 125 |
+
return state["messages"]
|
| 126 |
|
| 127 |
# Create the agent with the Python execution tool
|
| 128 |
agent = create_react_agent(
|