generated from kyegomez/Python-Package-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kye Gomez
authored and
Kye Gomez
committed
Jul 27, 2024
1 parent
edee935
commit 05a538f
Showing
5 changed files
with
118 additions
and
76 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "swarms-cloud" | ||
version = "0.2.6" | ||
version = "0.2.7" | ||
description = "Swarms Cloud - Pytorch" | ||
license = "MIT" | ||
authors = ["Kye Gomez <[email protected]>"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from swarms_cloud.schema.agent_api_schemas import AgentInput, ModelSchema, ModelList, GenerationMetrics, AgentOutput | ||
|
||
|
||
__all__ = [ | ||
"AgentInput", | ||
"ModelSchema", | ||
"ModelList", | ||
"GenerationMetrics", | ||
"AgentOutput", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import time | ||
from typing import List, Any | ||
|
||
from pydantic import BaseModel, model_validator | ||
|
||
from swarms_cloud.schema.cog_vlm_schemas import ChatCompletionResponse | ||
|
||
|
||
|
||
# Define the input model using Pydantic | ||
class AgentInput(BaseModel): | ||
agent_name: str = "Swarm Agent" | ||
system_prompt: str = None | ||
agent_description: str = None | ||
model_name: str = "OpenAIChat" | ||
max_loops: int = 1 | ||
autosave: bool = False | ||
dynamic_temperature_enabled: bool = False | ||
dashboard: bool = False | ||
verbose: bool = False | ||
streaming_on: bool = False | ||
saved_state_path: str = "agent_saved_state.json" | ||
sop: str = None | ||
sop_list: List[str] = None | ||
user_name: str = "User" | ||
retry_attempts: int = 3 | ||
context_length: int = 8192 | ||
task: str = None | ||
max_tokens: int = None | ||
tool_schema: Any = None | ||
|
||
@model_validator(mode="pre") | ||
def check_required_fields(cls, values): | ||
required_fields = [ | ||
"agent_name", | ||
"system_prompt", | ||
"task", | ||
"max_loops", | ||
"context_window", | ||
] | ||
|
||
for field in required_fields: | ||
if not values.get(field): | ||
|
||
raise ValueError(f"{field} must not be empty or null") | ||
|
||
if values["max_loops"] <= 0: | ||
raise ValueError("max_loops must be greater than 0") | ||
|
||
if values["context_window"] <= 0: | ||
raise ValueError("context_window must be greater than 0") | ||
|
||
return values | ||
|
||
|
||
class ModelSchema(BaseModel): | ||
id: str = None | ||
object: str = "model" | ||
created_at: int = time.time() | ||
owned_by: str = "TGSC" | ||
|
||
|
||
class ModelList(BaseModel): | ||
object: str = "list" | ||
data = List[ModelSchema] = [] | ||
|
||
|
||
# Define the output model using Pydantic | ||
class GenerationMetrics(BaseModel): | ||
tokens_per_second: float = 0.0 | ||
completion_time: float = 0.0 | ||
|
||
|
||
# Define the output model using Pydantic | ||
class AgentOutput(BaseModel): | ||
agent: AgentInput | ||
completions: ChatCompletionResponse | ||
# metrics: GenerationMetrics | ||
|