Skip to content

Python: 'Invalid function type detected, unable to infer DelegateType. Function: (input: str, kernel: semantic_kernel.kernel.Kernel) -> semantic_kernel.orchestration.sk_context.SKContext', None) #3365

@AliRaza190

Description

@AliRaza190

I want to return a json object from my native function but it doesn't returns that. Can anyone guide me how do I achieve that.I would prefer a python solution. The issue with native function in semantic kernel is that it can return only the follwing data types:

  • int
  • str
  • None
  • SKContext
    I want to return a SKContext object as it is not possible currently to return a JSON object . Can anyone help me on this ?

`
class CSVLoader:

def __init__(self,kernel:Kernel) -> None:
    self._kernel=kernel

@sk_function(
    description="This will load a CSV file and return the string",
    name="loadcsv",
    input_description="This is a string which is the filename of CSV file",
)
def LoadCSV(self, input: str,kernel:Kernel) -> 'SKContext':
    new_context=kernel.create_new_context()
    df=pd.read_csv(input["input"])
    for col in df.columns:
        if df[col].dtype == 'int64' or df[col].dtype == 'float64':
            df[col].fillna('', inplace=True)
        elif df[col].dtype == 'object' or df[col].dtype == 'datetime64' or df[col].dtype=='category' or df[col].dtype=='bool':
            df[col].fillna('', inplace=True)
    
    new_context=df.to_json()
    print('new',new_context)
    return new_context

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    pythonPull requests for the Python Semantic Kerneltriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions