# Copyright 2022 Soul Machines Ltd

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#     http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# generated by datamodel-codegen:
#   filename:  skill-api.yml
#   timestamp: 2022-01-19T20:00:28+00:00

from __future__ import annotations

from typing import Any, Dict, List, Optional

from pydantic import BaseModel, Extra, Field


class Intent(BaseModel):
    name: Optional[str] = Field(
        None,
        description="""Name of intent that handled the request or 'NO_MATCH' if a
            fallback is hit""",
    )
    confidence: Optional[float] = Field(
        None, description="Confidence of the intent matched in the range 0-1"
    )


class Variables(BaseModel):
    class Config:
        extra = Extra.allow

    public: Optional[Dict[str, Any]] = None


class Output(BaseModel):
    text: Optional[str] = None
    variables: Optional[Variables] = None


class Memory(BaseModel):
    class Config:
        extra = Extra.allow


class ExecuteRequest(BaseModel):
    projectId: str = Field(
        ..., description="(Future functionality) Salted hash of DDNA Studio Project ID"
    )
    sessionId: str = Field(
        ..., description="A unique identifier for this particular session"
    )
    intent: Optional[Intent] = None
    text: str = Field(..., description="User input")
    memory: List[Memory] = Field(
        ...,
        description="""Information stored from the most recent response received from
            the endpoint""",
    )
    context: Optional[Dict[str, Any]] = Field(
        None, description="Used to send DP specific data e.g. EQ data"
    )
    config: Optional[Dict[str, Any]] = Field(
        None,
        description="""Skill configuration data will be included in this object. This
            property will only be  included if the skill is stateless (i.e. no
            sessionEndpoint is provided).\n""",
    )


class ExecuteResponse(BaseModel):
    output: Optional[Output] = None
    intent: Optional[Intent] = None
    memory: Optional[List[Memory]] = None
    endConversation: bool = Field(
        ...,
        description="""Used to indicate whether the current interaction with the skill
            should be concluded.  Set to false if you want the skill to handle
            further conversation turns with the user.\n""",
    )


class SessionRequest(BaseModel):
    projectId: str = Field(
        ..., description="(Future functionality) Salted hash of DDNA Studio Project ID"
    )
    sessionId: str
    config: Optional[Dict[str, Any]] = None
    memory: Optional[List[Memory]] = None


class SessionResponse(BaseModel):
    memory: Optional[List[Memory]] = None
