From e8a2d23f03985abb0508d474b4c132cdb1c90067 Mon Sep 17 00:00:00 2001 From: benzguo Date: Thu, 13 Jun 2024 11:22:58 -0400 Subject: [PATCH] wip --- examples/basic.py | 7 +- substrate/core/models.py | 331 ++++++++++++++++++++++++++- substrate/future_dataclass_models.py | 5 +- substrate/nodes.py | 100 +++++++- substrate/typeddict_models.py | 5 +- 5 files changed, 427 insertions(+), 21 deletions(-) diff --git a/examples/basic.py b/examples/basic.py index 1204e5b..62aa40b 100755 --- a/examples/basic.py +++ b/examples/basic.py @@ -10,14 +10,15 @@ if api_key is None: raise EnvironmentError("No SUBSTRATE_API_KEY set") -from substrate import Substrate, GenerateText, sb +from substrate import Substrate, GenerateText substrate = Substrate(api_key=api_key, timeout=60 * 5) story = GenerateText(prompt="tell me a story") -summary = GenerateText(prompt=sb.concat("Summarize this story: ", story.future.text)) +# summary = GenerateText(prompt=sb.concat("Summarize this story: ", story.future.text)) -response = substrate.run(story, summary) +# response = substrate.run(story, summary) +response = substrate.run(story) print(response.api_response.json) print(response.api_response.status_code) diff --git a/substrate/core/models.py b/substrate/core/models.py index 83afea1..a1fee99 100644 --- a/substrate/core/models.py +++ b/substrate/core/models.py @@ -1,7 +1,6 @@ """ -𐃏 Substrate -@generated file -(using datamodel-codegen) +֍ Substrate +generated file """ @@ -10,10 +9,13 @@ from typing import Any, Dict, List, Optional from typing_extensions import Literal, Annotated -from pydantic import Field, BaseModel +from pydantic import Extra, Field, BaseModel class ErrorOut(BaseModel): + class Config: + extra = Extra.allow + type: Literal["api_error", "invalid_request_error"] """ The type of error returned. @@ -25,6 +27,9 @@ class ErrorOut(BaseModel): class ExperimentalIn(BaseModel): + class Config: + extra = Extra.allow + name: str """ Identifier. @@ -40,6 +45,9 @@ class ExperimentalIn(BaseModel): class ExperimentalOut(BaseModel): + class Config: + extra = Extra.allow + output: Dict[str, Any] """ Response. @@ -47,6 +55,9 @@ class ExperimentalOut(BaseModel): class RunPythonIn(BaseModel): + class Config: + extra = Extra.allow + pkl_function: Optional[str] = None """ Pickled function. @@ -66,6 +77,9 @@ class RunPythonIn(BaseModel): class RunPythonOut(BaseModel): + class Config: + extra = Extra.allow + output: Optional[Any] = None """ Return value of your function. @@ -85,6 +99,9 @@ class RunPythonOut(BaseModel): class GenerateTextIn(BaseModel): + class Config: + extra = Extra.allow + prompt: str """ Input prompt. @@ -114,6 +131,9 @@ class GenerateTextIn(BaseModel): class GenerateTextOut(BaseModel): + class Config: + extra = Extra.allow + text: str """ Text response. @@ -121,6 +141,9 @@ class GenerateTextOut(BaseModel): class GenerateJSONIn(BaseModel): + class Config: + extra = Extra.allow + prompt: str """ Input prompt. @@ -144,6 +167,9 @@ class GenerateJSONIn(BaseModel): class GenerateJSONOut(BaseModel): + class Config: + extra = Extra.allow + json_object: Optional[Dict[str, Any]] = None """ JSON response. @@ -155,6 +181,9 @@ class GenerateJSONOut(BaseModel): class MultiGenerateTextIn(BaseModel): + class Config: + extra = Extra.allow + prompt: str """ Input prompt. @@ -183,6 +212,9 @@ class MultiGenerateTextIn(BaseModel): class MultiGenerateTextOut(BaseModel): + class Config: + extra = Extra.allow + choices: List[GenerateTextOut] """ Response choices. @@ -190,6 +222,9 @@ class MultiGenerateTextOut(BaseModel): class BatchGenerateTextIn(BaseModel): + class Config: + extra = Extra.allow + prompts: List[str] """ Batch input prompts. @@ -205,6 +240,9 @@ class BatchGenerateTextIn(BaseModel): class BatchGenerateTextOut(BaseModel): + class Config: + extra = Extra.allow + outputs: List[GenerateTextOut] """ Batch outputs. @@ -212,6 +250,9 @@ class BatchGenerateTextOut(BaseModel): class MultiGenerateJSONIn(BaseModel): + class Config: + extra = Extra.allow + prompt: str """ Input prompt. @@ -239,6 +280,9 @@ class MultiGenerateJSONIn(BaseModel): class MultiGenerateJSONOut(BaseModel): + class Config: + extra = Extra.allow + choices: List[GenerateJSONOut] """ Response choices. @@ -246,6 +290,9 @@ class MultiGenerateJSONOut(BaseModel): class BatchGenerateJSONIn(BaseModel): + class Config: + extra = Extra.allow + model: Literal["Mistral7BInstruct", "Llama3Instruct8B"] = "Llama3Instruct8B" """ Selected model. @@ -269,6 +316,9 @@ class BatchGenerateJSONIn(BaseModel): class BatchGenerateJSONOut(BaseModel): + class Config: + extra = Extra.allow + outputs: List[GenerateJSONOut] """ Batch outputs. @@ -276,6 +326,9 @@ class BatchGenerateJSONOut(BaseModel): class Mistral7BInstructIn(BaseModel): + class Config: + extra = Extra.allow + prompt: str """ Input prompt. @@ -319,6 +372,9 @@ class Mistral7BInstructIn(BaseModel): class Mistral7BInstructChoice(BaseModel): + class Config: + extra = Extra.allow + text: Optional[str] = None """ Text response, if `json_schema` was not provided. @@ -330,6 +386,9 @@ class Mistral7BInstructChoice(BaseModel): class Mistral7BInstructOut(BaseModel): + class Config: + extra = Extra.allow + choices: List[Mistral7BInstructChoice] """ Response choices. @@ -337,6 +396,9 @@ class Mistral7BInstructOut(BaseModel): class Mixtral8x7BInstructIn(BaseModel): + class Config: + extra = Extra.allow + prompt: str """ Input prompt. @@ -380,6 +442,9 @@ class Mixtral8x7BInstructIn(BaseModel): class Mixtral8x7BChoice(BaseModel): + class Config: + extra = Extra.allow + text: Optional[str] = None """ Text response, if `json_schema` was not provided. @@ -391,6 +456,9 @@ class Mixtral8x7BChoice(BaseModel): class Mixtral8x7BInstructOut(BaseModel): + class Config: + extra = Extra.allow + choices: List[Mixtral8x7BChoice] """ Response choices. @@ -398,6 +466,9 @@ class Mixtral8x7BInstructOut(BaseModel): class Llama3Instruct8BIn(BaseModel): + class Config: + extra = Extra.allow + prompt: str """ Input prompt. @@ -441,6 +512,9 @@ class Llama3Instruct8BIn(BaseModel): class Llama3Instruct8BChoice(BaseModel): + class Config: + extra = Extra.allow + text: Optional[str] = None """ Text response. @@ -452,6 +526,9 @@ class Llama3Instruct8BChoice(BaseModel): class Llama3Instruct8BOut(BaseModel): + class Config: + extra = Extra.allow + choices: List[Llama3Instruct8BChoice] """ Response choices. @@ -459,6 +536,9 @@ class Llama3Instruct8BOut(BaseModel): class Llama3Instruct70BIn(BaseModel): + class Config: + extra = Extra.allow + prompt: str """ Input prompt. @@ -498,6 +578,9 @@ class Llama3Instruct70BIn(BaseModel): class Llama3Instruct70BChoice(BaseModel): + class Config: + extra = Extra.allow + text: Optional[str] = None """ Text response. @@ -505,6 +588,9 @@ class Llama3Instruct70BChoice(BaseModel): class Llama3Instruct70BOut(BaseModel): + class Config: + extra = Extra.allow + choices: List[Llama3Instruct70BChoice] """ Response choices. @@ -512,6 +598,9 @@ class Llama3Instruct70BOut(BaseModel): class Firellava13BIn(BaseModel): + class Config: + extra = Extra.allow + prompt: str """ Text prompt. @@ -527,6 +616,9 @@ class Firellava13BIn(BaseModel): class Firellava13BOut(BaseModel): + class Config: + extra = Extra.allow + text: str """ Text response. @@ -534,6 +626,9 @@ class Firellava13BOut(BaseModel): class GenerateImageIn(BaseModel): + class Config: + extra = Extra.allow + prompt: str """ Text prompt. @@ -545,6 +640,9 @@ class GenerateImageIn(BaseModel): class GenerateImageOut(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. @@ -552,6 +650,9 @@ class GenerateImageOut(BaseModel): class MultiGenerateImageIn(BaseModel): + class Config: + extra = Extra.allow + prompt: str """ Text prompt. @@ -567,6 +668,9 @@ class MultiGenerateImageIn(BaseModel): class MultiGenerateImageOut(BaseModel): + class Config: + extra = Extra.allow + outputs: List[GenerateImageOut] """ Generated images. @@ -574,6 +678,9 @@ class MultiGenerateImageOut(BaseModel): class StableDiffusionXLIn(BaseModel): + class Config: + extra = Extra.allow + prompt: str """ Text prompt. @@ -613,6 +720,9 @@ class StableDiffusionXLIn(BaseModel): class StableDiffusionImage(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. @@ -624,6 +734,9 @@ class StableDiffusionImage(BaseModel): class StableDiffusionXLOut(BaseModel): + class Config: + extra = Extra.allow + outputs: List[StableDiffusionImage] """ Generated images. @@ -631,6 +744,9 @@ class StableDiffusionXLOut(BaseModel): class StableDiffusionXLLightningIn(BaseModel): + class Config: + extra = Extra.allow + prompt: str """ Text prompt. @@ -662,6 +778,9 @@ class StableDiffusionXLLightningIn(BaseModel): class StableDiffusionXLLightningOut(BaseModel): + class Config: + extra = Extra.allow + outputs: List[StableDiffusionImage] """ Generated images. @@ -669,6 +788,9 @@ class StableDiffusionXLLightningOut(BaseModel): class StableDiffusionXLIPAdapterIn(BaseModel): + class Config: + extra = Extra.allow + prompt: str """ Text prompt. @@ -708,6 +830,9 @@ class StableDiffusionXLIPAdapterIn(BaseModel): class StableDiffusionXLIPAdapterOut(BaseModel): + class Config: + extra = Extra.allow + outputs: List[StableDiffusionImage] """ Generated images. @@ -715,6 +840,9 @@ class StableDiffusionXLIPAdapterOut(BaseModel): class StableDiffusionXLControlNetIn(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Input image. @@ -758,6 +886,9 @@ class StableDiffusionXLControlNetIn(BaseModel): class StableDiffusionXLControlNetOut(BaseModel): + class Config: + extra = Extra.allow + outputs: List[StableDiffusionImage] """ Generated images. @@ -765,6 +896,9 @@ class StableDiffusionXLControlNetOut(BaseModel): class InpaintImageIn(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Original image. @@ -784,6 +918,9 @@ class InpaintImageIn(BaseModel): class InpaintImageOut(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. @@ -791,6 +928,9 @@ class InpaintImageOut(BaseModel): class MultiInpaintImageIn(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Original image. @@ -814,6 +954,9 @@ class MultiInpaintImageIn(BaseModel): class MultiInpaintImageOut(BaseModel): + class Config: + extra = Extra.allow + outputs: List[InpaintImageOut] """ Generated images. @@ -821,6 +964,9 @@ class MultiInpaintImageOut(BaseModel): class StableDiffusionXLInpaintIn(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Original image. @@ -860,6 +1006,9 @@ class StableDiffusionXLInpaintIn(BaseModel): class StableDiffusionXLInpaintOut(BaseModel): + class Config: + extra = Extra.allow + outputs: List[StableDiffusionImage] """ Generated images. @@ -867,6 +1016,9 @@ class StableDiffusionXLInpaintOut(BaseModel): class BoundingBox(BaseModel): + class Config: + extra = Extra.allow + x1: float """ Top left corner x. @@ -886,6 +1038,9 @@ class BoundingBox(BaseModel): class Point(BaseModel): + class Config: + extra = Extra.allow + x: int """ X position. @@ -897,6 +1052,9 @@ class Point(BaseModel): class EraseImageIn(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Input image. @@ -912,6 +1070,9 @@ class EraseImageIn(BaseModel): class EraseImageOut(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. @@ -919,6 +1080,9 @@ class EraseImageOut(BaseModel): class BigLaMaIn(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Input image. @@ -934,6 +1098,9 @@ class BigLaMaIn(BaseModel): class BigLaMaOut(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. @@ -941,6 +1108,9 @@ class BigLaMaOut(BaseModel): class RemoveBackgroundIn(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Input image. @@ -960,6 +1130,9 @@ class RemoveBackgroundIn(BaseModel): class RemoveBackgroundOut(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. @@ -967,6 +1140,9 @@ class RemoveBackgroundOut(BaseModel): class DISISNetIn(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Input image. @@ -978,6 +1154,9 @@ class DISISNetIn(BaseModel): class DISISNetOut(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. @@ -985,6 +1164,9 @@ class DISISNetOut(BaseModel): class UpscaleImageIn(BaseModel): + class Config: + extra = Extra.allow + prompt: Optional[str] = None """ Prompt to guide model on the content of image to upscale. @@ -1004,6 +1186,9 @@ class UpscaleImageIn(BaseModel): class UpscaleImageOut(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. @@ -1011,6 +1196,9 @@ class UpscaleImageOut(BaseModel): class SegmentUnderPointIn(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Input image. @@ -1026,6 +1214,9 @@ class SegmentUnderPointIn(BaseModel): class SegmentUnderPointOut(BaseModel): + class Config: + extra = Extra.allow + mask_image_uri: str """ Detected segments in 'mask image' format. Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. @@ -1033,6 +1224,9 @@ class SegmentUnderPointOut(BaseModel): class SegmentAnythingIn(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Input image. @@ -1052,6 +1246,9 @@ class SegmentAnythingIn(BaseModel): class SegmentAnythingOut(BaseModel): + class Config: + extra = Extra.allow + mask_image_uri: str """ Detected segments in 'mask image' format. Base 64-encoded JPEG image bytes, or a hosted image url if `store` is provided. @@ -1059,6 +1256,9 @@ class SegmentAnythingOut(BaseModel): class TranscribeSpeechIn(BaseModel): + class Config: + extra = Extra.allow + audio_uri: str """ Input audio. @@ -1090,6 +1290,9 @@ class TranscribeSpeechIn(BaseModel): class TranscribedWord(BaseModel): + class Config: + extra = Extra.allow + word: str """ Text of word. @@ -1109,6 +1312,9 @@ class TranscribedWord(BaseModel): class TranscribedSegment(BaseModel): + class Config: + extra = Extra.allow + text: str """ Text of segment. @@ -1132,6 +1338,9 @@ class TranscribedSegment(BaseModel): class ChapterMarker(BaseModel): + class Config: + extra = Extra.allow + title: str """ Chapter title. @@ -1143,6 +1352,9 @@ class ChapterMarker(BaseModel): class TranscribeSpeechOut(BaseModel): + class Config: + extra = Extra.allow + text: str """ Transcribed text. @@ -1158,6 +1370,9 @@ class TranscribeSpeechOut(BaseModel): class GenerateSpeechIn(BaseModel): + class Config: + extra = Extra.allow + text: str """ Input text. @@ -1169,6 +1384,9 @@ class GenerateSpeechIn(BaseModel): class GenerateSpeechOut(BaseModel): + class Config: + extra = Extra.allow + audio_uri: str """ Base 64-encoded WAV audio bytes, or a hosted audio url if `store` is provided. @@ -1176,6 +1394,9 @@ class GenerateSpeechOut(BaseModel): class XTTSV2In(BaseModel): + class Config: + extra = Extra.allow + text: str """ Input text. @@ -1195,6 +1416,9 @@ class XTTSV2In(BaseModel): class XTTSV2Out(BaseModel): + class Config: + extra = Extra.allow + audio_uri: str """ Base 64-encoded WAV audio bytes, or a hosted audio url if `store` is provided. @@ -1202,6 +1426,9 @@ class XTTSV2Out(BaseModel): class Embedding(BaseModel): + class Config: + extra = Extra.allow + vector: List[float] """ Embedding vector. @@ -1217,6 +1444,9 @@ class Embedding(BaseModel): class EmbedTextIn(BaseModel): + class Config: + extra = Extra.allow + text: str """ Text to embed. @@ -1244,6 +1474,9 @@ class EmbedTextIn(BaseModel): class EmbedTextOut(BaseModel): + class Config: + extra = Extra.allow + embedding: Embedding """ Generated embedding. @@ -1251,6 +1484,9 @@ class EmbedTextOut(BaseModel): class EmbedTextItem(BaseModel): + class Config: + extra = Extra.allow + text: str """ Text to embed. @@ -1266,6 +1502,9 @@ class EmbedTextItem(BaseModel): class MultiEmbedTextIn(BaseModel): + class Config: + extra = Extra.allow + items: List[EmbedTextItem] """ Items to embed. @@ -1285,6 +1524,9 @@ class MultiEmbedTextIn(BaseModel): class MultiEmbedTextOut(BaseModel): + class Config: + extra = Extra.allow + embeddings: List[Embedding] """ Generated embeddings. @@ -1292,6 +1534,9 @@ class MultiEmbedTextOut(BaseModel): class JinaV2In(BaseModel): + class Config: + extra = Extra.allow + items: List[EmbedTextItem] """ Items to embed. @@ -1307,6 +1552,9 @@ class JinaV2In(BaseModel): class JinaV2Out(BaseModel): + class Config: + extra = Extra.allow + embeddings: List[Embedding] """ Generated embeddings. @@ -1314,6 +1562,9 @@ class JinaV2Out(BaseModel): class EmbedImageIn(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Image to embed. @@ -1333,6 +1584,9 @@ class EmbedImageIn(BaseModel): class EmbedImageOut(BaseModel): + class Config: + extra = Extra.allow + embedding: Embedding """ Generated embedding. @@ -1340,6 +1594,9 @@ class EmbedImageOut(BaseModel): class EmbedImageItem(BaseModel): + class Config: + extra = Extra.allow + image_uri: str """ Image to embed. @@ -1351,6 +1608,9 @@ class EmbedImageItem(BaseModel): class EmbedTextOrImageItem(BaseModel): + class Config: + extra = Extra.allow + image_uri: Optional[str] = None """ Image to embed. @@ -1370,6 +1630,9 @@ class EmbedTextOrImageItem(BaseModel): class MultiEmbedImageIn(BaseModel): + class Config: + extra = Extra.allow + items: List[EmbedImageItem] """ Items to embed. @@ -1385,6 +1648,9 @@ class MultiEmbedImageIn(BaseModel): class MultiEmbedImageOut(BaseModel): + class Config: + extra = Extra.allow + embeddings: List[Embedding] """ Generated embeddings. @@ -1392,6 +1658,9 @@ class MultiEmbedImageOut(BaseModel): class CLIPIn(BaseModel): + class Config: + extra = Extra.allow + items: List[EmbedTextOrImageItem] """ Items to embed. @@ -1407,6 +1676,9 @@ class CLIPIn(BaseModel): class CLIPOut(BaseModel): + class Config: + extra = Extra.allow + embeddings: List[Embedding] """ Generated embeddings. @@ -1414,6 +1686,9 @@ class CLIPOut(BaseModel): class FindOrCreateVectorStoreIn(BaseModel): + class Config: + extra = Extra.allow + collection_name: Annotated[str, Field(max_length=63, min_length=1)] """ Vector store name. @@ -1425,6 +1700,9 @@ class FindOrCreateVectorStoreIn(BaseModel): class FindOrCreateVectorStoreOut(BaseModel): + class Config: + extra = Extra.allow + collection_name: Annotated[str, Field(max_length=63, min_length=1)] """ Vector store name. @@ -1438,8 +1716,14 @@ class FindOrCreateVectorStoreOut(BaseModel): class ListVectorStoresIn(BaseModel): pass + class Config: + extra = Extra.allow + class ListVectorStoresOut(BaseModel): + class Config: + extra = Extra.allow + items: Optional[List[FindOrCreateVectorStoreOut]] = None """ List of vector stores. @@ -1447,6 +1731,9 @@ class ListVectorStoresOut(BaseModel): class DeleteVectorStoreIn(BaseModel): + class Config: + extra = Extra.allow + collection_name: str """ Vector store name. @@ -1458,6 +1745,9 @@ class DeleteVectorStoreIn(BaseModel): class DeleteVectorStoreOut(BaseModel): + class Config: + extra = Extra.allow + collection_name: str """ Vector store name. @@ -1473,6 +1763,9 @@ class Vector(BaseModel): Canonical representation of document with embedding vector. """ + class Config: + extra = Extra.allow + id: str """ Document ID. @@ -1488,6 +1781,9 @@ class Vector(BaseModel): class FetchVectorsIn(BaseModel): + class Config: + extra = Extra.allow + collection_name: str """ Vector store name. @@ -1503,6 +1799,9 @@ class FetchVectorsIn(BaseModel): class FetchVectorsOut(BaseModel): + class Config: + extra = Extra.allow + vectors: List[Vector] """ Retrieved vectors. @@ -1510,6 +1809,9 @@ class FetchVectorsOut(BaseModel): class UpdateVectorsOut(BaseModel): + class Config: + extra = Extra.allow + count: int """ Number of vectors modified. @@ -1517,6 +1819,9 @@ class UpdateVectorsOut(BaseModel): class DeleteVectorsOut(BaseModel): + class Config: + extra = Extra.allow + count: int """ Number of vectors modified. @@ -1524,6 +1829,9 @@ class DeleteVectorsOut(BaseModel): class UpdateVectorParams(BaseModel): + class Config: + extra = Extra.allow + id: str """ Document ID. @@ -1539,6 +1847,9 @@ class UpdateVectorParams(BaseModel): class UpdateVectorsIn(BaseModel): + class Config: + extra = Extra.allow + collection_name: str """ Vector store name. @@ -1554,6 +1865,9 @@ class UpdateVectorsIn(BaseModel): class DeleteVectorsIn(BaseModel): + class Config: + extra = Extra.allow + collection_name: str """ Vector store name. @@ -1569,6 +1883,9 @@ class DeleteVectorsIn(BaseModel): class QueryVectorStoreIn(BaseModel): + class Config: + extra = Extra.allow + collection_name: str """ Vector store to query against. @@ -1616,6 +1933,9 @@ class QueryVectorStoreIn(BaseModel): class VectorStoreQueryResult(BaseModel): + class Config: + extra = Extra.allow + id: str """ Document ID. @@ -1635,6 +1955,9 @@ class VectorStoreQueryResult(BaseModel): class QueryVectorStoreOut(BaseModel): + class Config: + extra = Extra.allow + results: List[List[VectorStoreQueryResult]] """ Query results. diff --git a/substrate/future_dataclass_models.py b/substrate/future_dataclass_models.py index ecaeb38..5f2791e 100644 --- a/substrate/future_dataclass_models.py +++ b/substrate/future_dataclass_models.py @@ -1,7 +1,6 @@ """ -𐃏 Substrate -@generated file -(using datamodel-codegen) +֍ Substrate +generated file """ diff --git a/substrate/nodes.py b/substrate/nodes.py index 5d86915..c352e33 100644 --- a/substrate/nodes.py +++ b/substrate/nodes.py @@ -95,7 +95,14 @@ class Experimental(CoreNode[ExperimentalOut]): """https://substrate.run/nodes#Experimental""" - def __init__(self, name: str, args: Dict[str, Any], timeout: int = 60, hide: bool = False): + def __init__( + self, + name: str, + args: Dict[str, Any], + timeout: int = 60, + hide: bool = False, + **kwargs, + ): """ Args: name: Identifier. @@ -104,7 +111,14 @@ def __init__(self, name: str, args: Dict[str, Any], timeout: int = 60, hide: boo https://substrate.run/nodes#Experimental """ - super().__init__(name=name, args=args, timeout=timeout, hide=hide, out_type=ExperimentalOut) + super().__init__( + name=name, + args=args, + timeout=timeout, + hide=hide, + out_type=ExperimentalOut, + **kwargs, + ) self.node = "Experimental" @property @@ -134,6 +148,7 @@ def __init__( "Firellava13B", ] = "Llama3Instruct8B", hide: bool = False, + **kwargs, ): """ Args: @@ -153,6 +168,7 @@ def __init__( model=model, hide=hide, out_type=GenerateTextOut, + **kwargs, ) self.node = "GenerateText" @@ -177,6 +193,7 @@ def __init__( max_tokens: Optional[int] = None, model: Literal["Mistral7BInstruct", "Mixtral8x7BInstruct", "Llama3Instruct8B"] = "Llama3Instruct8B", hide: bool = False, + **kwargs, ): """ Args: @@ -196,6 +213,7 @@ def __init__( model=model, hide=hide, out_type=GenerateJSONOut, + **kwargs, ) self.node = "GenerateJSON" @@ -225,6 +243,7 @@ def __init__( "Llama3Instruct70B", ] = "Llama3Instruct8B", hide: bool = False, + **kwargs, ): """ Args: @@ -244,6 +263,7 @@ def __init__( model=model, hide=hide, out_type=MultiGenerateTextOut, + **kwargs, ) self.node = "MultiGenerateText" @@ -266,6 +286,7 @@ def __init__( temperature: float = 0.4, max_tokens: Optional[int] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -281,6 +302,7 @@ def __init__( max_tokens=max_tokens, hide=hide, out_type=BatchGenerateTextOut, + **kwargs, ) self.node = "BatchGenerateText" @@ -306,6 +328,7 @@ def __init__( max_tokens: Optional[int] = None, model: Literal["Mistral7BInstruct", "Mixtral8x7BInstruct", "Llama3Instruct8B"] = "Llama3Instruct8B", hide: bool = False, + **kwargs, ): """ Args: @@ -327,6 +350,7 @@ def __init__( model=model, hide=hide, out_type=MultiGenerateJSONOut, + **kwargs, ) self.node = "MultiGenerateJSON" @@ -351,6 +375,7 @@ def __init__( temperature: float = 0.4, max_tokens: Optional[int] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -370,6 +395,7 @@ def __init__( max_tokens=max_tokens, hide=hide, out_type=BatchGenerateJSONOut, + **kwargs, ) self.node = "BatchGenerateJSON" @@ -399,6 +425,7 @@ def __init__( top_p: float = 0.95, max_tokens: Optional[int] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -428,6 +455,7 @@ def __init__( max_tokens=max_tokens, hide=hide, out_type=Mistral7BInstructOut, + **kwargs, ) self.node = "Mistral7BInstruct" @@ -457,6 +485,7 @@ def __init__( top_p: float = 0.95, max_tokens: Optional[int] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -486,6 +515,7 @@ def __init__( max_tokens=max_tokens, hide=hide, out_type=Mixtral8x7BInstructOut, + **kwargs, ) self.node = "Mixtral8x7BInstruct" @@ -515,6 +545,7 @@ def __init__( max_tokens: Optional[int] = None, json_schema: Optional[Dict[str, Any]] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -544,6 +575,7 @@ def __init__( json_schema=json_schema, hide=hide, out_type=Llama3Instruct8BOut, + **kwargs, ) self.node = "Llama3Instruct8B" @@ -572,6 +604,7 @@ def __init__( top_p: float = 0.95, max_tokens: Optional[int] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -599,6 +632,7 @@ def __init__( max_tokens=max_tokens, hide=hide, out_type=Llama3Instruct70BOut, + **kwargs, ) self.node = "Llama3Instruct70B" @@ -621,6 +655,7 @@ def __init__( image_uris: List[str], max_tokens: Optional[int] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -636,6 +671,7 @@ def __init__( max_tokens=max_tokens, hide=hide, out_type=Firellava13BOut, + **kwargs, ) self.node = "Firellava13B" @@ -652,7 +688,7 @@ def future(self) -> FutureFirellava13BOut: # type: ignore class GenerateImage(CoreNode[GenerateImageOut]): """https://substrate.run/nodes#GenerateImage""" - def __init__(self, prompt: str, store: Optional[str] = None, hide: bool = False): + def __init__(self, prompt: str, store: Optional[str] = None, hide: bool = False, **kwargs): """ Args: prompt: Text prompt. @@ -660,7 +696,7 @@ def __init__(self, prompt: str, store: Optional[str] = None, hide: bool = False) https://substrate.run/nodes#GenerateImage """ - super().__init__(prompt=prompt, store=store, hide=hide, out_type=GenerateImageOut) + super().__init__(prompt=prompt, store=store, hide=hide, out_type=GenerateImageOut, **kwargs) self.node = "GenerateImage" @property @@ -682,6 +718,7 @@ def __init__( num_images: int, store: Optional[str] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -697,6 +734,7 @@ def __init__( store=store, hide=hide, out_type=MultiGenerateImageOut, + **kwargs, ) self.node = "MultiGenerateImage" @@ -723,6 +761,7 @@ def __init__( width: int = 1024, seeds: Optional[List[int]] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -746,6 +785,7 @@ def __init__( seeds=seeds, hide=hide, out_type=StableDiffusionXLLightningOut, + **kwargs, ) self.node = "StableDiffusionXLLightning" @@ -775,6 +815,7 @@ def __init__( strength: float = 0.5, seeds: Optional[List[int]] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -804,6 +845,7 @@ def __init__( seeds=seeds, hide=hide, out_type=StableDiffusionXLControlNetOut, + **kwargs, ) self.node = "StableDiffusionXLControlNet" @@ -827,6 +869,7 @@ def __init__( mask_image_uri: Optional[str] = None, store: Optional[str] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -844,6 +887,7 @@ def __init__( store=store, hide=hide, out_type=InpaintImageOut, + **kwargs, ) self.node = "InpaintImage" @@ -868,6 +912,7 @@ def __init__( mask_image_uri: Optional[str] = None, store: Optional[str] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -887,6 +932,7 @@ def __init__( store=store, hide=hide, out_type=MultiInpaintImageOut, + **kwargs, ) self.node = "MultiInpaintImage" @@ -915,6 +961,7 @@ def __init__( strength: float = 0.8, seeds: Optional[List[int]] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -942,6 +989,7 @@ def __init__( seeds=seeds, hide=hide, out_type=StableDiffusionXLInpaintOut, + **kwargs, ) self.node = "StableDiffusionXLInpaint" @@ -964,6 +1012,7 @@ def __init__( mask_image_uri: str, store: Optional[str] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -979,6 +1028,7 @@ def __init__( store=store, hide=hide, out_type=EraseImageOut, + **kwargs, ) self.node = "EraseImage" @@ -1002,6 +1052,7 @@ def __init__( background_color: Optional[str] = None, store: Optional[str] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -1019,6 +1070,7 @@ def __init__( store=store, hide=hide, out_type=RemoveBackgroundOut, + **kwargs, ) self.node = "RemoveBackground" @@ -1042,6 +1094,7 @@ def __init__( output_resolution: int = 1024, store: Optional[str] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -1059,6 +1112,7 @@ def __init__( store=store, hide=hide, out_type=UpscaleImageOut, + **kwargs, ) self.node = "UpscaleImage" @@ -1081,6 +1135,7 @@ def __init__( point: Point, store: Optional[str] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -1096,6 +1151,7 @@ def __init__( store=store, hide=hide, out_type=SegmentUnderPointOut, + **kwargs, ) self.node = "SegmentUnderPoint" @@ -1119,6 +1175,7 @@ def __init__( box_prompts: Optional[List[BoundingBox]] = None, store: Optional[str] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -1136,6 +1193,7 @@ def __init__( store=store, hide=hide, out_type=SegmentAnythingOut, + **kwargs, ) self.node = "SegmentAnything" @@ -1162,6 +1220,7 @@ def __init__( diarize: bool = False, suggest_chapters: bool = False, hide: bool = False, + **kwargs, ): """ Args: @@ -1185,6 +1244,7 @@ def __init__( suggest_chapters=suggest_chapters, hide=hide, out_type=TranscribeSpeechOut, + **kwargs, ) self.node = "TranscribeSpeech" @@ -1201,7 +1261,7 @@ def future(self) -> FutureTranscribeSpeechOut: # type: ignore class GenerateSpeech(CoreNode[GenerateSpeechOut]): """https://substrate.run/nodes#GenerateSpeech""" - def __init__(self, text: str, store: Optional[str] = None, hide: bool = False): + def __init__(self, text: str, store: Optional[str] = None, hide: bool = False, **kwargs): """ Args: text: Input text. @@ -1209,7 +1269,7 @@ def __init__(self, text: str, store: Optional[str] = None, hide: bool = False): https://substrate.run/nodes#GenerateSpeech """ - super().__init__(text=text, store=store, hide=hide, out_type=GenerateSpeechOut) + super().__init__(text=text, store=store, hide=hide, out_type=GenerateSpeechOut, **kwargs) self.node = "GenerateSpeech" @property @@ -1234,6 +1294,7 @@ def __init__( doc_id: Optional[str] = None, model: Literal["jina-v2", "clip"] = "jina-v2", hide: bool = False, + **kwargs, ): """ Args: @@ -1255,6 +1316,7 @@ def __init__( model=model, hide=hide, out_type=EmbedTextOut, + **kwargs, ) self.node = "EmbedText" @@ -1278,6 +1340,7 @@ def __init__( embedded_metadata_keys: Optional[List[str]] = None, model: Literal["jina-v2", "clip"] = "jina-v2", hide: bool = False, + **kwargs, ): """ Args: @@ -1295,6 +1358,7 @@ def __init__( model=model, hide=hide, out_type=MultiEmbedTextOut, + **kwargs, ) self.node = "MultiEmbedText" @@ -1317,6 +1381,7 @@ def __init__( collection_name: Optional[str] = None, embedded_metadata_keys: Optional[List[str]] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -1332,6 +1397,7 @@ def __init__( embedded_metadata_keys=embedded_metadata_keys, hide=hide, out_type=JinaV2Out, + **kwargs, ) self.node = "JinaV2" @@ -1355,6 +1421,7 @@ def __init__( doc_id: Optional[str] = None, model: Literal["clip"] = "clip", hide: bool = False, + **kwargs, ): """ Args: @@ -1372,6 +1439,7 @@ def __init__( model=model, hide=hide, out_type=EmbedImageOut, + **kwargs, ) self.node = "EmbedImage" @@ -1394,6 +1462,7 @@ def __init__( collection_name: Optional[str] = None, model: Literal["clip"] = "clip", hide: bool = False, + **kwargs, ): """ Args: @@ -1409,6 +1478,7 @@ def __init__( model=model, hide=hide, out_type=MultiEmbedImageOut, + **kwargs, ) self.node = "MultiEmbedImage" @@ -1431,6 +1501,7 @@ def __init__( collection_name: Optional[str] = None, embedded_metadata_keys: Optional[List[str]] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -1446,6 +1517,7 @@ def __init__( embedded_metadata_keys=embedded_metadata_keys, hide=hide, out_type=CLIPOut, + **kwargs, ) self.node = "CLIP" @@ -1467,6 +1539,7 @@ def __init__( collection_name: str, model: Literal["jina-v2", "clip"], hide: bool = False, + **kwargs, ): """ Args: @@ -1480,6 +1553,7 @@ def __init__( model=model, hide=hide, out_type=FindOrCreateVectorStoreOut, + **kwargs, ) self.node = "FindOrCreateVectorStore" @@ -1496,13 +1570,13 @@ def future(self) -> FutureFindOrCreateVectorStoreOut: # type: ignore class ListVectorStores(CoreNode[ListVectorStoresOut]): """https://substrate.run/nodes#ListVectorStores""" - def __init__(self, hide: bool = False): + def __init__(self, hide: bool = False, **kwargs): """ Args: https://substrate.run/nodes#ListVectorStores """ - super().__init__(hide=hide, out_type=ListVectorStoresOut) + super().__init__(hide=hide, out_type=ListVectorStoresOut, **kwargs) self.node = "ListVectorStores" @property @@ -1523,6 +1597,7 @@ def __init__( collection_name: str, model: Literal["jina-v2", "clip"], hide: bool = False, + **kwargs, ): """ Args: @@ -1536,6 +1611,7 @@ def __init__( model=model, hide=hide, out_type=DeleteVectorStoreOut, + **kwargs, ) self.node = "DeleteVectorStore" @@ -1558,6 +1634,7 @@ def __init__( model: Literal["jina-v2", "clip"], ids: List[str], hide: bool = False, + **kwargs, ): """ Args: @@ -1573,6 +1650,7 @@ def __init__( ids=ids, hide=hide, out_type=FetchVectorsOut, + **kwargs, ) self.node = "FetchVectors" @@ -1595,6 +1673,7 @@ def __init__( model: Literal["jina-v2", "clip"], vectors: List[UpdateVectorParams], hide: bool = False, + **kwargs, ): """ Args: @@ -1610,6 +1689,7 @@ def __init__( vectors=vectors, hide=hide, out_type=UpdateVectorsOut, + **kwargs, ) self.node = "UpdateVectors" @@ -1632,6 +1712,7 @@ def __init__( model: Literal["jina-v2", "clip"], ids: List[str], hide: bool = False, + **kwargs, ): """ Args: @@ -1647,6 +1728,7 @@ def __init__( ids=ids, hide=hide, out_type=DeleteVectorsOut, + **kwargs, ) self.node = "DeleteVectors" @@ -1677,6 +1759,7 @@ def __init__( include_metadata: bool = False, filters: Optional[Dict[str, Any]] = None, hide: bool = False, + **kwargs, ): """ Args: @@ -1708,6 +1791,7 @@ def __init__( filters=filters, hide=hide, out_type=QueryVectorStoreOut, + **kwargs, ) self.node = "QueryVectorStore" diff --git a/substrate/typeddict_models.py b/substrate/typeddict_models.py index a40a9a7..d6c52f7 100644 --- a/substrate/typeddict_models.py +++ b/substrate/typeddict_models.py @@ -1,7 +1,6 @@ """ -𐃏 Substrate -@generated file -(using datamodel-codegen) +֍ Substrate +generated file """