Skip to content

feat(blocks): Ollama - Remote hosts #8234

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

Merged
merged 44 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 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
9390c50
Discard changes to autogpt_platform/backend/backend/blocks/iteration.py
ntindle Dec 12, 2024
aa1169c
Delete autogpt_platform/infra/helm/autogpt-server/values.prod.yaml
ntindle Dec 12, 2024
d0c0eaa
Delete autogpt_platform/infra/helm/autogpt-server/templates/backendco…
ntindle Dec 12, 2024
f6daa8d
Discard changes to autogpt_platform/backend/backend/blocks/search.py
ntindle Dec 12, 2024
812fa0b
Discard changes to autogpt_platform/frontend/src/components/TallyPopu…
ntindle Dec 12, 2024
8b4d2bb
Discard changes to autogpt_platform/frontend/src/components/marketpla…
ntindle Dec 12, 2024
0fc0381
Delete autogpt_platform/frontend/src/components/nav/MarketPopup.tsx
ntindle Dec 12, 2024
90514cf
Delete autogpt_platform/infra/helm/autogpt-server/templates/deploymen…
ntindle Dec 12, 2024
a6e71b3
Delete autogpt_platform/frontend/src/components/nav/NavBarButtons.tsx
ntindle Dec 12, 2024
498e341
Discard changes to autogpt_platform/frontend/src/lib/utils.ts
ntindle Dec 12, 2024
7a92aee
Discard changes to autogpt_platform/infra/helm/autogpt-builder/values…
ntindle Dec 12, 2024
01ff691
Discard changes to autogpt_platform/frontend/yarn.lock
ntindle Dec 12, 2024
3c892ae
Delete autogpt_platform/infra/helm/autogpt-server/templates/service-e…
ntindle Dec 12, 2024
cc71a59
Discard changes to autogpt_platform/infra/helm/autogpt-server/values.…
ntindle Dec 12, 2024
a143a31
Rename autogpt_platform/frontend/src/components/nav/CreditButton.tsx …
ntindle Dec 12, 2024
363ce4f
Merge branch 'dev' into ollama_remote
ntindle Dec 12, 2024
673451e
fix: merge mess
ntindle Dec 12, 2024
717551d
fix: merge mess
ntindle Dec 12, 2024
849e23d
fix: give it a cost why dont ya
ntindle Dec 12, 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
35 changes: 34 additions & 1 deletion autogpt_platform/backend/backend/blocks/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class LlmModel(str, Enum, metaclass=LlmModelMeta):
# Ollama models
OLLAMA_LLAMA3_8B = "llama3"
OLLAMA_LLAMA3_405B = "llama3.1:405b"
OLLAMA_DOLPHIN = "dolphin-mistral:latest"
# OpenRouter models
GEMINI_FLASH_1_5_8B = "google/gemini-flash-1.5"
GROK_BETA = "x-ai/grok-beta"
Expand Down Expand Up @@ -164,6 +165,7 @@ def context_window(self) -> int:
LlmModel.LLAMA3_1_8B: ModelMetadata("groq", 131072),
LlmModel.OLLAMA_LLAMA3_8B: ModelMetadata("ollama", 8192),
LlmModel.OLLAMA_LLAMA3_405B: ModelMetadata("ollama", 8192),
LlmModel.OLLAMA_DOLPHIN: ModelMetadata("ollama", 32768),
LlmModel.GEMINI_FLASH_1_5_8B: ModelMetadata("open_router", 8192),
LlmModel.GROK_BETA: ModelMetadata("open_router", 8192),
LlmModel.MISTRAL_NEMO: ModelMetadata("open_router", 4000),
Expand Down Expand Up @@ -240,6 +242,12 @@ class Input(BlockSchema):
description="The maximum number of tokens to generate in the chat completion.",
)

ollama_host: str = SchemaField(
advanced=True,
default="localhost:11434",
description="Ollama host for local models",
)

class Output(BlockSchema):
response: dict[str, Any] = SchemaField(
description="The response object generated by the language model."
Expand Down Expand Up @@ -285,6 +293,7 @@ def llm_call(
prompt: list[dict],
json_format: bool,
max_tokens: int | None = None,
ollama_host: str = "localhost:11434",
) -> tuple[str, int, int]:
"""
Args:
Expand All @@ -293,6 +302,7 @@ def llm_call(
prompt: The prompt to send to the LLM.
json_format: Whether the response should be in JSON format.
max_tokens: The maximum number of tokens to generate in the chat completion.
ollama_host: The host for ollama to use

Returns:
The response from the LLM.
Expand Down Expand Up @@ -382,9 +392,10 @@ def llm_call(
response.usage.completion_tokens if response.usage else 0,
)
elif provider == "ollama":
client = ollama.Client(host=ollama_host)
sys_messages = [p["content"] for p in prompt if p["role"] == "system"]
usr_messages = [p["content"] for p in prompt if p["role"] != "system"]
response = ollama.generate(
response = client.generate(
model=llm_model.value,
prompt=f"{sys_messages}\n\n{usr_messages}",
stream=False,
Expand Down Expand Up @@ -484,6 +495,7 @@ def parse_response(resp: str) -> tuple[dict[str, Any], str | None]:
llm_model=llm_model,
prompt=prompt,
json_format=bool(input_data.expected_format),
ollama_host=input_data.ollama_host,
max_tokens=input_data.max_tokens,
)
self.merge_stats(
Expand Down Expand Up @@ -566,6 +578,11 @@ class Input(BlockSchema):
prompt_values: dict[str, str] = SchemaField(
advanced=False, default={}, description="Values used to fill in the prompt."
)
ollama_host: str = SchemaField(
advanced=True,
default="localhost:11434",
description="Ollama host for local models",
)
max_tokens: int | None = SchemaField(
advanced=True,
default=None,
Expand Down Expand Up @@ -656,6 +673,11 @@ class Input(BlockSchema):
description="The number of overlapping tokens between chunks to maintain context.",
ge=0,
)
ollama_host: str = SchemaField(
advanced=True,
default="localhost:11434",
description="Ollama host for local models",
)

class Output(BlockSchema):
summary: str = SchemaField(description="The final summary of the text.")
Expand Down Expand Up @@ -794,6 +816,11 @@ class Input(BlockSchema):
default=None,
description="The maximum number of tokens to generate in the chat completion.",
)
ollama_host: str = SchemaField(
advanced=True,
default="localhost:11434",
description="Ollama host for local models",
)

class Output(BlockSchema):
response: str = SchemaField(
Expand Down Expand Up @@ -891,6 +918,11 @@ class Input(BlockSchema):
default=None,
description="The maximum number of tokens to generate in the chat completion.",
)
ollama_host: str = SchemaField(
advanced=True,
default="localhost:11434",
description="Ollama host for local models",
)

class Output(BlockSchema):
generated_list: List[str] = SchemaField(description="The generated list.")
Expand Down Expand Up @@ -1042,6 +1074,7 @@ def run(
credentials=input_data.credentials,
model=input_data.model,
expected_format={}, # Do not use structured response
ollama_host=input_data.ollama_host,
),
credentials=credentials,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
LlmModel.LLAMA3_1_8B: 1,
LlmModel.OLLAMA_LLAMA3_8B: 1,
LlmModel.OLLAMA_LLAMA3_405B: 1,
LlmModel.OLLAMA_DOLPHIN: 1,
LlmModel.GEMINI_FLASH_1_5_8B: 1,
LlmModel.GROK_BETA: 5,
LlmModel.MISTRAL_NEMO: 1,
Expand Down
Loading