HowdenLLM 1.7.0__tar.gz → 3.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {howdenllm-1.7.0 → howdenllm-3.0.0}/HowdenLLM/manager.py +2 -2
- howdenllm-3.0.0/HowdenLLM/providers/base_provider.py +7 -0
- {howdenllm-1.7.0 → howdenllm-3.0.0}/HowdenLLM/providers/provider_anthropic.py +4 -4
- {howdenllm-1.7.0 → howdenllm-3.0.0}/HowdenLLM/providers/provider_factory.py +4 -4
- {howdenllm-1.7.0 → howdenllm-3.0.0}/HowdenLLM/providers/provider_huggingface.py +4 -2
- {howdenllm-1.7.0 → howdenllm-3.0.0}/HowdenLLM/providers/provider_openai.py +4 -4
- {howdenllm-1.7.0 → howdenllm-3.0.0}/PKG-INFO +1 -1
- {howdenllm-1.7.0 → howdenllm-3.0.0}/pyproject.toml +1 -0
- howdenllm-1.7.0/HowdenLLM/providers/base_provider.py +0 -7
- {howdenllm-1.7.0 → howdenllm-3.0.0}/HowdenLLM/__init__.py +0 -0
- {howdenllm-1.7.0 → howdenllm-3.0.0}/HowdenLLM/providers/__init__.py +0 -0
- {howdenllm-1.7.0 → howdenllm-3.0.0}/HowdenLLM/providers/known_providers.py +0 -0
- {howdenllm-1.7.0 → howdenllm-3.0.0}/HowdenLLM/providers/provider_meta.py +0 -0
- {howdenllm-1.7.0 → howdenllm-3.0.0}/README.md +0 -0
|
@@ -70,7 +70,7 @@ class LLM:
|
|
|
70
70
|
except (KeyError, LookupError, AttributeError, ImportError):
|
|
71
71
|
return len(text.split())
|
|
72
72
|
|
|
73
|
-
def __call__(self, path_or_content: Path | str) -> str:
|
|
73
|
+
async def __call__(self, path_or_content: Path | str) -> str:
|
|
74
74
|
"""
|
|
75
75
|
Execute one completion round and return:
|
|
76
76
|
(output_text, input_token_count, output_token_count)
|
|
@@ -89,7 +89,7 @@ class LLM:
|
|
|
89
89
|
input_tokens = self._count_tokens(input_text)
|
|
90
90
|
|
|
91
91
|
# --- run model ---
|
|
92
|
-
output = self.provider.complete(self.system, prompt, self.model, self.use_web_search_tool,self.upload_attachment)
|
|
92
|
+
output = await self.provider.complete(self.system, prompt, self.model, self.use_web_search_tool,self.upload_attachment)
|
|
93
93
|
|
|
94
94
|
# --- count output tokens ---
|
|
95
95
|
output_tokens = self._count_tokens(output)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from .provider_meta import ProviderMeta
|
|
3
|
+
|
|
4
|
+
class BaseProvider(ABC, metaclass=ProviderMeta):
|
|
5
|
+
@abstractmethod
|
|
6
|
+
async def complete(self, system: str, prompt: str, model: str, use_web_search_tool: bool, upload_attachment: str|None) -> str:
|
|
7
|
+
pass
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
from abc import ABC
|
|
2
2
|
from HowdenLLM.providers.base_provider import BaseProvider
|
|
3
|
-
from anthropic import
|
|
3
|
+
from anthropic import AsyncAnthropic
|
|
4
4
|
from .known_providers import KnownProviders
|
|
5
5
|
|
|
6
6
|
class AnthropicProvider(BaseProvider, ABC):
|
|
7
7
|
provider = KnownProviders.Anthropic
|
|
8
8
|
|
|
9
|
-
def __init__(self,client:
|
|
9
|
+
def __init__(self,client: AsyncAnthropic):
|
|
10
10
|
self.client = client
|
|
11
11
|
|
|
12
|
-
def complete(self, system: str, prompt: str, model: str, use_web_search_tool: bool, upload_attachment: str) -> str:
|
|
12
|
+
async def complete(self, system: str, prompt: str, model: str, use_web_search_tool: bool, upload_attachment: str) -> str:
|
|
13
13
|
|
|
14
14
|
if use_web_search_tool:
|
|
15
15
|
tools=[{"type": "web_search_20260209","name": "web_search","max_uses": 5}]
|
|
@@ -17,7 +17,7 @@ class AnthropicProvider(BaseProvider, ABC):
|
|
|
17
17
|
tools = []
|
|
18
18
|
|
|
19
19
|
if model in ["claude-opus-4-6","claude-opus-4-5-20251101","claude-sonnet-4-6","claude-sonnet-4-5-20250929"]:
|
|
20
|
-
message = self.client.messages.create(
|
|
20
|
+
message = await self.client.messages.create(
|
|
21
21
|
model=model,
|
|
22
22
|
system=system,
|
|
23
23
|
messages=[
|
|
@@ -41,13 +41,13 @@ class ProviderFactory:
|
|
|
41
41
|
if key not in ProviderFactory.clients_alive.keys():
|
|
42
42
|
load_dotenv()
|
|
43
43
|
if key == KnownProviders.OpenAI:
|
|
44
|
-
from openai import
|
|
45
|
-
ProviderFactory.clients_alive[key] =
|
|
44
|
+
from openai import AsyncOpenAI
|
|
45
|
+
ProviderFactory.clients_alive[key] = AsyncOpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
|
46
46
|
elif key == KnownProviders.HuggingFace:
|
|
47
47
|
from huggingface_hub import InferenceClient
|
|
48
48
|
ProviderFactory.clients_alive[key] = InferenceClient(token=os.getenv("HUGGINGFACE_API_KEY"))
|
|
49
49
|
elif key == KnownProviders.Anthropic:
|
|
50
|
-
from anthropic import
|
|
51
|
-
ProviderFactory.clients_alive[key] =
|
|
50
|
+
from anthropic import AsyncAnthropic
|
|
51
|
+
ProviderFactory.clients_alive[key] = AsyncAnthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
|
|
52
52
|
|
|
53
53
|
return providers[key](ProviderFactory.clients_alive[key])
|
|
@@ -3,6 +3,7 @@ from dotenv import load_dotenv
|
|
|
3
3
|
import os
|
|
4
4
|
from huggingface_hub import InferenceClient
|
|
5
5
|
from .known_providers import KnownProviders
|
|
6
|
+
import asyncio
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
class HuggingFaceProvider(BaseProvider):
|
|
@@ -11,9 +12,10 @@ class HuggingFaceProvider(BaseProvider):
|
|
|
11
12
|
def __init__(self,client: InferenceClient):
|
|
12
13
|
self.client = client
|
|
13
14
|
|
|
14
|
-
def complete(self, system: str, prompt: str, model: str, use_web_search_tool: bool) -> str:
|
|
15
|
+
async def complete(self, system: str, prompt: str, model: str, use_web_search_tool: bool) -> str:
|
|
15
16
|
full_prompt = f"[System]: {system}\n[User]: {prompt}\n"
|
|
16
|
-
response =
|
|
17
|
+
response = await asyncio.to_thread(
|
|
18
|
+
self.client.text_generation,
|
|
17
19
|
model=model,
|
|
18
20
|
prompt=full_prompt,
|
|
19
21
|
max_new_tokens=500,
|
|
@@ -3,16 +3,16 @@ from abc import ABC
|
|
|
3
3
|
from sympy.codegen.ast import continue_
|
|
4
4
|
|
|
5
5
|
from HowdenLLM.providers.base_provider import BaseProvider
|
|
6
|
-
from openai import
|
|
6
|
+
from openai import AsyncOpenAI
|
|
7
7
|
from .known_providers import KnownProviders
|
|
8
8
|
|
|
9
9
|
class OpenAIProvider(BaseProvider, ABC):
|
|
10
10
|
provider = KnownProviders.OpenAI
|
|
11
11
|
|
|
12
|
-
def __init__(self,client:
|
|
12
|
+
def __init__(self,client: AsyncOpenAI):
|
|
13
13
|
self.client = client
|
|
14
14
|
|
|
15
|
-
def complete(self, system: str, prompt: str, model: str, use_web_search_tool: bool, upload_attachment: str|None) -> str:
|
|
15
|
+
async def complete(self, system: str, prompt: str, model: str, use_web_search_tool: bool, upload_attachment: str|None) -> str:
|
|
16
16
|
|
|
17
17
|
if use_web_search_tool:
|
|
18
18
|
tools = [
|
|
@@ -41,7 +41,7 @@ class OpenAIProvider(BaseProvider, ABC):
|
|
|
41
41
|
]
|
|
42
42
|
|
|
43
43
|
if model in ["gpt-5", "gpt-5.2", "gpt-5-mini", "gpt-5.4-mini", "gpt-5-nano"]:
|
|
44
|
-
response = self.client.responses.create(
|
|
44
|
+
response = await self.client.responses.create(
|
|
45
45
|
model=model,
|
|
46
46
|
input=input,
|
|
47
47
|
tools=tools,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
from abc import ABC, abstractmethod
|
|
2
|
-
from .provider_meta import ProviderMeta
|
|
3
|
-
|
|
4
|
-
class BaseProvider(ABC, metaclass=ProviderMeta):
|
|
5
|
-
@abstractmethod
|
|
6
|
-
def complete(self, system: str, prompt: str, model: str, use_web_search_tool: bool, upload_attachment: str|None) -> str:
|
|
7
|
-
pass
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|