Skip to content

Commit

Permalink
make sync
Browse files Browse the repository at this point in the history
  • Loading branch information
0thernet committed Jun 10, 2024
1 parent 28d17c0 commit 85c116d
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 223 deletions.
2 changes: 1 addition & 1 deletion substrate/GEN_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20240530.20240531
20240604.20240610
10 changes: 3 additions & 7 deletions substrate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
𐃏 Substrate Python SDK
20240530.20240531
20240604.20240610
"""

from .nodes import (
Expand Down Expand Up @@ -32,21 +32,19 @@
RemoveBackground,
BatchGenerateJSON,
BatchGenerateText,
CreateVectorStore,
DeleteVectorStore,
Llama3Instruct70B,
Mistral7BInstruct,
MultiGenerateJSON,
MultiGenerateText,
SegmentUnderPoint,
StableDiffusionXL,
GenerateTextVision,
MultiGenerateImage,
GenerativeEditImage,
Mixtral8x7BInstruct,
FindOrCreateVectorStore,
MultiGenerativeEditImage,
StableDiffusionXLInpaint,
StableDiffusionXLIPAdapter,
StableDiffusionXLLightning,
StableDiffusionXLControlNet,
)
Expand Down Expand Up @@ -77,11 +75,9 @@
"MultiGenerateImage",
"GenerativeEditImage",
"MultiGenerativeEditImage",
"StableDiffusionXL",
"StableDiffusionXLLightning",
"StableDiffusionXLInpaint",
"StableDiffusionXLControlNet",
"StableDiffusionXLIPAdapter",
"TranscribeMedia",
"GenerateSpeech",
"XTTSV2",
Expand All @@ -96,7 +92,7 @@
"MultiEmbedImage",
"JinaV2",
"CLIP",
"CreateVectorStore",
"FindOrCreateVectorStore",
"ListVectorStores",
"DeleteVectorStore",
"QueryVectorStore",
Expand Down
67 changes: 20 additions & 47 deletions substrate/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@

from __future__ import annotations

import os
from typing import Any, Dict, List, Optional

use_pydantic_v1 = os.getenv("USE_PYDANTIC_V1", "0").lower() == "1"

if use_pydantic_v1:
from pydantic.v1 import Field, BaseModel
else:
from pydantic import Field, BaseModel

from typing_extensions import Literal, Annotated

from pydantic import Field, BaseModel


class ErrorOut(BaseModel):
type: Literal["api_error", "invalid_request_error"]
Expand Down Expand Up @@ -54,13 +47,17 @@ class ExperimentalOut(BaseModel):


class RunPythonIn(BaseModel):
code: str
function: str
"""
Pickled function.
"""
Python code to execute. In your code, access values from the `input` parameter using the `SB_IN` variable. Update the `SB_OUT` variable with results you want returned in `output`.
arguments: str
"""
input: Optional[Dict[str, Any]] = None
Pickled arguments.
"""
Input to your code, accessible using the preloaded `SB_IN` variable.
python_version: Optional[str] = None
"""
Python version.
"""
pip_install: Optional[List[str]] = None
"""
Expand All @@ -73,9 +70,9 @@ class RunPythonOut(BaseModel):
"""
Everything printed to stdout while running your code.
"""
output: Dict[str, Any]
output: Optional[Dict[str, Any]] = None
"""
Contents of the `SB_OUT` variable after running your code.
Return value of your function.
"""
stderr: str
"""
Expand All @@ -101,7 +98,7 @@ class GenerateTextIn(BaseModel):
"Mixtral8x7BInstruct",
"Llama3Instruct8B",
"Llama3Instruct70B",
] = "Mistral7BInstruct"
] = "Llama3Instruct8B"
"""
Selected node.
"""
Expand Down Expand Up @@ -131,7 +128,7 @@ class GenerateJSONIn(BaseModel):
"""
Maximum number of tokens to generate.
"""
node: Literal["Mistral7BInstruct", "Mixtral8x7BInstruct", "Llama3Instruct8B"] = "Mistral7BInstruct"
node: Literal["Mistral7BInstruct", "Mixtral8x7BInstruct", "Llama3Instruct8B"] = "Llama3Instruct8B"
"""
Selected node.
"""
Expand Down Expand Up @@ -170,7 +167,7 @@ class MultiGenerateTextIn(BaseModel):
"Mixtral8x7BInstruct",
"Llama3Instruct8B",
"Llama3Instruct70B",
] = "Mistral7BInstruct"
] = "Llama3Instruct8B"
"""
Selected node.
"""
Expand Down Expand Up @@ -226,7 +223,7 @@ class MultiGenerateJSONIn(BaseModel):
"""
Maximum number of tokens to generate.
"""
node: Literal["Mistral7BInstruct", "Mixtral8x7BInstruct", "Llama3Instruct8B"] = "Mistral7BInstruct"
node: Literal["Mistral7BInstruct", "Mixtral8x7BInstruct", "Llama3Instruct8B"] = "Llama3Instruct8B"
"""
Selected node.
"""
Expand All @@ -240,7 +237,7 @@ class MultiGenerateJSONOut(BaseModel):


class BatchGenerateJSONIn(BaseModel):
node: Literal["Mistral7BInstruct", "Llama3Instruct8B"] = "Mistral7BInstruct"
node: Literal["Mistral7BInstruct", "Llama3Instruct8B"] = "Llama3Instruct8B"
"""
Selected node.
"""
Expand Down Expand Up @@ -1355,7 +1352,7 @@ class CLIPOut(BaseModel):
"""


