Spaces:
Sleeping
Sleeping
File size: 2,078 Bytes
bd468ee 374834e bd468ee | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
"""
Pydantic schemas for the Rag Optimizer environment.
These define the API contract between the client (agent) and the server.
"""
from typing import Dict, Literal, Optional
from pydantic import BaseModel, Field
class RagOptimizerAction(BaseModel):
"""
Actions the agent can take to interact with the Knowledge Base.
"""
action_type: Literal["read_document", "update_document", "delete_document", "add_metadata", "submit"] = Field(
...,
description="The RAG optimization tool to execute."
)
doc_id: Optional[str] = Field(
None,
description="The ID of the document to target."
)
text: Optional[str] = Field(
None,
description="The text content (used for update_document)."
)
metadata_key: Optional[str] = Field(
None,
description="The key of the metadata tag (used for add_metadata)."
)
metadata_value: Optional[str] = Field(
None,
description="The value of the metadata tag (used for add_metadata)."
)
class RagOptimizerObservation(BaseModel):
"""
The environment's response to an action, including the state of the KB.
"""
message: str = Field(
...,
description="Feedback from the last action (e.g., success/error messages)."
)
current_docs: Dict[str, Dict] = Field(
...,
description="A live summary of the documents currently inside the KB (doc_id -> metadata/length)."
)
# Required OpenEnv standard fields
done: bool = Field(False, description="Whether the episode has finished.")
reward: float = Field(0.01, description="The reward obtained from the last step.")
metadata: Dict = Field(default_factory=dict, description="Additional optional information.")
|