inferencesh 0.2.25__tar.gz → 0.2.27__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.
Potentially problematic release.
This version of inferencesh might be problematic. Click here for more details.
- {inferencesh-0.2.25/src/inferencesh.egg-info → inferencesh-0.2.27}/PKG-INFO +1 -1
- {inferencesh-0.2.25 → inferencesh-0.2.27}/pyproject.toml +1 -1
- {inferencesh-0.2.25 → inferencesh-0.2.27}/src/inferencesh/models/llm.py +54 -33
- {inferencesh-0.2.25 → inferencesh-0.2.27/src/inferencesh.egg-info}/PKG-INFO +1 -1
- {inferencesh-0.2.25 → inferencesh-0.2.27}/LICENSE +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/README.md +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/setup.cfg +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/setup.py +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/src/inferencesh/__init__.py +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/src/inferencesh/models/__init__.py +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/src/inferencesh/models/base.py +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/src/inferencesh/models/file.py +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/src/inferencesh/utils/__init__.py +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/src/inferencesh/utils/download.py +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/src/inferencesh/utils/storage.py +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/src/inferencesh.egg-info/SOURCES.txt +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/src/inferencesh.egg-info/dependency_links.txt +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/src/inferencesh.egg-info/entry_points.txt +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/src/inferencesh.egg-info/requires.txt +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/src/inferencesh.egg-info/top_level.txt +0 -0
- {inferencesh-0.2.25 → inferencesh-0.2.27}/tests/test_sdk.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from typing import Optional, List, Any, Callable, Dict, Generator
|
|
2
2
|
from enum import Enum
|
|
3
|
-
from pydantic import Field
|
|
3
|
+
from pydantic import Field, BaseModel
|
|
4
4
|
from queue import Queue
|
|
5
5
|
from threading import Thread
|
|
6
6
|
import time
|
|
@@ -9,6 +9,7 @@ import base64
|
|
|
9
9
|
|
|
10
10
|
from .base import BaseAppInput, BaseAppOutput
|
|
11
11
|
from .file import File
|
|
12
|
+
from .types import ContextMessage
|
|
12
13
|
|
|
13
14
|
class ContextMessageRole(str, Enum):
|
|
14
15
|
USER = "user"
|
|
@@ -33,7 +34,8 @@ class ContextMessage(BaseAppInput):
|
|
|
33
34
|
default=None
|
|
34
35
|
)
|
|
35
36
|
|
|
36
|
-
class
|
|
37
|
+
class BaseLLMInput(BaseAppInput):
|
|
38
|
+
"""Base class with common LLM fields."""
|
|
37
39
|
system_prompt: str = Field(
|
|
38
40
|
description="The system prompt to use for the model",
|
|
39
41
|
default="You are a helpful assistant that can answer questions and help with tasks.",
|
|
@@ -47,25 +49,13 @@ class LLMInput(BaseAppInput):
|
|
|
47
49
|
)
|
|
48
50
|
context: List[ContextMessage] = Field(
|
|
49
51
|
description="The context to use for the model",
|
|
52
|
+
default=[],
|
|
50
53
|
examples=[
|
|
51
54
|
[
|
|
52
|
-
{"role": "user", "content": [{"type": "text", "text": "What is the capital of France?"}]},
|
|
55
|
+
{"role": "user", "content": [{"type": "text", "text": "What is the capital of France?"}]},
|
|
53
56
|
{"role": "assistant", "content": [{"type": "text", "text": "The capital of France is Paris."}]}
|
|
54
|
-
],
|
|
55
|
-
[
|
|
56
|
-
{"role": "user", "content": [{"type": "text", "text": "What is the weather like today?"}]},
|
|
57
|
-
{"role": "assistant", "content": [{"type": "text", "text": "I apologize, but I don't have access to real-time weather information. You would need to check a weather service or app to get current weather conditions for your location."}]}
|
|
58
|
-
],
|
|
59
|
-
[
|
|
60
|
-
{"role": "user", "content": [{"type": "text", "text": "Can you help me write a poem about spring?"}]},
|
|
61
|
-
{"role": "assistant", "content": [{"type": "text", "text": "Here's a short poem about spring:\n\nGreen buds awakening,\nSoft rain gently falling down,\nNew life springs anew.\n\nWarm sun breaks through clouds,\nBirds return with joyful song,\nNature's sweet rebirth."}]}
|
|
62
|
-
],
|
|
63
|
-
[
|
|
64
|
-
{"role": "user", "content": [{"type": "text", "text": "Explain quantum computing in simple terms"}]},
|
|
65
|
-
{"role": "assistant", "content": [{"type": "text", "text": "Quantum computing is like having a super-powerful calculator that can solve many problems at once instead of one at a time. While regular computers use bits (0s and 1s), quantum computers use quantum bits or \"qubits\" that can be both 0 and 1 at the same time - kind of like being in two places at once! This allows them to process huge amounts of information much faster than regular computers for certain types of problems."}]}
|
|
66
57
|
]
|
|
67
|
-
]
|
|
68
|
-
default=[]
|
|
58
|
+
]
|
|
69
59
|
)
|
|
70
60
|
text: str = Field(
|
|
71
61
|
description="The user prompt to use for the model",
|
|
@@ -74,22 +64,41 @@ class LLMInput(BaseAppInput):
|
|
|
74
64
|
"What is the weather like today?",
|
|
75
65
|
"Can you help me write a poem about spring?",
|
|
76
66
|
"Explain quantum computing in simple terms"
|
|
77
|
-
]
|
|
78
|
-
)
|
|
79
|
-
image: Optional[File] = Field(
|
|
80
|
-
description="The image to use for the model",
|
|
81
|
-
default=None
|
|
67
|
+
]
|
|
82
68
|
)
|
|
83
|
-
# Optional parameters
|
|
84
69
|
temperature: float = Field(default=0.7)
|
|
85
70
|
top_p: float = Field(default=0.95)
|
|
86
71
|
max_tokens: int = Field(default=4096)
|
|
87
72
|
context_size: int = Field(default=4096)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
73
|
+
|
|
74
|
+
class ImageCapabilityMixin(BaseModel):
|
|
75
|
+
"""Mixin for models that support image inputs."""
|
|
76
|
+
image: Optional[File] = Field(
|
|
77
|
+
description="The image to use for the model",
|
|
78
|
+
default=None
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
class ReasoningCapabilityMixin(BaseModel):
|
|
82
|
+
"""Mixin for models that support reasoning."""
|
|
83
|
+
reasoning: bool = Field(
|
|
84
|
+
description="Enable step-by-step reasoning",
|
|
85
|
+
default=False
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
class ToolsCapabilityMixin(BaseModel):
|
|
89
|
+
"""Mixin for models that support tool/function calling."""
|
|
90
|
+
tools: Optional[List[Dict[str, Any]]] = Field(
|
|
91
|
+
description="Tool definitions for function calling",
|
|
92
|
+
default=None
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# Example of how to use:
|
|
96
|
+
class LLMInput(BaseLLMInput):
|
|
97
|
+
"""Default LLM input model with no special capabilities."""
|
|
98
|
+
pass
|
|
99
|
+
|
|
100
|
+
# For backward compatibility
|
|
101
|
+
LLMInput.model_config["title"] = "LLMInput"
|
|
93
102
|
|
|
94
103
|
class LLMUsage(BaseAppOutput):
|
|
95
104
|
stop_reason: str = ""
|
|
@@ -102,12 +111,24 @@ class LLMUsage(BaseAppOutput):
|
|
|
102
111
|
reasoning_time: float = 0.0
|
|
103
112
|
|
|
104
113
|
|
|
105
|
-
class
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
114
|
+
class BaseLLMOutput(BaseAppOutput):
|
|
115
|
+
"""Base class for LLM outputs with common fields."""
|
|
116
|
+
text: str = Field(description="The generated text response")
|
|
117
|
+
done: bool = Field(default=False, description="Whether this is the final chunk")
|
|
118
|
+
|
|
119
|
+
class LLMUsageMixin(BaseModel):
|
|
120
|
+
"""Mixin for models that provide token usage statistics."""
|
|
121
|
+
usage: Optional[LLMUsage] = Field(
|
|
122
|
+
description="Token usage statistics"
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
# Example of how to use:
|
|
126
|
+
class LLMOutput(BaseLLMOutput, LLMUsageMixin):
|
|
127
|
+
"""Default LLM output model with token usage tracking."""
|
|
128
|
+
pass
|
|
110
129
|
|
|
130
|
+
# For backward compatibility
|
|
131
|
+
LLMOutput.model_config["title"] = "LLMOutput"
|
|
111
132
|
|
|
112
133
|
@contextmanager
|
|
113
134
|
def timing_context():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|