Spaces:
Running
Running
mriusero
commited on
Commit
·
08f1a87
1
Parent(s):
154d8ef
feat: thoughts UI
Browse files
chroma_db/chroma.sqlite3
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 876544
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eab9f96d6137088ecaffae8550b0e71edca4f34455fa9ae8025ff9c634a8a83b
|
3 |
size 876544
|
chroma_db/d365f4bc-8099-45f4-bdc0-9c299960820d/length.bin
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 40000
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f11db32cb916fca1af5c42ae827128c3d54709e1b2f7fa688d8dc1e206b18f1b
|
3 |
size 40000
|
src/agent/stream.py
CHANGED
@@ -150,6 +150,11 @@ async def respond(message, history=None, state=None):
|
|
150 |
if current_phase == "act":
|
151 |
tool_calls = getattr(delta, "tool_calls", None)
|
152 |
if tool_calls and tool_calls != [] and str(tool_calls) != "Unset()":
|
|
|
|
|
|
|
|
|
|
|
153 |
async with tool_lock:
|
154 |
messages = call_tool(
|
155 |
agent,
|
@@ -158,11 +163,11 @@ async def respond(message, history=None, state=None):
|
|
158 |
)
|
159 |
last_tool_response = next((m for m in reversed(messages) if m["role"] == "tool"), None)
|
160 |
if last_tool_response and last_tool_response.get("content"):
|
161 |
-
|
162 |
|
163 |
parent_message = next((msg for msg in history if msg.metadata.get("id") == state['cycle']), None)
|
164 |
if parent_message:
|
165 |
-
parent_message.content += "\n\n" + buffer
|
166 |
parent_message.metadata["title"] = "Acting..."
|
167 |
else:
|
168 |
history[-1] = ChatMessage(role="assistant", content=buffer, metadata={"title": "Acting...", "status": "pending", "id": state['cycle']+1, 'parent_id': state["cycle"]})
|
|
|
150 |
if current_phase == "act":
|
151 |
tool_calls = getattr(delta, "tool_calls", None)
|
152 |
if tool_calls and tool_calls != [] and str(tool_calls) != "Unset()":
|
153 |
+
|
154 |
+
for tool_call in tool_calls:
|
155 |
+
fn_name = tool_call.function.name
|
156 |
+
fn_args = json.loads(tool_call.function.arguments)
|
157 |
+
|
158 |
async with tool_lock:
|
159 |
messages = call_tool(
|
160 |
agent,
|
|
|
163 |
)
|
164 |
last_tool_response = next((m for m in reversed(messages) if m["role"] == "tool"), None)
|
165 |
if last_tool_response and last_tool_response.get("content"):
|
166 |
+
output = last_tool_response["content"]
|
167 |
|
168 |
parent_message = next((msg for msg in history if msg.metadata.get("id") == state['cycle']), None)
|
169 |
if parent_message:
|
170 |
+
parent_message.content += "\n\n" + buffer + f"\n\nTool: `{fn_name}`\nArgs: `{fn_args}`\n\n" + output + '\n\n'
|
171 |
parent_message.metadata["title"] = "Acting..."
|
172 |
else:
|
173 |
history[-1] = ChatMessage(role="assistant", content=buffer, metadata={"title": "Acting...", "status": "pending", "id": state['cycle']+1, 'parent_id': state["cycle"]})
|
src/agent/tools/check_downtines.py
CHANGED
@@ -15,9 +15,9 @@ def get_downtimes() -> str:
|
|
15 |
data = json.loads(json_string)
|
16 |
|
17 |
if data is None or len(data) == 0 or data == "[]":
|
18 |
-
result = "No downtimes recorded yet. Please check the production status or wait for downtimes to occur."
|
19 |
else:
|
20 |
-
result = "
|
21 |
result += json_string
|
22 |
|
23 |
return result
|
|
|
15 |
data = json.loads(json_string)
|
16 |
|
17 |
if data is None or len(data) == 0 or data == "[]":
|
18 |
+
result = "'No downtimes recorded yet. Please check the production status or wait for downtimes to occur.'"
|
19 |
else:
|
20 |
+
result = "##### Downtimes:\n\n"
|
21 |
result += json_string
|
22 |
|
23 |
return result
|
src/agent/tools/check_production.py
CHANGED
@@ -13,12 +13,12 @@ def get_production_status() -> str:
|
|
13 |
data = json.loads(json_string)
|
14 |
|
15 |
if data == {}:
|
16 |
-
result = "
|
17 |
|
18 |
elif data["opening_time"] == "0 days 00:00:00":
|
19 |
-
result = "Production has not started yet."
|
20 |
else:
|
21 |
-
result = "
|
22 |
result += json_string
|
23 |
|
24 |
return result
|
|
|
13 |
data = json.loads(json_string)
|
14 |
|
15 |
if data == {}:
|
16 |
+
result = "'production has not started yet.'"
|
17 |
|
18 |
elif data["opening_time"] == "0 days 00:00:00":
|
19 |
+
result = "'Production has not started yet.'"
|
20 |
else:
|
21 |
+
result = "##### Production status:\n\n"
|
22 |
result += json_string
|
23 |
|
24 |
return result
|
src/agent/tools/retrieve_knowledge.py
CHANGED
@@ -5,13 +5,13 @@ def format_the(query, results):
|
|
5 |
if results == "No relevant data found in the knowledge database. Have you checked any webpages or use any tools? If so, please try to find more relevant data.":
|
6 |
return results
|
7 |
else:
|
8 |
-
formatted_text = f"
|
9 |
formatted_text += f"Fetched {len(results['documents'])} relevant documents.\n\n"
|
10 |
try:
|
11 |
for i in range(len(results['documents'])):
|
12 |
-
formatted_text += f"
|
13 |
formatted_text += f"- Content: '''\n{results['documents'][i]}\n'''\n"
|
14 |
-
formatted_text += f"- Metadata: {results['metadatas'][i]}\n"
|
15 |
formatted_text += f"---\n\n"
|
16 |
except Exception as e:
|
17 |
return f"Error: Index out of range. Please check the results structure. {str(e)}"
|
|
|
5 |
if results == "No relevant data found in the knowledge database. Have you checked any webpages or use any tools? If so, please try to find more relevant data.":
|
6 |
return results
|
7 |
else:
|
8 |
+
formatted_text = f"#### Knowledge for '{query}' \n\n"
|
9 |
formatted_text += f"Fetched {len(results['documents'])} relevant documents.\n\n"
|
10 |
try:
|
11 |
for i in range(len(results['documents'])):
|
12 |
+
formatted_text += f"##### Document {i + 1} ---\n"
|
13 |
formatted_text += f"- Content: '''\n{results['documents'][i]}\n'''\n"
|
14 |
+
#formatted_text += f"- Metadata: {results['metadatas'][i]}\n"
|
15 |
formatted_text += f"---\n\n"
|
16 |
except Exception as e:
|
17 |
return f"Error: Index out of range. Please check the results structure. {str(e)}"
|