MCPcopy
hub / github.com/llmware-ai/llmware / function_call

Method function_call

llmware/models.py:10798–10927  ·  view source on GitHub ↗

This is the key inference method for SLIM models - takes a context passage and a key list which is packaged in the prompt as the keys for python dictionary output

(self, context, function=None, params=None, get_logits=True,
                      temperature=-99.0, max_output=None)

Source from the content-addressed store, hash-verified

10796 return output_response
10797
10798 def function_call(self, context, function=None, params=None, get_logits=True,
10799 temperature=-99.0, max_output=None):
10800
10801 """ This is the key inference method for SLIM models - takes a context passage and a key list
10802 which is packaged in the prompt as the keys for python dictionary output"""
10803
10804 if not self.fc_supported:
10805 logger.warning("GGUFGenerativeModel - loaded model does not support function calls. "
10806 "Please either use the standard .inference method with this model, or use a GGUF "
10807 "model that has 'function_calls' key set to True in its model card.")
10808 return []
10809
10810 self.context = context
10811
10812 # start with clean logits_record and output_tokens for each function call
10813 self.logits_record = []
10814 self.output_tokens = []
10815
10816 if get_logits:
10817 self.get_logits = get_logits
10818
10819 if params:
10820 self.primary_keys = params
10821
10822 if not self.primary_keys:
10823 logger.warning("GGUFGenerativeModel - function call - no keys provided - "
10824 "function call may yield unpredictable results")
10825
10826 if not params:
10827 params = self.primary_keys
10828
10829 if not function:
10830 # pull from model card
10831 if self.function:
10832 if isinstance(self.function, list):
10833 if len(self.function) > 0:
10834 function = self.function[0]
10835 else:
10836 function = self.function
10837
10838 if not function:
10839 function = "classify"
10840
10841 self.primary_keys = params
10842 self.function = function
10843
10844 # preview before initiating api call
10845 self.preview()
10846
10847 # START - route to api endpoint
10848
10849 if self.api_endpoint:
10850
10851 return self.function_call_over_api_endpoint(model_name=self.model_name,
10852 context=self.context,params=self.primary_keys,
10853 function=self.function,
10854 api_key=self.api_key,get_logits=self.get_logits)
10855

Callers

nothing calls this directly

Calls 7

_inferenceMethod · 0.95
ModelCatalogClass · 0.85
previewMethod · 0.80
formatMethod · 0.80
registerMethod · 0.80

Tested by

no test coverage detected