class CreateVectorStoreIn(BaseModel):
class FindOrCreateVectorStoreIn(BaseModel):
collection_name: Annotated[str, Field(max_length=63, min_length=1)]
"""
Vector store name.
Expand All @@ -1364,21 +1361,9 @@ class CreateVectorStoreIn(BaseModel):
"""
Selected embedding model.
"""
m: Annotated[int, Field(ge=1, le=64)] = 16
"""
The max number of connections per layer for the index.
"""
ef_construction: Annotated[int, Field(ge=1, le=128)] = 64
"""
The size of the dynamic candidate list for constructing the index graph.
"""
metric: Literal["cosine", "l2", "inner"] = "inner"
"""
The distance metric to construct the index with.
"""


class CreateVectorStoreOut(BaseModel):
class FindOrCreateVectorStoreOut(BaseModel):
collection_name: Annotated[str, Field(max_length=63, min_length=1)]
"""
Vector store name.
Expand All @@ -1387,26 +1372,14 @@ class CreateVectorStoreOut(BaseModel):
"""
Selected embedding model.
"""
m: Annotated[int, Field(ge=1, le=64)]
"""
The max number of connections per layer for the index.
"""
ef_construction: Annotated[int, Field(ge=1, le=128)]
"""
The size of the dynamic candidate list for constructing the index graph.
"""
metric: Literal["cosine", "l2", "inner"]
"""
The distance metric to construct the index with.
"""


class ListVectorStoresIn(BaseModel):
pass


