Add context management and clear command to ARC1 prototype
parent
d753e748f0
commit
3cac55fe00
|
|
@ -412,10 +412,12 @@ class ChatSession:
|
||||||
"4. Use appropriate context from the user's question\n"
|
"4. Use appropriate context from the user's question\n"
|
||||||
"5. Avoid simply repeating the raw data\n\n"
|
"5. Avoid simply repeating the raw data\n\n"
|
||||||
"Please use only the tools that are explicitly defined above."
|
"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 = [{"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:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
|
@ -424,6 +426,11 @@ class ChatSession:
|
||||||
logging.info("\nExiting...")
|
logging.info("\nExiting...")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if user_input == "clear":
|
||||||
|
logging.info("\nClearing...")
|
||||||
|
messages = [{"role": "system", "content": system_message}]
|
||||||
|
continue
|
||||||
|
|
||||||
messages.append({"role": "user", "content": user_input})
|
messages.append({"role": "user", "content": user_input})
|
||||||
|
|
||||||
llm_response = self.llm_client.get_response(messages)
|
llm_response = self.llm_client.get_response(messages)
|
||||||
|
|
|
||||||
|
|
@ -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"""
|
"""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}
|
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
|
# Add a dynamic greeting resource
|
||||||
@mcp.resource("greeting://{name}")
|
@mcp.resource("greeting://{name}")
|
||||||
def get_greeting(name: str) -> str:
|
def get_greeting(name: str) -> str:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue