How to return the result of function calling execution to the front end #9968
Replies: 2 comments 2 replies
-
note: #9408 (comment) |
Beta Was this translation helpful? Give feedback.
1 reply
-
tried it. semantic kernel 1.17.1 async def main() -> None:
kernel = Kernel()
kernel.add_service(
service=AzureChatCompletion(
service_id=app_settings.SERVICE_ID,
api_key=app_settings.OPENAI_COMPLETION_API_KEY,
deployment_name=app_settings.OPENAI_COMPLETION_DEPLOYMENT_NAME,
endpoint=app_settings.OPENAI_COMPLETION_ENDPOINT,
)
)
kernel.add_plugin(plugin=MathPlugin(), plugin_name="math")
kernel.add_plugin(plugin=TimePlugin(), plugin_name="time")
settings = kernel.get_prompt_execution_settings_from_service_id(service_id=app_settings.SERVICE_ID)
if isinstance(settings, AzureChatPromptExecutionSettings):
settings.function_choice_behavior = FunctionChoiceBehavior.Auto(auto_invoke=True)
service = kernel.get_service(service_id=app_settings.SERVICE_ID)
if not isinstance(service, AzureChatCompletion):
raise Exception("Invalid Value")
history = ChatHistory()
history.add_user_message("3 + 3 = ?\nWhat is the time in Tokyo? =")
result = service.get_streaming_chat_message_contents(
chat_history=history,
settings=settings,
kernel=kernel,
arguments=KernelArguments(settings=settings),
)
async for content in result:
if content and content[0].inner_content is None:
print(">>",content[0].items)
if content and content[0].inner_content is not None:
print(content)
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If anyone knows a good way to do this, please let me know. I am wondering how to pass information to the front-end application when an agent built with semantic kernel is function calling. For example, when I execute the following code, I get the following chunk.
It is easy to tell the front end the name and arguments of the function calling used. The chunk contains the information, so it is read. So how best to communicate the results of the plugin's execution? If anyone knows of a common method used in the openai-related ecosystem, please let me know.
Beta Was this translation helpful? Give feedback.
All reactions