mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-22 21:48:12 -05:00
Compare commits
2 Commits
testing-cl
...
swiftyos/b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d519530dc | ||
|
|
af2c48d355 |
0
rnd/autogpt_server/autogpt_server/blocks/README.md
Normal file
0
rnd/autogpt_server/autogpt_server/blocks/README.md
Normal file
26
rnd/autogpt_server/autogpt_server/blocks/llm.py
Normal file
26
rnd/autogpt_server/autogpt_server/blocks/llm.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
from typing import ClassVar, Any
|
||||||
|
from autogpt_server.data.block import Block, BlockSchema, BlockData
|
||||||
|
from openai import OpenAI
|
||||||
|
|
||||||
|
|
||||||
|
class LlmBlock(Block):
|
||||||
|
id: ClassVar[str] = "db7d8f02-2f44-4c55-ab7a-eae0941f0c33" # type: ignore
|
||||||
|
input_schema: ClassVar[BlockSchema] = BlockSchema(
|
||||||
|
{ # type: ignore
|
||||||
|
"model": "string",
|
||||||
|
"messages": "Dict[string, Any]",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
output_schema: ClassVar[BlockSchema] = BlockSchema(
|
||||||
|
{ # type: ignore
|
||||||
|
"response": "string",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
async def run(self, input_data: BlockData) -> tuple[str, Any]:
|
||||||
|
client = OpenAI()
|
||||||
|
|
||||||
|
completion = client.chat.completions.create(
|
||||||
|
model=input_data["model"], messages=input_data["messages"]
|
||||||
|
)
|
||||||
|
return "response", completion.choices[0].message
|
||||||
44
rnd/autogpt_server/autogpt_server/blocks/logic.py
Normal file
44
rnd/autogpt_server/autogpt_server/blocks/logic.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
from typing import ClassVar, Any
|
||||||
|
from autogpt_server.data.block import Block, BlockSchema, BlockData
|
||||||
|
|
||||||
|
|
||||||
|
class IfBlock(Block):
|
||||||
|
id: ClassVar[str] = "db7d8f02-2f44-4c55-ab7a-eae0941f0c31" # type: ignore
|
||||||
|
input_schema: ClassVar[BlockSchema] = BlockSchema(
|
||||||
|
{ # type: ignore
|
||||||
|
"condition": "string",
|
||||||
|
"variables": "Dict[string, Any]",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
output_schema: ClassVar[BlockSchema] = BlockSchema(
|
||||||
|
{ # type: ignore
|
||||||
|
"result": "bool",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
async def run(self, input_data: BlockData) -> tuple[str, Any]:
|
||||||
|
for key in input_data.keys():
|
||||||
|
eval(f"{key} = {input_data[key]}")
|
||||||
|
if eval(input_data["condition"]):
|
||||||
|
return "result", True
|
||||||
|
else:
|
||||||
|
return "result", False
|
||||||
|
|
||||||
|
|
||||||
|
class ForBlock(Block):
|
||||||
|
id: ClassVar[str] = "db7d8f02-2f44-4c55-ab7a-eae0941f0c32" # type: ignore
|
||||||
|
input_schema: ClassVar[BlockSchema] = BlockSchema(
|
||||||
|
{ # type: ignore
|
||||||
|
"data": "List[Any]"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
output_schema: ClassVar[BlockSchema] = BlockSchema(
|
||||||
|
{ # type: ignore
|
||||||
|
"result": "Any",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
async def run(self, input_data: BlockData) -> tuple[str, Any]:
|
||||||
|
# FIX: Current block does not support multiple returns...:W
|
||||||
|
for element in input_data["data"]:
|
||||||
|
return "result", element
|
||||||
56
rnd/autogpt_server/poetry.lock
generated
56
rnd/autogpt_server/poetry.lock
generated
@@ -181,6 +181,17 @@ files = [
|
|||||||
{file = "cx_Logging-3.2.0.tar.gz", hash = "sha256:bdbad6d2e6a0cc5bef962a34d7aa1232e88ea9f3541d6e2881675b5e7eab5502"},
|
{file = "cx_Logging-3.2.0.tar.gz", hash = "sha256:bdbad6d2e6a0cc5bef962a34d7aa1232e88ea9f3541d6e2881675b5e7eab5502"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "distro"
|
||||||
|
version = "1.9.0"
|
||||||
|
description = "Distro - an OS platform information API"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.6"
|
||||||
|
files = [
|
||||||
|
{file = "distro-1.9.0-py3-none-any.whl", hash = "sha256:7bffd925d65168f85027d8da9af6bddab658135b840670a223589bc0c8ef02b2"},
|
||||||
|
{file = "distro-1.9.0.tar.gz", hash = "sha256:2fa77c6fd8940f116ee1d6b94a2f90b13b5ea8d019b98bc8bafdcabcdd9bdbed"},
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "exceptiongroup"
|
name = "exceptiongroup"
|
||||||
version = "1.2.1"
|
version = "1.2.1"
|
||||||
@@ -554,6 +565,29 @@ files = [
|
|||||||
{file = "nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f"},
|
{file = "nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "openai"
|
||||||
|
version = "1.34.0"
|
||||||
|
description = "The official Python library for the openai API"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7.1"
|
||||||
|
files = [
|
||||||
|
{file = "openai-1.34.0-py3-none-any.whl", hash = "sha256:018623c2f795424044675c6230fa3bfbf98d9e0aab45d8fd116f2efb2cfb6b7e"},
|
||||||
|
{file = "openai-1.34.0.tar.gz", hash = "sha256:95c8e2da4acd6958e626186957d656597613587195abd0fb2527566a93e76770"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
anyio = ">=3.5.0,<5"
|
||||||
|
distro = ">=1.7.0,<2"
|
||||||
|
httpx = ">=0.23.0,<1"
|
||||||
|
pydantic = ">=1.9.0,<3"
|
||||||
|
sniffio = "*"
|
||||||
|
tqdm = ">4"
|
||||||
|
typing-extensions = ">=4.7,<5"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
datalib = ["numpy (>=1)", "pandas (>=1.2.3)", "pandas-stubs (>=1.1.0.11)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "packaging"
|
name = "packaging"
|
||||||
version = "24.1"
|
version = "24.1"
|
||||||
@@ -1173,6 +1207,26 @@ files = [
|
|||||||
{file = "tomlkit-0.12.5.tar.gz", hash = "sha256:eef34fba39834d4d6b73c9ba7f3e4d1c417a4e56f89a7e96e090dd0d24b8fb3c"},
|
{file = "tomlkit-0.12.5.tar.gz", hash = "sha256:eef34fba39834d4d6b73c9ba7f3e4d1c417a4e56f89a7e96e090dd0d24b8fb3c"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tqdm"
|
||||||
|
version = "4.66.4"
|
||||||
|
description = "Fast, Extensible Progress Meter"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
files = [
|
||||||
|
{file = "tqdm-4.66.4-py3-none-any.whl", hash = "sha256:b75ca56b413b030bc3f00af51fd2c1a1a5eac6a0c1cca83cbb37a5c52abce644"},
|
||||||
|
{file = "tqdm-4.66.4.tar.gz", hash = "sha256:e4d936c9de8727928f3be6079590e97d9abfe8d39a590be678eb5919ffc186bb"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
colorama = {version = "*", markers = "platform_system == \"Windows\""}
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
dev = ["pytest (>=6)", "pytest-cov", "pytest-timeout", "pytest-xdist"]
|
||||||
|
notebook = ["ipywidgets (>=6)"]
|
||||||
|
slack = ["slack-sdk"]
|
||||||
|
telegram = ["requests"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typing-extensions"
|
name = "typing-extensions"
|
||||||
version = "4.12.2"
|
version = "4.12.2"
|
||||||
@@ -1483,4 +1537,4 @@ test = ["pytest (>=6.0.0)", "setuptools (>=65)"]
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.10"
|
python-versions = "^3.10"
|
||||||
content-hash = "391567de870dbbf86ea217ff6b15f7c6d2c9406707c196661d29f45deb886812"
|
content-hash = "8e1c4f06c5f036dd6f32ed9c88e367c4ff2ecd23d13beadbfc8ef55c17cf4daa"
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ ruff = "^0.4.8"
|
|||||||
flake8 = "^7.0.0"
|
flake8 = "^7.0.0"
|
||||||
jsonschema = "^4.22.0"
|
jsonschema = "^4.22.0"
|
||||||
psutil = "^5.9.8"
|
psutil = "^5.9.8"
|
||||||
|
openai = "^1.34.0"
|
||||||
|
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
|
|||||||
Reference in New Issue
Block a user