class ListVectorStoresOut(BaseModel):
items: Optional[List[CreateVectorStoreOut]] = None
items: Optional[List[FindOrCreateVectorStoreOut]] = None
"""
List of vector stores.
"""
Expand Down
71 changes: 23 additions & 48 deletions substrate/future_dataclass_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,20 @@ class FutureRunPythonIn:
Future reference to FutureRunPythonIn
"""

code: str
function: str
"""
(Future reference)
Python code to execute. In your code, access values from the `input` parameter using the `SB_IN` variable. Update the `SB_OUT` variable with results you want returned in `output`.
Pickled function.
"""
input: Optional[Dict[str, Any]] = None
arguments: str
"""
(Future reference)
Input to your code, accessible using the preloaded `SB_IN` variable.
Pickled arguments.
"""
python_version: Optional[str] = None
"""
(Future reference)
Python version.
"""
pip_install: Optional[List[str]] = None
"""
Expand All @@ -100,15 +105,15 @@ class FutureRunPythonOut:
(Future reference)
Everything printed to stdout while running your code.
"""
output: Dict[str, Any]
stderr: str
"""
(Future reference)
Contents of the `SB_OUT` variable after running your code.
Contents of stderr if your code did not run successfully.
"""
stderr: str
output: Optional[Dict[str, Any]] = None
"""
(Future reference)
Contents of stderr if your code did not run successfully.
Return value of your function.
"""


Expand Down Expand Up @@ -138,7 +143,7 @@ class FutureGenerateTextIn:
"Mixtral8x7BInstruct",
"Llama3Instruct8B",
"Llama3Instruct70B",
] = "Mistral7BInstruct"
] = "Llama3Instruct8B"
"""
(Future reference)
Selected node.
Expand Down Expand Up @@ -184,7 +189,7 @@ class FutureGenerateJSONIn:
(Future reference)
Maximum number of tokens to generate.
"""
node: Literal["Mistral7BInstruct", "Mixtral8x7BInstruct", "Llama3Instruct8B"] = "Mistral7BInstruct"
node: Literal["Mistral7BInstruct", "Mixtral8x7BInstruct", "Llama3Instruct8B"] = "Llama3Instruct8B"
"""
(Future reference)
Selected node.
Expand Down Expand Up @@ -240,7 +245,7 @@ class FutureMultiGenerateTextIn:
"Mixtral8x7BInstruct",
"Llama3Instruct8B",
"Llama3Instruct70B",
] = "Mistral7BInstruct"
] = "Llama3Instruct8B"
"""
(Future reference)
Selected node.
Expand Down Expand Up @@ -327,7 +332,7 @@ class FutureMultiGenerateJSONIn:
(Future reference)
Maximum number of tokens to generate.
"""
node: Literal["Mistral7BInstruct", "Mixtral8x7BInstruct", "Llama3Instruct8B"] = "Mistral7BInstruct"
node: Literal["Mistral7BInstruct", "Mixtral8x7BInstruct", "Llama3Instruct8B"] = "Llama3Instruct8B"
"""
(Future reference)
Selected node.
Expand Down Expand Up @@ -363,7 +368,7 @@ class FutureBatchGenerateJSONIn:
(Future reference)
JSON schema to guide `json_object` response.
"""
node: Literal["Mistral7BInstruct", "Llama3Instruct8B"] = "Mistral7BInstruct"
node: Literal["Mistral7BInstruct", "Llama3Instruct8B"] = "Llama3Instruct8B"
"""
(Future reference)
Selected node.
Expand Down Expand Up @@ -2083,9 +2088,9 @@ class FutureCLIPOut:


@dataclass
class FutureCreateVectorStoreIn:
class FutureFindOrCreateVectorStoreIn:
"""
Future reference to FutureCreateVectorStoreIn
Future reference to FutureFindOrCreateVectorStoreIn
"""

collection_name: str
Expand All @@ -2098,27 +2103,12 @@ class FutureCreateVectorStoreIn:
(Future reference)
Selected embedding model.
"""
m: int = 16
"""
(Future reference)
The max number of connections per layer for the index.
"""
ef_construction: int = 64
"""
(Future reference)
The size of the dynamic candidate list for constructing the index graph.
"""
metric: Literal["cosine", "l2", "inner"] = "inner"
"""
(Future reference)
The distance metric to construct the index with.
"""


@dataclass
class FutureCreateVectorStoreOut:
class FutureFindOrCreateVectorStoreOut:
"""
Future reference to FutureCreateVectorStoreOut
Future reference to FutureFindOrCreateVectorStoreOut
"""

collection_name: str
Expand All @@ -2131,21 +2121,6 @@ class FutureCreateVectorStoreOut:
(Future reference)
Selected embedding model.
"""
m: int
"""
(Future reference)
The max number of connections per layer for the index.
"""
ef_construction: int
"""
(Future reference)
The size of the dynamic candidate list for constructing the index graph.
"""
metric: Literal["cosine", "l2", "inner"]
"""
(Future reference)
The distance metric to construct the index with.
"""


@dataclass
Expand All @@ -2163,7 +2138,7 @@ class FutureListVectorStoresOut:
Future reference to FutureListVectorStoresOut
"""

items: Optional[List[FutureCreateVectorStoreOut]] = None
items: Optional[List[FutureFindOrCreateVectorStoreOut]] = None
"""
(Future reference)
List of vector stores.
Expand Down
Loading

0 comments on commit 85c116d

Please sign in to comment.