Вот соответствующий код для настройки ядра и плагина:< /p>
Код: Выделить всё
# Kernel and service setup
kernel = Kernel()
execution_settings = AzureChatPromptExecutionSettings(tool_choice="auto")
execution_settings.function_choice_behavior = FunctionChoiceBehavior.Auto(filters={})
openai_client = OpenAI(api_key=api_key)
chat_completion_service = OpenAIChatCompletion(
ai_model_id=model_id,
api_key=api_key,
service_id=service_id
)
# Add services and plugins
kernel.add_service(chat_completion_service)
kernel.add_plugin(MovesPlugin(openai_client), plugin_name='MovesPlugin')
Код: Выделить всё
# Inside FastAPI endpoint
@app.post("/chat/")
async def chat(request: Request):
session_id = await request.json().get('session_id')
# Get chat completion service
_chat_completion_service = kernel.get_service(type=ChatCompletionClientBase)
# Get chat completion response
response = await _chat_completion_service.get_chat_message_content(
chat_history=chat_history,
kernel=kernel,
settings=execution_settings
)
return response
Код: Выделить всё
session_idБудем очень признательны за любые рекомендации и предложения!< /п>
Подробнее здесь: https://stackoverflow.com/questions/792 ... in-for-ope
Мобильная версия