Skip to content

Commit

Permalink
update prompt typing hint (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZingLix authored May 16, 2024
1 parent 5ce9f73 commit c837e5f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions python/qianfan/common/prompt/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import re
import time
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, cast
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, cast

from qianfan.common.hub.interface import HubSerializable
from qianfan.config import encoding
Expand All @@ -43,7 +43,7 @@ class PromptLabel(HubSerializable):
Class of prompt label
"""

id: int
id: Union[str, int]
"""
id of the label
"""
Expand Down
14 changes: 7 additions & 7 deletions python/qianfan/resources/console/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Prompt API
"""
import re
from typing import Any, List, Optional, Tuple
from typing import Any, List, Optional, Tuple, Union

from qianfan.consts import (
Consts,
Expand Down Expand Up @@ -44,7 +44,7 @@ def create(
scene: PromptSceneType = PromptSceneType.Text2Text,
framework: PromptFrameworkType = PromptFrameworkType.NotUse,
variables: Optional[List[str]] = None,
label_ids: Optional[List[int]] = None,
label_ids: Optional[List[Union[int, str]]] = None,
negative_template: Optional[str] = None,
negative_variables: Optional[List[str]] = None,
**kwargs: Any,
Expand All @@ -68,7 +68,7 @@ def create(
automatically find variables in the template. The variables only support
English, numbers, and underscores (_), and cannot start with a number. They
must be between 2 and 30 characters in length.
label_ids (Optional[List[int]]):
label_ids (Optional[List[Union[int, str]]]):
List of label IDs associated with the prompt.
negative_template (Optional[str]):
An optional negative example template. Only available when scene is
Expand Down Expand Up @@ -171,7 +171,7 @@ def update(
cls,
id: str,
name: Optional[str] = None,
label_ids: Optional[List[int]] = None,
label_ids: Optional[List[Union[int, str]]] = None,
template: Optional[str] = None,
identifier: Optional[Literal["{}", "{{}}", "[]", "[[]]", "()", "(())"]] = None,
negative_template: Optional[str] = None,
Expand All @@ -188,7 +188,7 @@ def update(
The ID of the prompt template to update.
name (Optional[str]):
The new name for the prompt template.
label_ids (Optional[List[int]]):
label_ids (Optional[List[Union[int, str]]]):
The updated list of label IDs associated with the prompt template.
template (Optional[str]):
The modified template for the prompt.
Expand Down Expand Up @@ -259,7 +259,7 @@ def list(
offset: int = 0,
page_size: int = 10,
name: Optional[str] = None,
label_ids: List[int] = [],
label_ids: List[Union[int, str]] = [],
type: Optional[PromptType] = None,
**kwargs: Any,
) -> QfRequest:
Expand All @@ -276,7 +276,7 @@ def list(
The number of prompt templates to retrieve per page. Default is 10.
name (Optional[str]):
A filter for prompt templates by name.
label_ids (List[int]):
label_ids (List[Union[int, str]]):
A list of label IDs to filter prompt templates.
type (Optional[PromptType]):
A filter for prompt templates by type.
Expand Down

0 comments on commit c837e5f

Please sign in to comment.