truefoundry 0.5.3rc2__py3-none-any.whl → 0.5.3rc4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of truefoundry might be problematic. Click here for more details.
- truefoundry/autodeploy/agents/base.py +1 -1
- truefoundry/autodeploy/agents/developer.py +1 -1
- truefoundry/autodeploy/agents/project_identifier.py +1 -1
- truefoundry/autodeploy/agents/tester.py +1 -1
- truefoundry/autodeploy/tools/base.py +2 -1
- truefoundry/autodeploy/tools/commit.py +1 -1
- truefoundry/autodeploy/tools/docker_build.py +1 -1
- truefoundry/autodeploy/tools/docker_run.py +1 -1
- truefoundry/autodeploy/tools/file_type_counts.py +1 -1
- truefoundry/autodeploy/tools/list_files.py +1 -1
- truefoundry/autodeploy/tools/read_file.py +1 -2
- truefoundry/autodeploy/tools/send_request.py +1 -1
- truefoundry/autodeploy/tools/write_file.py +1 -1
- truefoundry/cli/__main__.py +4 -0
- truefoundry/cli/commands/pat.py +24 -0
- truefoundry/common/constants.py +1 -0
- truefoundry/deploy/lib/clients/servicefoundry_client.py +24 -1
- truefoundry/gateway/__init__.py +1 -0
- truefoundry/gateway/cli/cli.py +51 -0
- truefoundry/gateway/lib/client.py +51 -0
- truefoundry/gateway/lib/entities.py +33 -0
- truefoundry/gateway/lib/models.py +67 -0
- {truefoundry-0.5.3rc2.dist-info → truefoundry-0.5.3rc4.dist-info}/METADATA +1 -1
- {truefoundry-0.5.3rc2.dist-info → truefoundry-0.5.3rc4.dist-info}/RECORD +26 -20
- {truefoundry-0.5.3rc2.dist-info → truefoundry-0.5.3rc4.dist-info}/WHEEL +0 -0
- {truefoundry-0.5.3rc2.dist-info → truefoundry-0.5.3rc4.dist-info}/entry_points.txt +0 -0
|
@@ -17,12 +17,12 @@ from openai.types.chat.chat_completion_user_message_param import (
|
|
|
17
17
|
ChatCompletionUserMessageParam,
|
|
18
18
|
)
|
|
19
19
|
from openai.types.shared_params.function_definition import FunctionDefinition
|
|
20
|
-
from pydantic import BaseModel, ValidationError
|
|
21
20
|
|
|
22
21
|
from truefoundry.autodeploy.constants import AUTODEPLOY_MODEL_NAME
|
|
23
22
|
from truefoundry.autodeploy.logger import logger
|
|
24
23
|
from truefoundry.autodeploy.tools import Event, RequestEvent, Tool
|
|
25
24
|
from truefoundry.autodeploy.utils.pydantic_compat import model_dump, model_json_schema
|
|
25
|
+
from truefoundry.pydantic_v1 import BaseModel, ValidationError
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
def llm(
|
|
@@ -4,7 +4,6 @@ from typing import Dict, Optional
|
|
|
4
4
|
|
|
5
5
|
import docker
|
|
6
6
|
from openai import OpenAI
|
|
7
|
-
from pydantic import Field
|
|
8
7
|
|
|
9
8
|
from truefoundry.autodeploy.agents.base import Agent
|
|
10
9
|
from truefoundry.autodeploy.agents.project_identifier import ProjectIdentifier
|
|
@@ -18,6 +17,7 @@ from truefoundry.autodeploy.tools import (
|
|
|
18
17
|
RequestEvent,
|
|
19
18
|
ResponseEvent,
|
|
20
19
|
)
|
|
20
|
+
from truefoundry.pydantic_v1 import Field
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class Developer(Agent):
|
|
@@ -4,7 +4,6 @@ import enum
|
|
|
4
4
|
from typing import List, Optional
|
|
5
5
|
|
|
6
6
|
from openai import OpenAI
|
|
7
|
-
from pydantic import Field
|
|
8
7
|
from rich.console import Console
|
|
9
8
|
|
|
10
9
|
from truefoundry.autodeploy.agents.base import Agent
|
|
@@ -16,6 +15,7 @@ from truefoundry.autodeploy.tools import (
|
|
|
16
15
|
RequestEvent,
|
|
17
16
|
ResponseEvent,
|
|
18
17
|
)
|
|
18
|
+
from truefoundry.pydantic_v1 import Field
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class ComponentType(str, enum.Enum):
|
|
@@ -4,7 +4,6 @@ from typing import Dict, Optional
|
|
|
4
4
|
|
|
5
5
|
import docker
|
|
6
6
|
from openai import OpenAI
|
|
7
|
-
from pydantic import Field
|
|
8
7
|
from rich.console import Console
|
|
9
8
|
|
|
10
9
|
from truefoundry.autodeploy.agents.base import Agent
|
|
@@ -16,6 +15,7 @@ from truefoundry.autodeploy.tools import (
|
|
|
16
15
|
ResponseEvent,
|
|
17
16
|
SendRequest,
|
|
18
17
|
)
|
|
18
|
+
from truefoundry.pydantic_v1 import Field
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class Tester(Agent):
|
|
@@ -2,9 +2,10 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import Any, ClassVar, Generator, Optional, Protocol, Type
|
|
4
4
|
|
|
5
|
-
from pydantic import BaseModel
|
|
6
5
|
from rich.console import Console
|
|
7
6
|
|
|
7
|
+
from truefoundry.pydantic_v1 import BaseModel
|
|
8
|
+
|
|
8
9
|
|
|
9
10
|
class Event(BaseModel):
|
|
10
11
|
def render(self, _: Console) -> Optional[Any]: ...
|
|
@@ -4,7 +4,6 @@ import os
|
|
|
4
4
|
import tempfile
|
|
5
5
|
from typing import Any, Generator, Optional
|
|
6
6
|
|
|
7
|
-
from pydantic import Field
|
|
8
7
|
from rich.console import Console
|
|
9
8
|
from rich.padding import Padding
|
|
10
9
|
from rich.prompt import Confirm
|
|
@@ -20,6 +19,7 @@ from truefoundry.autodeploy.tools.base import (
|
|
|
20
19
|
from truefoundry.autodeploy.utils.client import get_git_binary
|
|
21
20
|
from truefoundry.autodeploy.utils.diff import LLMDiff
|
|
22
21
|
from truefoundry.autodeploy.utils.pydantic_compat import model_dump
|
|
22
|
+
from truefoundry.pydantic_v1 import Field
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
class CommitConfirmation(Event):
|
|
@@ -6,7 +6,6 @@ from typing import Any, Generator, Iterable, Optional
|
|
|
6
6
|
|
|
7
7
|
import docker
|
|
8
8
|
from docker.models.images import BuildError, json_stream
|
|
9
|
-
from pydantic import Field
|
|
10
9
|
from rich.console import Console, ConsoleOptions, RenderResult
|
|
11
10
|
from rich.padding import Padding
|
|
12
11
|
from rich.text import Text
|
|
@@ -19,6 +18,7 @@ from truefoundry.autodeploy.tools.base import (
|
|
|
19
18
|
Rule,
|
|
20
19
|
Tool,
|
|
21
20
|
)
|
|
21
|
+
from truefoundry.pydantic_v1 import Field
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
class DockerBuildLog(Event):
|
|
@@ -5,7 +5,6 @@ from typing import Any, Dict, Generator, List, Optional
|
|
|
5
5
|
|
|
6
6
|
import docker
|
|
7
7
|
import requests
|
|
8
|
-
from pydantic import Field
|
|
9
8
|
from rich.console import Console, ConsoleOptions, RenderResult
|
|
10
9
|
from rich.padding import Padding
|
|
11
10
|
from rich.text import Text
|
|
@@ -18,6 +17,7 @@ from truefoundry.autodeploy.tools.base import (
|
|
|
18
17
|
Rule,
|
|
19
18
|
Tool,
|
|
20
19
|
)
|
|
20
|
+
from truefoundry.pydantic_v1 import Field
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class DockerRunLog(Event):
|
|
@@ -5,7 +5,6 @@ from collections import Counter
|
|
|
5
5
|
from typing import Any, Dict, Generator
|
|
6
6
|
|
|
7
7
|
import gitignorefile
|
|
8
|
-
from pydantic import Field
|
|
9
8
|
from rich.console import Console
|
|
10
9
|
from rich.table import Table
|
|
11
10
|
|
|
@@ -17,6 +16,7 @@ from truefoundry.autodeploy.tools.base import (
|
|
|
17
16
|
Rule,
|
|
18
17
|
Tool,
|
|
19
18
|
)
|
|
19
|
+
from truefoundry.pydantic_v1 import Field
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
class ShowFileCount(Event):
|
|
@@ -5,7 +5,6 @@ from fnmatch import fnmatch
|
|
|
5
5
|
from typing import Any, Generator, List, Optional
|
|
6
6
|
|
|
7
7
|
import gitignorefile
|
|
8
|
-
from pydantic import Field
|
|
9
8
|
|
|
10
9
|
from truefoundry.autodeploy.tools.base import (
|
|
11
10
|
Event,
|
|
@@ -15,6 +14,7 @@ from truefoundry.autodeploy.tools.base import (
|
|
|
15
14
|
Rule,
|
|
16
15
|
Tool,
|
|
17
16
|
)
|
|
17
|
+
from truefoundry.pydantic_v1 import Field
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class ListFiles(Tool):
|
|
@@ -3,8 +3,6 @@ from __future__ import annotations
|
|
|
3
3
|
import os
|
|
4
4
|
from typing import Any, Generator, List, Optional
|
|
5
5
|
|
|
6
|
-
from pydantic import BaseModel, Field
|
|
7
|
-
|
|
8
6
|
from truefoundry.autodeploy.constants import MAX_FILE_SIZE_READ
|
|
9
7
|
from truefoundry.autodeploy.tools.base import (
|
|
10
8
|
Event,
|
|
@@ -14,6 +12,7 @@ from truefoundry.autodeploy.tools.base import (
|
|
|
14
12
|
Rule,
|
|
15
13
|
Tool,
|
|
16
14
|
)
|
|
15
|
+
from truefoundry.pydantic_v1 import BaseModel, Field
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
class Line(BaseModel):
|
|
@@ -3,7 +3,6 @@ from __future__ import annotations
|
|
|
3
3
|
from typing import Any, Generator, Optional
|
|
4
4
|
|
|
5
5
|
import requests
|
|
6
|
-
from pydantic import Field
|
|
7
6
|
|
|
8
7
|
from truefoundry.autodeploy.tools.base import (
|
|
9
8
|
Event,
|
|
@@ -13,6 +12,7 @@ from truefoundry.autodeploy.tools.base import (
|
|
|
13
12
|
Rule,
|
|
14
13
|
Tool,
|
|
15
14
|
)
|
|
15
|
+
from truefoundry.pydantic_v1 import Field
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
class SendRequest(Tool):
|
|
@@ -4,12 +4,12 @@ from __future__ import annotations
|
|
|
4
4
|
import os
|
|
5
5
|
from typing import Optional
|
|
6
6
|
|
|
7
|
-
from pydantic import BaseModel, Field
|
|
8
7
|
from rich.console import Console
|
|
9
8
|
from rich.prompt import Confirm
|
|
10
9
|
|
|
11
10
|
from truefoundry.autodeploy.tools.base import Tool
|
|
12
11
|
from truefoundry.autodeploy.utils.diff import Diff
|
|
12
|
+
from truefoundry.pydantic_v1 import BaseModel, Field
|
|
13
13
|
|
|
14
14
|
INTERACTIVE_SESSION = True
|
|
15
15
|
|
truefoundry/cli/__main__.py
CHANGED
|
@@ -4,6 +4,7 @@ import sys
|
|
|
4
4
|
import rich_click as click
|
|
5
5
|
|
|
6
6
|
from truefoundry import logger
|
|
7
|
+
from truefoundry.cli.commands.pat import get_generate_pat_command
|
|
7
8
|
from truefoundry.cli.config import CliConfig
|
|
8
9
|
from truefoundry.cli.const import GROUP_CLS
|
|
9
10
|
from truefoundry.cli.util import setup_rich_click
|
|
@@ -21,6 +22,7 @@ from truefoundry.deploy.cli.commands import (
|
|
|
21
22
|
get_terminate_command,
|
|
22
23
|
get_trigger_command,
|
|
23
24
|
)
|
|
25
|
+
from truefoundry.gateway.cli.cli import get_gateway_cli
|
|
24
26
|
from truefoundry.ml.cli.cli import get_ml_cli
|
|
25
27
|
from truefoundry.version import __version__
|
|
26
28
|
|
|
@@ -88,6 +90,8 @@ def create_truefoundry_cli() -> click.MultiCommand:
|
|
|
88
90
|
cli.add_command(get_trigger_command())
|
|
89
91
|
cli.add_command(get_terminate_command())
|
|
90
92
|
cli.add_command(get_ml_cli())
|
|
93
|
+
cli.add_command(get_gateway_cli())
|
|
94
|
+
cli.add_command(get_generate_pat_command())
|
|
91
95
|
|
|
92
96
|
if not (sys.platform.startswith("win32") or sys.platform.startswith("cygwin")):
|
|
93
97
|
cli.add_command(get_patch_command())
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from truefoundry.cli.console import console
|
|
4
|
+
from truefoundry.cli.const import COMMAND_CLS
|
|
5
|
+
from truefoundry.deploy.lib.clients.servicefoundry_client import (
|
|
6
|
+
ServiceFoundryServiceClient,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@click.command(cls=COMMAND_CLS, name="generate-api-key")
|
|
11
|
+
@click.option(
|
|
12
|
+
"--name",
|
|
13
|
+
required=True,
|
|
14
|
+
help="Name for the API key",
|
|
15
|
+
)
|
|
16
|
+
def generate_pat(name: str):
|
|
17
|
+
"""Generate a new Personal Access Token with specified name"""
|
|
18
|
+
client = ServiceFoundryServiceClient()
|
|
19
|
+
pat = client.create_pat(name)
|
|
20
|
+
console.print(pat)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def get_generate_pat_command():
|
|
24
|
+
return generate_pat
|
truefoundry/common/constants.py
CHANGED
|
@@ -4,7 +4,7 @@ import json
|
|
|
4
4
|
import os
|
|
5
5
|
import time
|
|
6
6
|
from datetime import datetime, timezone
|
|
7
|
-
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
|
7
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional
|
|
8
8
|
from urllib.parse import urljoin
|
|
9
9
|
|
|
10
10
|
import requests
|
|
@@ -43,6 +43,7 @@ from truefoundry.deploy.v2.lib.models import (
|
|
|
43
43
|
BuildResponse,
|
|
44
44
|
DeploymentFqnResponse,
|
|
45
45
|
)
|
|
46
|
+
from truefoundry.gateway.lib.entities import ProviderModels
|
|
46
47
|
from truefoundry.logger import logger
|
|
47
48
|
from truefoundry.pydantic_v1 import parse_obj_as
|
|
48
49
|
|
|
@@ -708,3 +709,25 @@ class ServiceFoundryServiceClient(BaseServiceFoundryServiceClient):
|
|
|
708
709
|
)
|
|
709
710
|
response_data = request_handling(response)
|
|
710
711
|
return response_data
|
|
712
|
+
|
|
713
|
+
def get_gateway_models(
|
|
714
|
+
self, model_type: Optional[Literal["chat", "completion", "embedding"]] = None
|
|
715
|
+
) -> ProviderModels:
|
|
716
|
+
url = f"{self._api_server_url}/{VERSION_PREFIX}/llm-gateway/model/enabled"
|
|
717
|
+
params = {}
|
|
718
|
+
if model_type:
|
|
719
|
+
params["modelType"] = model_type
|
|
720
|
+
response = session_with_retries().get(
|
|
721
|
+
url, headers=self._get_header(), params=params
|
|
722
|
+
)
|
|
723
|
+
response = request_handling(response)
|
|
724
|
+
return parse_obj_as(ProviderModels, response)
|
|
725
|
+
|
|
726
|
+
def create_pat(self, name: str):
|
|
727
|
+
url = f"{self._api_server_url}/{VERSION_PREFIX}/service-account/pat"
|
|
728
|
+
body = {"name": name}
|
|
729
|
+
response = session_with_retries().post(
|
|
730
|
+
url, headers=self._get_header(), json=body
|
|
731
|
+
)
|
|
732
|
+
response = request_handling(response)
|
|
733
|
+
return response
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Gateway module for Truefoundry CLI"""
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from truefoundry.cli.const import COMMAND_CLS, GROUP_CLS
|
|
4
|
+
from truefoundry.cli.display_util import print_entity_list
|
|
5
|
+
from truefoundry.gateway.lib.models import generate_code_for_model, list_models
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def get_gateway_cli():
|
|
9
|
+
@click.group(cls=GROUP_CLS, help="Commands to interact with TrueFoundry Gateway")
|
|
10
|
+
def gateway(): ...
|
|
11
|
+
|
|
12
|
+
@gateway.group("list", cls=GROUP_CLS, help="List gateway resources")
|
|
13
|
+
def list_group():
|
|
14
|
+
"""List gateway resources"""
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
@list_group.command(
|
|
18
|
+
"models", cls=COMMAND_CLS, help="List available models filtered by type"
|
|
19
|
+
)
|
|
20
|
+
@click.option(
|
|
21
|
+
"--type",
|
|
22
|
+
"model_type",
|
|
23
|
+
type=click.Choice(["chat", "completion", "embedding"]),
|
|
24
|
+
help="Filter models by type",
|
|
25
|
+
)
|
|
26
|
+
def list_models_cli(model_type: str):
|
|
27
|
+
enabled_models = list_models(model_type)
|
|
28
|
+
print_entity_list("Models", enabled_models)
|
|
29
|
+
|
|
30
|
+
@gateway.command("generate-code", cls=COMMAND_CLS, help="Generate code for a model")
|
|
31
|
+
@click.argument("model_id")
|
|
32
|
+
@click.option(
|
|
33
|
+
"--inference-type",
|
|
34
|
+
type=click.Choice(["chat", "completion", "embedding"]),
|
|
35
|
+
default="chat",
|
|
36
|
+
help="Type of inference to generate code for",
|
|
37
|
+
)
|
|
38
|
+
@click.option(
|
|
39
|
+
"--client",
|
|
40
|
+
type=click.Choice(["openai", "rest", "langchain", "stream", "node", "curl"]),
|
|
41
|
+
default="curl",
|
|
42
|
+
help="Language/framework to generate code for",
|
|
43
|
+
)
|
|
44
|
+
def generate_code_cli(model_id: str, inference_type: str, client: str):
|
|
45
|
+
"""Generate code for a model"""
|
|
46
|
+
code = generate_code_for_model(
|
|
47
|
+
model_id, client=client, inference_type=inference_type
|
|
48
|
+
)
|
|
49
|
+
print(code)
|
|
50
|
+
|
|
51
|
+
return gateway
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from typing import Literal, Optional
|
|
2
|
+
|
|
3
|
+
import requests
|
|
4
|
+
|
|
5
|
+
from truefoundry.common.constants import GATEWAY_SERVER_RELATIVE_PATH
|
|
6
|
+
from truefoundry.common.credential_provider import (
|
|
7
|
+
CredentialProvider,
|
|
8
|
+
EnvCredentialProvider,
|
|
9
|
+
FileCredentialProvider,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class GatewayServiceClient:
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
credential_provider: Optional[CredentialProvider] = None,
|
|
17
|
+
host: Optional[str] = None,
|
|
18
|
+
) -> None:
|
|
19
|
+
if credential_provider is None:
|
|
20
|
+
if EnvCredentialProvider.can_provide():
|
|
21
|
+
credential_provider = EnvCredentialProvider()
|
|
22
|
+
elif FileCredentialProvider.can_provide():
|
|
23
|
+
credential_provider = FileCredentialProvider()
|
|
24
|
+
else:
|
|
25
|
+
raise Exception(
|
|
26
|
+
"No credentials found. Please login using `tfy login` or set TFY_API_KEY environment variable"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
self._credential_provider = credential_provider
|
|
30
|
+
self._host = credential_provider.base_url
|
|
31
|
+
|
|
32
|
+
def _get_header(self):
|
|
33
|
+
return {
|
|
34
|
+
"Authorization": f"Bearer {self._credential_provider.token.access_token}"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def _base_url(self) -> str:
|
|
39
|
+
return f"{self._host}/{GATEWAY_SERVER_RELATIVE_PATH}"
|
|
40
|
+
|
|
41
|
+
def generate_code(
|
|
42
|
+
self, model_id: str, inference_type: Literal["chat", "completion", "embedding"]
|
|
43
|
+
) -> str:
|
|
44
|
+
url = f"{self._base_url}/api/inference/openai/generate-code-snippet"
|
|
45
|
+
data = {
|
|
46
|
+
"model": model_id,
|
|
47
|
+
"playground_endpoint": self._base_url,
|
|
48
|
+
"inference_type": inference_type,
|
|
49
|
+
}
|
|
50
|
+
response = requests.post(url, headers=self._get_header(), json=data)
|
|
51
|
+
return response.json()
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from typing import Any, Dict, List, Optional, Union
|
|
2
|
+
|
|
3
|
+
from truefoundry.pydantic_v1 import BaseModel
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class GatewayModel(BaseModel):
|
|
7
|
+
id: str
|
|
8
|
+
name: str
|
|
9
|
+
provider: str
|
|
10
|
+
model_id: Optional[str]
|
|
11
|
+
provider_account_name: str
|
|
12
|
+
tfy_application_id: Optional[str] = None
|
|
13
|
+
enabled: bool = True
|
|
14
|
+
types: Union[str, List[str]] = ""
|
|
15
|
+
created_by: str
|
|
16
|
+
tenant_name: str
|
|
17
|
+
model_fqn: str
|
|
18
|
+
|
|
19
|
+
def list_row_data(self) -> Dict[str, Any]:
|
|
20
|
+
model_display = self.model_fqn
|
|
21
|
+
provider_display = self.provider
|
|
22
|
+
if self.model_id:
|
|
23
|
+
provider_display = f"{self.provider} ({self.model_id})"
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
"model": model_display,
|
|
27
|
+
"provider": provider_display,
|
|
28
|
+
"type": self.types if isinstance(self.types, str) else ", ".join(self.types)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class ProviderModels(BaseModel):
|
|
33
|
+
__root__: Dict[str, Dict[str, List[GatewayModel]]]
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from typing import List, Literal, Optional
|
|
2
|
+
|
|
3
|
+
from truefoundry.deploy.lib.clients.servicefoundry_client import (
|
|
4
|
+
ServiceFoundryServiceClient,
|
|
5
|
+
)
|
|
6
|
+
from truefoundry.gateway.lib.client import GatewayServiceClient
|
|
7
|
+
from truefoundry.gateway.lib.entities import GatewayModel
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def list_models(
|
|
11
|
+
model_type: Optional[Literal["chat", "completion", "embedding"]] = None,
|
|
12
|
+
) -> List[GatewayModel]:
|
|
13
|
+
"""List available models filtered by type
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
model_type (Optional[str], optional): Filter models by type ('chat' or 'completion'). Defaults to None.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
List: List of enabled models
|
|
20
|
+
"""
|
|
21
|
+
client = ServiceFoundryServiceClient()
|
|
22
|
+
models = client.get_gateway_models(model_type)
|
|
23
|
+
|
|
24
|
+
enabled_models = []
|
|
25
|
+
for _, accounts in models.__root__.items():
|
|
26
|
+
for _, model_list in accounts.items():
|
|
27
|
+
for model in model_list:
|
|
28
|
+
enabled_models.append(model)
|
|
29
|
+
|
|
30
|
+
return enabled_models
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def generate_code_for_model(
|
|
34
|
+
model_id: str,
|
|
35
|
+
client: Literal["openai", "rest", "langchain", "stream", "node", "curl"] = "curl",
|
|
36
|
+
inference_type: Literal["chat", "completion", "embedding"] = "chat",
|
|
37
|
+
) -> str:
|
|
38
|
+
"""Generate code snippet for using a model in the specified language/framework
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
model_id (str): ID of the model to generate code for
|
|
42
|
+
language (Literal["openai", "rest", "langchain", "stream", "node", "curl"]): Language/framework to generate code for. Defaults to "curl"
|
|
43
|
+
inference_type (Literal["chat", "completion", "embedding"]): Type of inference to generate code for. Defaults to "chat"
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
str: Code snippet for using the model in the specified language/framework
|
|
47
|
+
"""
|
|
48
|
+
gateway_client = GatewayServiceClient()
|
|
49
|
+
response = gateway_client.generate_code(model_id, inference_type)
|
|
50
|
+
|
|
51
|
+
code_map = {
|
|
52
|
+
"openai": ("openai_code", "Python code using OpenAI SDK for direct API calls"),
|
|
53
|
+
"rest": ("rest_code", "Python code using requests library for REST API calls"),
|
|
54
|
+
"langchain": (
|
|
55
|
+
"langchain_code",
|
|
56
|
+
"Python code using LangChain framework for LLM integration",
|
|
57
|
+
),
|
|
58
|
+
"stream": ("stream_code", "Python code with streaming response handling"),
|
|
59
|
+
"node": ("node_code", "Node.js code using Axios for API calls"),
|
|
60
|
+
"curl": ("curl_code", "cURL command for direct API access via terminal"),
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
code_key, description = code_map[client]
|
|
64
|
+
if code_key in response and response[code_key]:
|
|
65
|
+
return f"{description}\n{response[code_key]}"
|
|
66
|
+
|
|
67
|
+
return "No code snippet available for the specified language"
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
truefoundry/__init__.py,sha256=jynqfY0pDmcaXlxewDnMQC5CYAIW9JFjptBrw7y76rY,81
|
|
2
2
|
truefoundry/autodeploy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
truefoundry/autodeploy/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
truefoundry/autodeploy/agents/base.py,sha256=
|
|
5
|
-
truefoundry/autodeploy/agents/developer.py,sha256=
|
|
6
|
-
truefoundry/autodeploy/agents/project_identifier.py,sha256=
|
|
7
|
-
truefoundry/autodeploy/agents/tester.py,sha256=
|
|
4
|
+
truefoundry/autodeploy/agents/base.py,sha256=lYw6bKhfCWff5BbtXXn2k4MjMbRIUkOwPBjRT70iXE8,6420
|
|
5
|
+
truefoundry/autodeploy/agents/developer.py,sha256=tO9vmgGjoaqK4rX-DFCyMrViFC2Oqofd89WoXqsEm-A,4142
|
|
6
|
+
truefoundry/autodeploy/agents/project_identifier.py,sha256=KlF7FwrGHDCjF3y3-YaCDxZ8kE34s6XPBagXhG2U1aM,4520
|
|
7
|
+
truefoundry/autodeploy/agents/tester.py,sha256=lqvVBuVcFRvGZnSLAUF2r-1-Yti20o_cbybU19IlSXo,2418
|
|
8
8
|
truefoundry/autodeploy/cli.py,sha256=1VnDAP9ylM6l00v0Ko5KL6_Dr7bL_voeAPdbEvWvU3Y,14215
|
|
9
9
|
truefoundry/autodeploy/constants.py,sha256=vTh2nA7cjqghqbW2rNh3FbtcIk2scdAWZuuQCmVBO80,1273
|
|
10
10
|
truefoundry/autodeploy/exception.py,sha256=fa_ZyTDUKiMKG2Uayynk1yWcEMsuVluqk2GtV4tfTPU,158
|
|
11
11
|
truefoundry/autodeploy/logger.py,sha256=tkV2UKcOTFl5nz0cn4eRbzxF-2CZd8b7MK9vnhaflYw,325
|
|
12
12
|
truefoundry/autodeploy/tools/__init__.py,sha256=9zJiC1d4bv9EL-p5XTCa9fAQ6ZKV--AbgeLz9bBBkyQ,875
|
|
13
13
|
truefoundry/autodeploy/tools/ask.py,sha256=MxUFLP7rjpdJ85gCc3El0wUqTZDjpjAw7WOTdV4LLWE,856
|
|
14
|
-
truefoundry/autodeploy/tools/base.py,sha256=
|
|
15
|
-
truefoundry/autodeploy/tools/commit.py,sha256=
|
|
16
|
-
truefoundry/autodeploy/tools/docker_build.py,sha256=
|
|
17
|
-
truefoundry/autodeploy/tools/docker_run.py,sha256=
|
|
18
|
-
truefoundry/autodeploy/tools/file_type_counts.py,sha256=
|
|
19
|
-
truefoundry/autodeploy/tools/list_files.py,sha256=
|
|
20
|
-
truefoundry/autodeploy/tools/read_file.py,sha256=
|
|
21
|
-
truefoundry/autodeploy/tools/send_request.py,sha256=
|
|
22
|
-
truefoundry/autodeploy/tools/write_file.py,sha256=
|
|
14
|
+
truefoundry/autodeploy/tools/base.py,sha256=Ltzj2d6DO1gUMx_qSt2c2Zq91MJ5V4FJXpZwl4T3F8M,795
|
|
15
|
+
truefoundry/autodeploy/tools/commit.py,sha256=MXqPnCnMHagvimSCCBGYsAbNdl7k1pf05BBBRjOP8b8,6051
|
|
16
|
+
truefoundry/autodeploy/tools/docker_build.py,sha256=tAG62G1bk-kYrbRykieXxU48nkOlv3IcAv25k6zdTz8,4015
|
|
17
|
+
truefoundry/autodeploy/tools/docker_run.py,sha256=PuiIvF41_L3JJN_EyoU-PAr2YkZEu0C9XX0ABcTFoJk,5076
|
|
18
|
+
truefoundry/autodeploy/tools/file_type_counts.py,sha256=DUcULN0S2qIrZKTTTfz7GXeRy6RKtHSIeVkeECeEQZw,2369
|
|
19
|
+
truefoundry/autodeploy/tools/list_files.py,sha256=HNZdsz-m-Jxf5yrf2bn7kRplIsNACP69Ozd4bpjlGMk,2657
|
|
20
|
+
truefoundry/autodeploy/tools/read_file.py,sha256=ZpgTNef2-plWEoX4UHcVFVzHmNGoqZrvVUn1OVY_rrE,2268
|
|
21
|
+
truefoundry/autodeploy/tools/send_request.py,sha256=Ea6MG0esSik7ZtWNIx9yTHlKJ593CQc11bET_YeRZgc,1703
|
|
22
|
+
truefoundry/autodeploy/tools/write_file.py,sha256=tSO8LEwVJZbF17zva7FWE426_-C8pB5FVwc1vClpFjY,3145
|
|
23
23
|
truefoundry/autodeploy/utils/client.py,sha256=PvbSkfgAjAogGjisinqmh4mP4svowxAC0IwzEQz3Ai0,453
|
|
24
24
|
truefoundry/autodeploy/utils/diff.py,sha256=Ef8Y-VffDKel_-q-GxRam6gqiv8qTLMcqVg6iifXfcA,5358
|
|
25
25
|
truefoundry/autodeploy/utils/pydantic_compat.py,sha256=hEAUy5kLjhPdzw7yGZ2iXGMXbbMVXVlGzIofmyHafXQ,412
|
|
26
26
|
truefoundry/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
-
truefoundry/cli/__main__.py,sha256=
|
|
27
|
+
truefoundry/cli/__main__.py,sha256=mYgMZRvI3sBP3_6DA0WwtFUZQTV3r8gJpMFvMJb-OOE,3692
|
|
28
|
+
truefoundry/cli/commands/pat.py,sha256=0rm95ny1b3KfeBJSRWh1M4lR46ERnp96ovUZKu-P5Ss,602
|
|
28
29
|
truefoundry/cli/config.py,sha256=tf8w4UfVzcC6eYkENvuuCPYt_V3sqVpO1bclORV9tAk,206
|
|
29
30
|
truefoundry/cli/console.py,sha256=9-dMy4YPisCJQziRKTg8Qa0UJnOGl1soiUnJjsnLDvE,242
|
|
30
31
|
truefoundry/cli/const.py,sha256=dVHPo1uAiDSSMXwXoT2mR5kNQjExT98QNVRz98Hz_Ts,510
|
|
@@ -32,7 +33,7 @@ truefoundry/cli/display_util.py,sha256=vypx4FQImmDwl2QAj7GpjwlpvG3VFhqoNPvCkBzGq
|
|
|
32
33
|
truefoundry/cli/util.py,sha256=yA8sie7TBTOu-5QFf2zEFWYEKYcBCaV6o1gtctj1dtI,3390
|
|
33
34
|
truefoundry/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
35
|
truefoundry/common/auth_service_client.py,sha256=RRiGUqITxeVYwKZLc923zJP-61UAvFtVlMaG2HJBvXc,7940
|
|
35
|
-
truefoundry/common/constants.py,sha256=
|
|
36
|
+
truefoundry/common/constants.py,sha256=VbwTn5nzdUnG8u50_dnq_zWwcLf5PXFinhhSogsOAys,2667
|
|
36
37
|
truefoundry/common/credential_file_manager.py,sha256=1yEk1Zm2xS4G0VDFwKSZ4w0VUrcPWQ1nJnoBaz9xyKA,4251
|
|
37
38
|
truefoundry/common/credential_provider.py,sha256=Aht7hFLsnyRgMR34dRbzln7dor0WYSeA8ej8ApNmnKM,4148
|
|
38
39
|
truefoundry/common/entities.py,sha256=8O-EGPk4PKqnyoFMKUTxISCU19rz0KBnfRDJU695DhY,3797
|
|
@@ -80,7 +81,7 @@ truefoundry/deploy/io/rich_output_callback.py,sha256=TJLiRD-EnFVwgcepxR7WN0koKqW
|
|
|
80
81
|
truefoundry/deploy/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
81
82
|
truefoundry/deploy/lib/auth/servicefoundry_session.py,sha256=5TCYPunAygtn5mb0mp_VcWKEalKMKPbyWMWer-Vty2g,1916
|
|
82
83
|
truefoundry/deploy/lib/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
83
|
-
truefoundry/deploy/lib/clients/servicefoundry_client.py,sha256=
|
|
84
|
+
truefoundry/deploy/lib/clients/servicefoundry_client.py,sha256=zx9c-TjQRzMDKGCa-wDvXEX_8FcWH1QlVif2SjxgLxs,27136
|
|
84
85
|
truefoundry/deploy/lib/const.py,sha256=Wg0GDnfFu-g1fJr4lU80NH2ULw0R0dYjV7LnW-PbOeM,173
|
|
85
86
|
truefoundry/deploy/lib/dao/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
86
87
|
truefoundry/deploy/lib/dao/application.py,sha256=xUqF34abde71YZo9gkR-WvVJi1C6nBeGBNw4kL5FdIo,9226
|
|
@@ -103,6 +104,11 @@ truefoundry/deploy/v2/lib/deployable_patched_models.py,sha256=MROgMxhn9hDEAKwJSW
|
|
|
103
104
|
truefoundry/deploy/v2/lib/models.py,sha256=pSolLMTArDuYpeNsmeeS5DWliloN_iCDfZSpRllMHUg,1120
|
|
104
105
|
truefoundry/deploy/v2/lib/patched_models.py,sha256=NTU8J_CwdvEuF9zNXwFyN3suOp_196Wrm75DDy5qcXE,14184
|
|
105
106
|
truefoundry/deploy/v2/lib/source.py,sha256=VHKuFREiixUP40D3Mrz-TA70spu1M0RbCzl--qwlFaY,9263
|
|
107
|
+
truefoundry/gateway/__init__.py,sha256=HvAMuk60-fuZcMmdOtozHrUaH_JcbEHxpMSlS9ci4ls,41
|
|
108
|
+
truefoundry/gateway/cli/cli.py,sha256=SPEHNP210QtK7G97KOOP6t6QBxgCq2YUezgx65QZToM,1715
|
|
109
|
+
truefoundry/gateway/lib/client.py,sha256=6E9gTl_rOCwcrx5fJkUzbZqacJmgXtSXd1mcmDk9bCA,1717
|
|
110
|
+
truefoundry/gateway/lib/entities.py,sha256=DoYS9QAKjiVao-CH9j9LVUPlVFdeHqJ3xC7-pYhmAyM,918
|
|
111
|
+
truefoundry/gateway/lib/models.py,sha256=0JUsLt2oNf0bBea_03ndDmUkZhNqvMmixh8zgxaH2lk,2600
|
|
106
112
|
truefoundry/logger.py,sha256=u-YCNjg5HBwE70uQcpjIG64Ghos-K2ulTWaxC03BSj4,714
|
|
107
113
|
truefoundry/ml/__init__.py,sha256=ssUEIs8BixPWxynKoeSh-dkRl6AtLXG0PBGYnUR5Az8,2217
|
|
108
114
|
truefoundry/ml/artifact/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -368,7 +374,7 @@ truefoundry/workflow/remote_filesystem/tfy_signed_url_client.py,sha256=5mBCIc-ON
|
|
|
368
374
|
truefoundry/workflow/remote_filesystem/tfy_signed_url_fs.py,sha256=Hf6Dk6Fu6P7DqsK5ULgraf9DStjgigf-kjaRAMBW-RU,8680
|
|
369
375
|
truefoundry/workflow/task.py,sha256=ToitYiKcNzFCtOVQwz1W8sRjbR97eVS7vQBdbgUQtKg,1779
|
|
370
376
|
truefoundry/workflow/workflow.py,sha256=WaTqUjhwfAXDWu4E5ehuwAxrCbDJkoAf1oWmR2E9Qy0,4575
|
|
371
|
-
truefoundry-0.5.
|
|
372
|
-
truefoundry-0.5.
|
|
373
|
-
truefoundry-0.5.
|
|
374
|
-
truefoundry-0.5.
|
|
377
|
+
truefoundry-0.5.3rc4.dist-info/METADATA,sha256=qPTGfmHQVmxxL_jBbf7CJI6fDI1LkOpkSfeBXSqLRpY,2887
|
|
378
|
+
truefoundry-0.5.3rc4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
379
|
+
truefoundry-0.5.3rc4.dist-info/entry_points.txt,sha256=TXvUxQkI6zmqJuycPsyxEIMr3oqfDjgrWj0m_9X12x4,95
|
|
380
|
+
truefoundry-0.5.3rc4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|