-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.Net: New Feature: How to pass the object returned by the first call of function calling to the function called the second time? #10669
Comments
@SergeyMenshykh do we have a sample showing how to do this? |
@1754581267, in your second function, do you need to access exactly the same instance returned by the first function, or does it not matter as long as all the properties of the object the second function is called with are equal to the ones returned by the first function? Please provide the functions and the Cat class signatures along with the value returned by the first function and the argument(s) the second function is called with. CC: @moonbox3 |
The SK I am using is python version. I need to let SK pass the object created in the function call correctly to the function used in the subsequent conversation. Cat is an example. Now the situation is that the parameters received by the subsequent function should be the object, but now it is a string from semantic_kernel.functions import kernel_function
class Cat:
name = ""
age = 0
def __init__(self):
self.name = ""
self.age = 0
def createCat(self, name: str, age: int) -> object:
"""
creates a new Cat object
:param name:
:param age:
:return: object
"""
print("Creating cat")
self.name = name + "159"
self.age = age
return self
def get_name(self, o: object) -> str:
"""
gets name of the Cat object
:param o: Cat
:return:
"""
print("Getting name", o)
return o.name from semantic_kernel.functions import kernel_function
from script.entity.Cat import Cat
class TestPlugin:
@kernel_function()
def create_cat(self, name: str, age: int) -> object:
"""
creates a new Cat object
:param name:
:param age:
:return:
"""
cat = Cat().createCat(name, age)
return cat
@kernel_function()
def get_name(self, cat: Cat) -> str:
"""
gets name of the Cat object
:return: str
"""
return Cat.get_name(cat)
if __name__ == '__main__':
cat = TestPlugin().create_cat('test', 12)
print(cat.get_name()) The conversation is:
|
I solved this problem in my own way, but I want to get the official solution |
How to pass the object returned by the first call of function calling to the function called the second time? Similar to: the first function generates a cat, and the second function gets the name of the cat
The text was updated successfully, but these errors were encountered: