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

Method function_call

llmware/models.py:3623–3790  ·  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 the dictionary output

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

Source from the content-addressed store, hash-verified

3621 return top_logits
3622
3623 def function_call(self, context, function=None, params=None, get_logits=True,
3624 temperature=-99, max_output=None):
3625
3626 """ This is the key inference method for SLIM models - takes a context passage and a key list
3627 which is packaged in the prompt as the keys for the dictionary output"""
3628
3629 from llmware.configs import ONNXConfig
3630 legacy = ONNXConfig().get_legacy_flag()
3631
3632 t0 = time.time()
3633
3634 self.context = context
3635
3636 if not self.fc_supported:
3637 logger.warning(f"ONNXGenerativeModel - loaded model does not support function calls. "
3638 "Please either use the standard .inference method with this model, or use a "
3639 "model that has 'function_calls' key set to True in its model card.")
3640 return []
3641
3642 # reset and start from scratch with new function call
3643 self.output_tokens = []
3644 self.logits_record = []
3645
3646 if temperature != -99:
3647 self.temperature = temperature
3648
3649 if max_output:
3650 self.target_requested_output_tokens = max_output
3651
3652 if get_logits:
3653 self.get_logits = get_logits
3654
3655 if params:
3656 self.primary_keys = params
3657
3658 if function:
3659 self.function = function
3660
3661 if not self.primary_keys:
3662 logger.warning(f"ONNXGenerativeModel - function call - no keys provided - "
3663 f"function call may yield unpredictable results")
3664
3665 self.preview()
3666
3667 # START - route to api endpoint
3668
3669 if self.api_endpoint:
3670 return self.function_call_over_api_endpoint(model_name=self.model_name,
3671 context=self.context, params=self.primary_keys,
3672 function=self.function,
3673 api_key=self.api_key, get_logits=self.get_logits)
3674
3675 # END - route to api endpoint
3676
3677 prompt = self.fc_prompt_engineer(self.context, params=self.primary_keys, function=self.function)
3678
3679 input_tokens = self.tokenizer.encode(prompt)
3680

Callers

nothing calls this directly

Calls 12

fc_prompt_engineerMethod · 0.95
register_top_logitsMethod · 0.95
ONNXConfigClass · 0.90
LLMWareExceptionClass · 0.90
ModelCatalogClass · 0.85
get_legacy_flagMethod · 0.80
previewMethod · 0.80
encodeMethod · 0.80
decodeMethod · 0.80
registerMethod · 0.80

Tested by

no test coverage detected