inferencesh 0.2.25__py3-none-any.whl → 0.2.27__py3-none-any.whl

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/models/llm.py CHANGED
@@ -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 LLMInput(BaseAppInput):
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
- # Model specific flags
90
- reasoning: bool = Field(default=False)
91
-
92
- tools: List[Dict[str, Any]] = Field(default=[])
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 LLMOutput(BaseAppOutput):
106
- response: str
107
- reasoning: Optional[str] = None
108
- tool_calls: Optional[List[Dict[str, Any]]] = None
109
- usage: Optional[LLMUsage] = None
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():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: inferencesh
3
- Version: 0.2.25
3
+ Version: 0.2.27
4
4
  Summary: inference.sh Python SDK
5
5
  Author: Inference Shell Inc.
6
6
  Author-email: "Inference Shell Inc." <hello@inference.sh>
@@ -2,13 +2,13 @@ inferencesh/__init__.py,sha256=WdADtOhfa3HDOunoE9HLFCTFlXRykYstBIH1FpyWvj8,613
2
2
  inferencesh/models/__init__.py,sha256=FDwcdtT6c4hbRitymjmN-hZMlQa8RbKSftkZZyjtUXA,536
3
3
  inferencesh/models/base.py,sha256=4gZQRi8J7y9U6PrGD9pRIehd1MJVJAqGakPQDs2AKFM,3251
4
4
  inferencesh/models/file.py,sha256=5xnpypcRahM1YcEjj64rv9g2gTimxrZb41YT4r440hU,7393
5
- inferencesh/models/llm.py,sha256=9d4JOlieJ-2bvwZQEAA69Qkmqk045gwibyzMcgkreFE,22362
5
+ inferencesh/models/llm.py,sha256=CryJ6cQRmFVHrhR6zsTYYpBDQFH7DmwPn-7JFE3jI8M,22030
6
6
  inferencesh/utils/__init__.py,sha256=-xiD6uo2XzcrPAWFb_fUbaimmnW4KFKc-8IvBzaxNd4,148
7
7
  inferencesh/utils/download.py,sha256=7n5twvoNYDcFnKJyefImaj2YfzRI7vddQw4usZbj38c,1521
8
8
  inferencesh/utils/storage.py,sha256=E4J8emd4eFKdmdDgAqzz3TpaaDd3n0l8gYlMHuY8yIU,519
9
- inferencesh-0.2.25.dist-info/licenses/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
10
- inferencesh-0.2.25.dist-info/METADATA,sha256=6PsBcetzAtbzXTGHBHVNkzoNVkRB9W49oaXJ0WYhBzY,2757
11
- inferencesh-0.2.25.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
- inferencesh-0.2.25.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
13
- inferencesh-0.2.25.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
14
- inferencesh-0.2.25.dist-info/RECORD,,
9
+ inferencesh-0.2.27.dist-info/licenses/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
10
+ inferencesh-0.2.27.dist-info/METADATA,sha256=Hl5m-k_2dUxK0SgDrKIwSc1JugdPoRQoqJoXyh_a63I,2757
11
+ inferencesh-0.2.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ inferencesh-0.2.27.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
13
+ inferencesh-0.2.27.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
14
+ inferencesh-0.2.27.dist-info/RECORD,,