Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mmabrouk committed Dec 5, 2023
1 parent cdbeca9 commit 9e5a35a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions agenta-cli/agenta/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
MultipleChoiceParam,
MessagesInput,
TextParam,
FileInputURL,
)
from .sdk.utils.preinit import PreInitObject
from .sdk.agenta_init import Config, init
Expand Down
1 change: 1 addition & 0 deletions agenta-cli/agenta/sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
MultipleChoiceParam,
TextParam,
MessagesInput,
FileInputURL,
)
from .agenta_init import Config, init

Expand Down
8 changes: 8 additions & 0 deletions agenta-cli/agenta/sdk/agenta_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
MultipleChoiceParam,
TextParam,
MessagesInput,
FileInputURL,
)

app = FastAPI()
Expand Down Expand Up @@ -314,6 +315,7 @@ def override_schema(openapi_schema: dict, func_name: str, endpoint: str, params:
- The min and max values for each IntParam instance
- The default value for DictInput instance
- The default value for MessagesParam instance
- The default value for FileInputURL instance
- ... [PLEASE ADD AT EACH CHANGE]
Args:
Expand Down Expand Up @@ -380,3 +382,9 @@ def find_in_schema(schema: dict, param_name: str, xparam: str):
):
subschema = find_in_schema(schema_to_override, param_name, "messages")
subschema["default"] = param_val.default
if (
isinstance(param_val, inspect.Parameter)
and param_val.annotation is FileInputURL
):
subschema = find_in_schema(schema_to_override, param_name, "file_url")
subschema["default"] = "https://example.com"
8 changes: 7 additions & 1 deletion agenta-cli/agenta/sdk/types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from typing import Any, Dict, List

from pydantic import BaseModel, Extra
from pydantic import BaseModel, Extra, HttpUrl


class InFile:
Expand Down Expand Up @@ -125,6 +125,12 @@ def __modify_schema__(cls, field_schema: dict[str, Any]):
field_schema.update({"x-parameter": "messages", "type": "array"})


class FileInputURL(HttpUrl):
@classmethod
def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None:
field_schema.update({"x-parameter": "file_url", "type": "string"})


class Context(BaseModel):
class Config:
extra = Extra.allow
Expand Down
2 changes: 1 addition & 1 deletion agenta-cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "agenta"
version = "0.6.1"
version = "0.6.2"
description = "The SDK for agenta is an open-source LLMOps platform."
readme = "README.md"
authors = ["Mahmoud Mabrouk <[email protected]>"]
Expand Down

0 comments on commit 9e5a35a

Please sign in to comment.