AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(blocks) Add ollama integration (#7505)
Aarushie6f9870f2ec0
diff --git a/rnd/autogpt_server/autogpt_server/blocks/llm.py b/rnd/autogpt_server/autogpt_server/blocks/llm.pyindex b0e2b4d53a..7b40b1ef5a 100644--- a/rnd/autogpt_server/autogpt_server/blocks/llm.py+++ b/rnd/autogpt_server/autogpt_server/blocks/llm.py@@ -3,6 +3,7 @@ from enum import Enumfrom typing import NamedTupleimport anthropic+import ollamaimport openaifrom groq import Groq@@ -16,6 +17,7 @@ LlmApiKeys = {"openai": BlockSecret("openai_api_key"),"anthropic": BlockSecret("anthropic_api_key"),"groq": BlockSecret("groq_api_key"),+ "ollama": BlockSecret(value=""),}@@ -39,6 +41,8 @@ class LlmModel(str, Enum):MIXTRAL_8X7B = "mixtral-8x7b-32768"GEMMA_7B = "gemma-7b-it"GEMMA2_9B = "gemma2-9b-it"+ # Ollama models+ OLLAMA_LLAMA3_8B = "llama3"@propertydef metadata(self) -> ModelMetadata:@@ -57,6 +61,7 @@ MODEL_METADATA = {LlmModel.MIXTRAL_8X7B: ModelMetadata("groq", 32768),LlmModel.GEMMA_7B: ModelMetadata("groq", 8192),LlmModel.GEMMA2_9B: ModelMetadata("groq", 8192),+ LlmModel.OLLAMA_LLAMA3_8B: ModelMetadata("ollama", 8192),}@@ -133,6 +138,12 @@ class LlmCallBlock(Block):response_format=response_format, # type: ignore)return response.choices[0].message.content or ""+ elif provider == "ollama":+ response = ollama.generate(+ model=model.value,+ prompt=prompt[0]["content"],+ )+ return response["response"]else:raise ValueError(f"Unsupported LLM provider: {provider}")diff --git a/rnd/autogpt_server/poetry.lock b/rnd/autogpt_server/poetry.lockindex 71c31497ed..8732185aae 100644--- a/rnd/autogpt_server/poetry.lock+++ b/rnd/autogpt_server/poetry.lock@@ -1,4 +1,4 @@-# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand.+# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.[[package]]name = "agpt"@@ -25,7 +25,7 @@ requests = "*"sentry-sdk = "^1.40.4"[package.extras]-benchmark = ["agbenchmark @ file:///Users/majdyz/Code/AutoGPT/benchmark"]+benchmark = ["agbenchmark"][package.source]type = "directory"@@ -329,7 +329,7 @@ watchdog = "4.0.0"webdriver-manager = "^4.0.1"[package.extras]-benchmark = ["agbenchmark @ file:///Users/majdyz/Code/AutoGPT/benchmark"]+benchmark = ["agbenchmark"][package.source]type = "directory"@@ -2354,6 +2354,9 @@ files = [{file = "lief-0.14.1-cp312-cp312-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl", hash = "sha256:497b88f9c9aaae999766ba188744ee35c5f38b4b64016f7dbb7037e9bf325382"},{file = "lief-0.14.1-cp312-cp312-win32.whl", hash = "sha256:08bad88083f696915f8dcda4042a3bfc514e17462924ec8984085838b2261921"},{file = "lief-0.14.1-cp312-cp312-win_amd64.whl", hash = "sha256:e131d6158a085f8a72124136816fefc29405c725cd3695ce22a904e471f0f815"},+ {file = "lief-0.14.1-cp313-cp313-manylinux_2_28_x86_64.manylinux_2_27_x86_64.whl", hash = "sha256:f9ff9a6959fb6d0e553cca41cd1027b609d27c5073e98d9fad8b774fbb5746c2"},+ {file = "lief-0.14.1-cp313-cp313-win32.whl", hash = "sha256:95f295a7cc68f4e14ce7ea4ff8082a04f5313c2e5e63cc2bbe9d059190b7e4d5"},+ {file = "lief-0.14.1-cp313-cp313-win_amd64.whl", hash = "sha256:cdc1123c2e27970f8c8353505fd578e634ab33193c8d1dff36dc159e25599a40"},{file = "lief-0.14.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:df650fa05ca131e4dfeb42c77985e1eb239730af9944bc0aadb1dfac8576e0e8"},{file = "lief-0.14.1-cp38-cp38-macosx_11_0_x86_64.whl", hash = "sha256:b4e76eeb48ca2925c6ca6034d408582615f2faa855f9bb11482e7acbdecc4803"},{file = "lief-0.14.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:016e4fac91303466024154dd3c4b599e8b7c52882f72038b62a2be386d98c8f9"},@@ -3132,6 +3135,20 @@ rsa = ["cryptography (>=3.0.0)"]signals = ["blinker (>=1.4.0)"]signedtoken = ["cryptography (>=3.0.0)", "pyjwt (>=2.0.0,<3)"]+[[package]]+name = "ollama"+version = "0.3.0"+description = "The official Python client for Ollama."+optional = false+python-versions = "<4.0,>=3.8"+files = [+ {file = "ollama-0.3.0-py3-none-any.whl", hash = "sha256:cd7010c4e2a37d7f08f36cd35c4592b14f1ec0d1bf3df10342cd47963d81ad7a"},+ {file = "ollama-0.3.0.tar.gz", hash = "sha256:6ff493a2945ba76cdd6b7912a1cd79a45cfd9ba9120d14adeb63b2b5a7f353da"},+]++[package.dependencies]+httpx = ">=0.27.0,<0.28.0"+[[package]]name = "onnxruntime"version = "1.18.1"@@ -6331,4 +6348,4 @@ test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools",[metadata]lock-version = "2.0"python-versions = "^3.10"-content-hash = "9544eed64854c066f3796e1e7b18e6c9125a73ff57a5a818ee01e47cc3f09c85"+content-hash = "1aadbaecdb13f497ec2d19e149160e736c464fb1863025b0b8d1674999cfd523"diff --git a/rnd/autogpt_server/pyproject.toml b/rnd/autogpt_server/pyproject.tomlindex 54bac719a1..d67e326854 100644--- a/rnd/autogpt_server/pyproject.toml+++ b/rnd/autogpt_server/pyproject.toml@@ -35,6 +35,7 @@ groq = "^0.8.0"anthropic = "^0.25.1"+ollama = "^0.3.0"[tool.poetry.group.dev.dependencies]cx-freeze = { git = "https://github.com/ntindle/cx_Freeze.git", rev = "main", develop = true }poethepoet = "^0.26.1"