alnzng commented on code in PR #168:
URL: https://github.com/apache/flink-agents/pull/168#discussion_r2353330298
##########
.github/workflows/ci.yml:
##########
@@ -98,7 +98,7 @@ jobs:
fail-fast: false
matrix:
os: [ 'macos-latest', 'ubuntu-latest' ]
- python-version: [ '3.9', '3.10', '3.11' ]
+ python-version: [ '3.10', '3.11' ]
Review Comment:
Thank you for disabling Python `3.9`, this will help unblock my PR!
##########
python/flink_agents/api/prompts/prompt.py:
##########
@@ -15,39 +15,57 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#################################################################################
-from typing import List, Sequence, Union
+from abc import ABC, abstractmethod
+from typing import List, Sequence
+
+from typing_extensions import override
from flink_agents.api.chat_message import ChatMessage, MessageRole
from flink_agents.api.prompts.utils import format_string
from flink_agents.api.resource import ResourceType, SerializableResource
-class Prompt(SerializableResource):
- """Prompt for a language model.
-
- Attributes:
- ----------
- template : Union[Sequence[ChatMessage], str]
- The prompt template.
- """
-
- template: Union[Sequence[ChatMessage], str]
+class Prompt(SerializableResource, ABC):
+ """Base prompt abstract."""
@staticmethod
def from_messages(name: str, messages: Sequence[ChatMessage]) -> "Prompt":
"""Create prompt from sequence of ChatMessage."""
- return Prompt(name=name, template=messages)
+ return LocalPrompt(name=name, template=messages)
@staticmethod
def from_text(name: str, text: str) -> "Prompt":
"""Create prompt from text string."""
- return Prompt(name=name, template=text)
+ return LocalPrompt(name=name, template=text)
+
+ @abstractmethod
+ def format_string(self, **kwargs: str) -> str:
+ """Generate text string from template with additional arguments."""
+
+ @abstractmethod
+ def format_messages(
+ self, role: MessageRole = MessageRole.SYSTEM, **kwargs: str
+ ) -> List[ChatMessage]:
+ """Generate list of ChatMessage from template with additional
arguments."""
@classmethod
+ @override
def resource_type(cls) -> ResourceType:
"""Get the resource type."""
return ResourceType.PROMPT
+
+class LocalPrompt(Prompt):
+ """Prompt for a language model.
+
+ Attributes:
+ ----------
+ template : Union[Sequence[ChatMessage], str]
Review Comment:
nit: change to new syntax `Sequence[ChatMessage] | str`
##########
python/flink_agents/api/resource.py:
##########
@@ -35,7 +35,7 @@ class ResourceType(Enum):
EMBEDDING_MODEL_CONNECTION = "embedding_model_connection"
PROMPT = "prompt"
# VECTOR_STORE = "vector_store"
- # MCP_SERVER = "mcp_server"
+ MCP_SERVER = "mcp_server"
Review Comment:
Should we add this in `ResourceType.java`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]