MCPcopy Index your code
hub / github.com/AmberSahdev/Open-Interface / process_command

Method process_command

app/interpreter.py:27–49  ·  view source on GitHub ↗

Reads the passed in JSON object and extracts relevant details. Format is specified in context.txt. After interpretation, it proceeds to execute the appropriate function call. :return: True for successful execution, False for exception while interpreting or executing.

(self, json_command: dict[str, Any])

Source from the content-addressed store, hash-verified

25 return True
26
27 def process_command(self, json_command: dict[str, Any]) -> bool:
28 """
29 Reads the passed in JSON object and extracts relevant details. Format is specified in context.txt.
30 After interpretation, it proceeds to execute the appropriate function call.
31
32 :return: True for successful execution, False for exception while interpreting or executing.
33 """
34 function_name = json_command['function']
35 parameters = json_command.get('parameters', {})
36 human_readable_justification = json_command.get('human_readable_justification')
37 print(f'Now performing - {function_name} - {parameters} - {human_readable_justification}')
38 self.status_queue.put(human_readable_justification)
39 try:
40 self.execute_function(function_name, parameters)
41 return True
42 except Exception as e:
43 print(f'\nError:\nWe are having a problem executing this step - {type(e)} - {e}')
44 print(f'This was the json we received from the LLM: {json.dumps(json_command, indent=2)}')
45 print(f'This is what we extracted:')
46 print(f'\t function_name:{function_name}')
47 print(f'\t parameters:{parameters}')
48
49 return False
50
51 def execute_function(self, function_name: str, parameters: dict[str, Any]) -> None:
52 """

Callers 2

process_commandsMethod · 0.95
executeMethod · 0.80

Calls 1

execute_functionMethod · 0.95

Tested by

no test coverage detected