Add context management and clear command to ARC1 prototype

pull/34/head
Jaronim Pracht 2025-05-04 20:32:30 +02:00
parent d753e748f0
commit 3cac55fe00
2 changed files with 21 additions and 1 deletions

View File

@ -412,10 +412,12 @@ class ChatSession:
"4. Use appropriate context from the user's question\n"
"5. Avoid simply repeating the raw data\n\n"
"Please use only the tools that are explicitly defined above."
"You can call another tool, but call them in the next call. Answer 'next tool' if you need another tool."
)
messages = [{"role": "system", "content": system_message}]
messages.append({"role": "assistant", "content": "You have to extract data from pdf files and have different tools for extracting."
"For each value there is only one correct answer, try to find it with the tools provided."})
while True:
try:
@ -424,6 +426,11 @@ class ChatSession:
logging.info("\nExiting...")
break
if user_input == "clear":
logging.info("\nClearing...")
messages = [{"role": "system", "content": system_message}]
continue
messages.append({"role": "user", "content": user_input})
llm_response = self.llm_client.get_response(messages)

View File

@ -36,6 +36,19 @@ def getFromChatGPTSingle(value: str) -> dict:
"""This tool get a single value from ChatGPT. You can use the value to specify for which key the value should calculated"""
return {"page":random.randint(1, 35), "value": random.choice(risikoProfile), "key": value}
context = ""
@mcp.tool()
def getContext() -> str:
"""This tool gets context information."""
return context
@mcp.tool()
def setContext(value: str) -> None:
"""This tool sets context information."""
global context
context = value
# Add a dynamic greeting resource
@mcp.resource("greeting://{name}")
def get_greeting(name: str) -> str: