Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ollama - Remote hosts #8234

Open
wants to merge 25 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
24f915a
Test commit
Oct 14, 2024
cfef0cd
Added host specification support for Ollama - moving to test
Oct 14, 2024
15ade2b
Forgot to change order of args
Oct 14, 2024
8538382
Changed how the StructuredResponse block handles prompt
Oct 14, 2024
7e087d4
Removed my dockerfile changes and commited now working code
Oct 14, 2024
c4564c9
Reformat to pass black ci/cd check
Oct 14, 2024
3f4e561
Typing fix
Oct 14, 2024
cc3bd84
feat(blocks): Add AI List Generator block (#8221)
Torantulino Sep 30, 2024
8b6284a
tweak(Blocks): Simplify iteration block to output list items (#8219)
Torantulino Sep 30, 2024
5ba6b1f
tweak(blocks): Add option for simple raw content scraping to ExtractW…
Torantulino Sep 30, 2024
3e99e48
dx(blocks): Auto-label block PRs (#8230)
Pwuts Sep 30, 2024
82ac84f
fix(platform): Fix unexpected closing block list on tutorial (#8233)
majdyz Sep 30, 2024
740c267
feat(prod,infra): Add prod values and clean up infra (#8238)
aarushik93 Oct 1, 2024
651f3b5
feat(frontend): push to cloud if needed for marketplace, and add a do…
ntindle Oct 1, 2024
66348e6
Discard changes to autogpt_platform/market/.env.example
ntindle Nov 15, 2024
f577883
Discard changes to autogpt_platform/infra/helm/autogpt-server/values.…
ntindle Nov 15, 2024
7e1bb8a
Discard changes to autogpt_platform/infra/helm/autogpt-server/templat…
ntindle Nov 15, 2024
d81fceb
Discard changes to autogpt_platform/infra/helm/autogpt-server/templat…
ntindle Nov 15, 2024
54f6095
Discard changes to .github/labeler.yml
ntindle Nov 15, 2024
f666d0e
Discard changes to autogpt_platform/docker-compose.platform.yml
ntindle Nov 15, 2024
d0667e2
Discard changes to autogpt_platform/frontend/.env.example
ntindle Nov 15, 2024
9c1c9d3
Discard changes to autogpt_platform/frontend/package.json
ntindle Nov 15, 2024
272834d
Discard changes to autogpt_platform/frontend/src/components/Flow.tsx
ntindle Nov 15, 2024
bdc3fa1
Discard changes to autogpt_platform/frontend/src/components/NavBar.tsx
ntindle Nov 15, 2024
ea3716a
Discard changes to autogpt_platform/frontend/src/components/NavBarBut…
ntindle Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 32 additions & 17 deletions autogpt_platform/backend/backend/blocks/iteration.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,52 @@
from typing import Any, List, Tuple
from typing import Any

from backend.data.block import Block, BlockCategory, BlockOutput, BlockSchema
from backend.data.model import SchemaField


class ListIteratorBlock(Block):
class StepThroughItemsBlock(Block):
class Input(BlockSchema):
items: List[Any] = SchemaField(
description="The list of items to iterate over",
placeholder="[1, 2, 3, 4, 5]",
items: list | dict = SchemaField(
description="The list or dictionary of items to iterate over",
placeholder="[1, 2, 3, 4, 5] or {'key1': 'value1', 'key2': 'value2'}",
)

class Output(BlockSchema):
item: Tuple[int, Any] = SchemaField(
description="A tuple with the index and current item in the iteration"
item: Any = SchemaField(description="The current item in the iteration")
key: Any = SchemaField(
description="The key or index of the current item in the iteration",
)

def __init__(self):
super().__init__(
id="f8e7d6c5-b4a3-2c1d-0e9f-8g7h6i5j4k3l",
input_schema=ListIteratorBlock.Input,
output_schema=ListIteratorBlock.Output,
description="Iterates over a list of items and outputs each item with its index.",
input_schema=StepThroughItemsBlock.Input,
output_schema=StepThroughItemsBlock.Output,
categories={BlockCategory.LOGIC},
test_input={"items": [1, "two", {"three": 3}, [4, 5]]},
description="Iterates over a list or dictionary and outputs each item.",
test_input={"items": [1, 2, 3, {"key1": "value1", "key2": "value2"}]},
test_output=[
("item", (0, 1)),
("item", (1, "two")),
("item", (2, {"three": 3})),
("item", (3, [4, 5])),
("item", 1),
("key", 0),
("item", 2),
("key", 1),
("item", 3),
("key", 2),
("item", {"key1": "value1", "key2": "value2"}),
("key", 3),
],
test_mock={},
)

def run(self, input_data: Input, **kwargs) -> BlockOutput:
for index, item in enumerate(input_data.items):
yield "item", (index, item)
items = input_data.items
if isinstance(items, dict):
# If items is a dictionary, iterate over its values
for item in items.values():
yield "item", item
yield "key", item
else:
# If items is a list, iterate over the list
for index, item in enumerate(items):
yield "item", item
yield "key", index
Loading
Loading