Skip to content

Commit

Permalink
Merge pull request #10 from laelhalawani/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
laelhalawani authored Jan 6, 2024
2 parents 797568e + e5a20a9 commit daf7df7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 27 deletions.
32 changes: 19 additions & 13 deletions docs/gguf_llama/gguf_llama.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ <h1 class="title">Module <code>gguf_llama.gguf_llama</code></h1>
self.max_tokens = new_max_tokens
self._loaded = False

def _set_input_token_limit(self, new_max_input_tokens: int) -&gt; None:
def _set_input_token_limit(self, new_max_input_tokens: int=None) -&gt; None:
&#34;&#34;&#34;
Adjust the max_input_tokens attribute.

Expand All @@ -144,12 +144,15 @@ <h1 class="title">Module <code>gguf_llama.gguf_llama</code></h1>

Raises an exception if the new value is less than max_tokens.
&#34;&#34;&#34;
if new_max_input_tokens &lt; self.max_tokens:
if new_max_input_tokens is None or (new_max_input_tokens is not None and new_max_input_tokens &lt;= 0):
self._max_input_tokens = None
print(&#34;Max input tokens limit cleared.&#34;)
elif new_max_input_tokens &lt; self.max_tokens:
raise Exception(&#34;The new maximum input tokens must be greater than the current maximum tokens.&#34;)
if self._max_input_tokens is None or new_max_input_tokens != self._max_input_tokens:
elif self._max_input_tokens is None or new_max_input_tokens != self._max_input_tokens:
self._max_input_tokens = new_max_input_tokens

def set_max_tokens(self, new_max_tokens: int, max_input_tokens_limit:Optional[int]) -&gt; None:
def set_max_tokens(self, new_max_tokens: int, max_input_tokens_limit:Optional[int]=None) -&gt; None:
&#34;&#34;&#34;
Adjust both the max tokens and max input tokens.

Expand Down Expand Up @@ -225,7 +228,7 @@ <h1 class="title">Module <code>gguf_llama.gguf_llama</code></h1>
&#34;&#34;&#34;
Clear the max input tokens limit.
&#34;&#34;&#34;
self._max_input_tokens = None
self._set_input_token_limit(None)

def infer(self, text:str, only_string: bool = True, stop_at_str=None, include_stop_str=True) -&gt; Union[str, dict]:
&#34;&#34;&#34;
Expand Down Expand Up @@ -413,7 +416,7 @@ <h2 id="args">Args</h2>
self.max_tokens = new_max_tokens
self._loaded = False

def _set_input_token_limit(self, new_max_input_tokens: int) -&gt; None:
def _set_input_token_limit(self, new_max_input_tokens: int=None) -&gt; None:
&#34;&#34;&#34;
Adjust the max_input_tokens attribute.

Expand All @@ -422,12 +425,15 @@ <h2 id="args">Args</h2>

Raises an exception if the new value is less than max_tokens.
&#34;&#34;&#34;
if new_max_input_tokens &lt; self.max_tokens:
if new_max_input_tokens is None or (new_max_input_tokens is not None and new_max_input_tokens &lt;= 0):
self._max_input_tokens = None
print(&#34;Max input tokens limit cleared.&#34;)
elif new_max_input_tokens &lt; self.max_tokens:
raise Exception(&#34;The new maximum input tokens must be greater than the current maximum tokens.&#34;)
if self._max_input_tokens is None or new_max_input_tokens != self._max_input_tokens:
elif self._max_input_tokens is None or new_max_input_tokens != self._max_input_tokens:
self._max_input_tokens = new_max_input_tokens

def set_max_tokens(self, new_max_tokens: int, max_input_tokens_limit:Optional[int]) -&gt; None:
def set_max_tokens(self, new_max_tokens: int, max_input_tokens_limit:Optional[int]=None) -&gt; None:
&#34;&#34;&#34;
Adjust both the max tokens and max input tokens.

Expand Down Expand Up @@ -503,7 +509,7 @@ <h2 id="args">Args</h2>
&#34;&#34;&#34;
Clear the max input tokens limit.
&#34;&#34;&#34;
self._max_input_tokens = None
self._set_input_token_limit(None)

def infer(self, text:str, only_string: bool = True, stop_at_str=None, include_stop_str=True) -&gt; Union[str, dict]:
&#34;&#34;&#34;
Expand Down Expand Up @@ -554,7 +560,7 @@ <h3>Methods</h3>
&#34;&#34;&#34;
Clear the max input tokens limit.
&#34;&#34;&#34;
self._max_input_tokens = None </code></pre>
self._set_input_token_limit(None)</code></pre>
</details>
</dd>
<dt id="gguf_llama.gguf_llama.LlamaAI.count_tokens"><code class="name flex">
Expand Down Expand Up @@ -705,7 +711,7 @@ <h2 id="args">Args</h2>
</details>
</dd>
<dt id="gguf_llama.gguf_llama.LlamaAI.set_max_tokens"><code class="name flex">
<span>def <span class="ident">set_max_tokens</span></span>(<span>self, new_max_tokens: int, max_input_tokens_limit: Optional[int]) ‑> None</span>
<span>def <span class="ident">set_max_tokens</span></span>(<span>self, new_max_tokens: int, max_input_tokens_limit: Optional[int] = None) ‑> None</span>
</code></dt>
<dd>
<div class="desc"><p>Adjust both the max tokens and max input tokens.</p>
Expand All @@ -722,7 +728,7 @@ <h2 id="args">Args</h2>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def set_max_tokens(self, new_max_tokens: int, max_input_tokens_limit:Optional[int]) -&gt; None:
<pre><code class="python">def set_max_tokens(self, new_max_tokens: int, max_input_tokens_limit:Optional[int]=None) -&gt; None:
&#34;&#34;&#34;
Adjust both the max tokens and max input tokens.

Expand Down
19 changes: 11 additions & 8 deletions docs/gguf_llama/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ <h2 id="args">Args</h2>
self.max_tokens = new_max_tokens
self._loaded = False

def _set_input_token_limit(self, new_max_input_tokens: int) -&gt; None:
def _set_input_token_limit(self, new_max_input_tokens: int=None) -&gt; None:
&#34;&#34;&#34;
Adjust the max_input_tokens attribute.

Expand All @@ -197,12 +197,15 @@ <h2 id="args">Args</h2>

Raises an exception if the new value is less than max_tokens.
&#34;&#34;&#34;
if new_max_input_tokens &lt; self.max_tokens:
if new_max_input_tokens is None or (new_max_input_tokens is not None and new_max_input_tokens &lt;= 0):
self._max_input_tokens = None
print(&#34;Max input tokens limit cleared.&#34;)
elif new_max_input_tokens &lt; self.max_tokens:
raise Exception(&#34;The new maximum input tokens must be greater than the current maximum tokens.&#34;)
if self._max_input_tokens is None or new_max_input_tokens != self._max_input_tokens:
elif self._max_input_tokens is None or new_max_input_tokens != self._max_input_tokens:
self._max_input_tokens = new_max_input_tokens

def set_max_tokens(self, new_max_tokens: int, max_input_tokens_limit:Optional[int]) -&gt; None:
def set_max_tokens(self, new_max_tokens: int, max_input_tokens_limit:Optional[int]=None) -&gt; None:
&#34;&#34;&#34;
Adjust both the max tokens and max input tokens.

Expand Down Expand Up @@ -278,7 +281,7 @@ <h2 id="args">Args</h2>
&#34;&#34;&#34;
Clear the max input tokens limit.
&#34;&#34;&#34;
self._max_input_tokens = None
self._set_input_token_limit(None)

def infer(self, text:str, only_string: bool = True, stop_at_str=None, include_stop_str=True) -&gt; Union[str, dict]:
&#34;&#34;&#34;
Expand Down Expand Up @@ -329,7 +332,7 @@ <h3>Methods</h3>
&#34;&#34;&#34;
Clear the max input tokens limit.
&#34;&#34;&#34;
self._max_input_tokens = None </code></pre>
self._set_input_token_limit(None)</code></pre>
</details>
</dd>
<dt id="gguf_llama.LlamaAI.count_tokens"><code class="name flex">
Expand Down Expand Up @@ -480,7 +483,7 @@ <h2 id="args">Args</h2>
</details>
</dd>
<dt id="gguf_llama.LlamaAI.set_max_tokens"><code class="name flex">
<span>def <span class="ident">set_max_tokens</span></span>(<span>self, new_max_tokens: int, max_input_tokens_limit: Optional[int]) ‑> None</span>
<span>def <span class="ident">set_max_tokens</span></span>(<span>self, new_max_tokens: int, max_input_tokens_limit: Optional[int] = None) ‑> None</span>
</code></dt>
<dd>
<div class="desc"><p>Adjust both the max tokens and max input tokens.</p>
Expand All @@ -497,7 +500,7 @@ <h2 id="args">Args</h2>
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def set_max_tokens(self, new_max_tokens: int, max_input_tokens_limit:Optional[int]) -&gt; None:
<pre><code class="python">def set_max_tokens(self, new_max_tokens: int, max_input_tokens_limit:Optional[int]=None) -&gt; None:
&#34;&#34;&#34;
Adjust both the max tokens and max input tokens.

Expand Down
13 changes: 8 additions & 5 deletions gguf_llama/gguf_llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def _set_total_token_limit(self, new_max_tokens: int) -> None:
self.max_tokens = new_max_tokens
self._loaded = False

def _set_input_token_limit(self, new_max_input_tokens: int) -> None:
def _set_input_token_limit(self, new_max_input_tokens: int=None) -> None:
"""
Adjust the max_input_tokens attribute.
Expand All @@ -116,12 +116,15 @@ def _set_input_token_limit(self, new_max_input_tokens: int) -> None:
Raises an exception if the new value is less than max_tokens.
"""
if new_max_input_tokens < self.max_tokens:
if new_max_input_tokens is None or (new_max_input_tokens is not None and new_max_input_tokens <= 0):
self._max_input_tokens = None
print("Max input tokens limit cleared.")
elif new_max_input_tokens < self.max_tokens:
raise Exception("The new maximum input tokens must be greater than the current maximum tokens.")
if self._max_input_tokens is None or new_max_input_tokens != self._max_input_tokens:
elif self._max_input_tokens is None or new_max_input_tokens != self._max_input_tokens:
self._max_input_tokens = new_max_input_tokens

def set_max_tokens(self, new_max_tokens: int, max_input_tokens_limit:Optional[int]) -> None:
def set_max_tokens(self, new_max_tokens: int, max_input_tokens_limit:Optional[int]=None) -> None:
"""
Adjust both the max tokens and max input tokens.
Expand Down Expand Up @@ -197,7 +200,7 @@ def clear_input_tokens_limit(self) -> None:
"""
Clear the max input tokens limit.
"""
self._max_input_tokens = None
self._set_input_token_limit(None)

def infer(self, text:str, only_string: bool = True, stop_at_str=None, include_stop_str=True) -> Union[str, dict]:
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
long_description = fh.read()
setup(
name="gguf_llama",
version="0.0.14",
version="0.0.15",
packages=find_packages(),
install_requires=[
'util_helper>=0.0.3',
Expand Down

0 comments on commit daf7df7

Please sign in to comment.