Merge branch 'KoboldAI:main' into united
This commit is contained in:
commit
5f3783a294
|
@ -165,7 +165,7 @@ return function(_python, _bridged)
|
|||
---@field num_outputs integer
|
||||
---@field feedback string
|
||||
---@field is_config_file_open boolean
|
||||
local kobold = setmetatable({API_VERSION = 1.1}, metawrapper)
|
||||
local kobold = setmetatable({API_VERSION = 1.2}, metawrapper)
|
||||
local KoboldLib_mt = setmetatable({}, metawrapper)
|
||||
local KoboldLib_getters = setmetatable({}, metawrapper)
|
||||
local KoboldLib_setters = setmetatable({}, metawrapper)
|
||||
|
@ -505,6 +505,7 @@ return function(_python, _bridged)
|
|||
elseif entries.name == "KoboldWorldInfoEntry" then
|
||||
_entries = {entries}
|
||||
else
|
||||
_entries = {}
|
||||
for k, v in pairs(entries) do
|
||||
if type(v) == "table" and v.name == "KoboldWorldInfoEntry" and v:is_valid() then
|
||||
_entries[k] = v.uid
|
||||
|
|
|
@ -470,11 +470,11 @@
|
|||
<pre class=" language-lua"><code class="prism language-lua"><span class="token keyword">local</span> entry <span class="token operator">=</span> kobold<span class="token punctuation">.</span>worldinfo<span class="token punctuation">[</span><span class="token number">5</span><span class="token punctuation">]</span> <span class="token comment">-- Retrieves fifth entry from top as a KoboldWorldInfoEntry</span>
|
||||
</code></pre>
|
||||
<p>You can use <code>ipairs</code> or a numeric loop to iterate from top to bottom:</p>
|
||||
<pre class=" language-lua"><code class="prism language-lua"><span class="token keyword">for</span> index<span class="token punctuation">,</span> entry <span class="token keyword">in</span> <span class="token function">ipairs</span><span class="token punctuation">(</span>kobold<span class="token punctuation">.</span>worldinfo<span class="token punctuation">)</span><span class="token punctuation">:</span>
|
||||
<pre class=" language-lua"><code class="prism language-lua"><span class="token keyword">for</span> index<span class="token punctuation">,</span> entry <span class="token keyword">in</span> <span class="token function">ipairs</span><span class="token punctuation">(</span>kobold<span class="token punctuation">.</span>worldinfo<span class="token punctuation">)</span> <span class="token keyword">do</span>
|
||||
<span class="token function">print</span><span class="token punctuation">(</span>index<span class="token punctuation">,</span> entry<span class="token punctuation">.</span>content<span class="token punctuation">)</span>
|
||||
<span class="token keyword">end</span>
|
||||
</code></pre>
|
||||
<pre class=" language-lua"><code class="prism language-lua"><span class="token keyword">for</span> index <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token operator">#</span>kobold<span class="token punctuation">.</span>worldinfo <span class="token keyword">do</span><span class="token punctuation">:</span>
|
||||
<pre class=" language-lua"><code class="prism language-lua"><span class="token keyword">for</span> index <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token operator">#</span>kobold<span class="token punctuation">.</span>worldinfo <span class="token keyword">do</span>
|
||||
<span class="token function">print</span><span class="token punctuation">(</span>index<span class="token punctuation">,</span> kobold<span class="token punctuation">.</span>worldinfo<span class="token punctuation">[</span>index<span class="token punctuation">]</span><span class="token punctuation">.</span>content<span class="token punctuation">)</span>
|
||||
<span class="token keyword">end</span>
|
||||
</code></pre>
|
||||
|
@ -531,11 +531,11 @@
|
|||
<p>Can be indexed in amortized constant worst-case time and iterated over and has a <code>finduid</code> method just like <code>kobold.worldinfo</code>, but gets folders (as <code>KoboldWorldInfoFolder</code> objects) instead.</p>
|
||||
<pre class=" language-lua"><code class="prism language-lua"><span class="token keyword">local</span> folder <span class="token operator">=</span> kobold<span class="token punctuation">.</span>worldinfo<span class="token punctuation">.</span>folders<span class="token punctuation">[</span><span class="token number">5</span><span class="token punctuation">]</span> <span class="token comment">-- Retrieves fifth folder from top as a KoboldWorldInfoFolder</span>
|
||||
</code></pre>
|
||||
<pre class=" language-lua"><code class="prism language-lua"><span class="token keyword">for</span> index<span class="token punctuation">,</span> folder <span class="token keyword">in</span> <span class="token function">ipairs</span><span class="token punctuation">(</span>kobold<span class="token punctuation">.</span>worldinfo<span class="token punctuation">.</span>folders<span class="token punctuation">)</span><span class="token punctuation">:</span>
|
||||
<pre class=" language-lua"><code class="prism language-lua"><span class="token keyword">for</span> index<span class="token punctuation">,</span> folder <span class="token keyword">in</span> <span class="token function">ipairs</span><span class="token punctuation">(</span>kobold<span class="token punctuation">.</span>worldinfo<span class="token punctuation">.</span>folders<span class="token punctuation">)</span> <span class="token keyword">do</span>
|
||||
<span class="token function">print</span><span class="token punctuation">(</span>index<span class="token punctuation">,</span> folder<span class="token punctuation">.</span>name<span class="token punctuation">)</span>
|
||||
<span class="token keyword">end</span>
|
||||
</code></pre>
|
||||
<pre class=" language-lua"><code class="prism language-lua"><span class="token keyword">for</span> index <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token operator">#</span>kobold<span class="token punctuation">.</span>worldinfo<span class="token punctuation">.</span>folders <span class="token keyword">do</span><span class="token punctuation">:</span>
|
||||
<pre class=" language-lua"><code class="prism language-lua"><span class="token keyword">for</span> index <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token operator">#</span>kobold<span class="token punctuation">.</span>worldinfo<span class="token punctuation">.</span>folders <span class="token keyword">do</span>
|
||||
<span class="token function">print</span><span class="token punctuation">(</span>index<span class="token punctuation">,</span> kobold<span class="token punctuation">.</span>worldinfo<span class="token punctuation">.</span>folders<span class="token punctuation">[</span>index<span class="token punctuation">]</span><span class="token punctuation">.</span>name<span class="token punctuation">)</span>
|
||||
<span class="token keyword">end</span>
|
||||
</code></pre>
|
||||
|
|
|
@ -503,13 +503,13 @@ local entry = kobold.worldinfo[5] -- Retrieves fifth entry from top as a Kobold
|
|||
You can use `ipairs` or a numeric loop to iterate from top to bottom:
|
||||
|
||||
```lua
|
||||
for index, entry in ipairs(kobold.worldinfo):
|
||||
for index, entry in ipairs(kobold.worldinfo) do
|
||||
print(index, entry.content)
|
||||
end
|
||||
```
|
||||
|
||||
```lua
|
||||
for index = 1, #kobold.worldinfo do:
|
||||
for index = 1, #kobold.worldinfo do
|
||||
print(index, kobold.worldinfo[index].content)
|
||||
end
|
||||
```
|
||||
|
@ -587,13 +587,13 @@ local folder = kobold.worldinfo.folders[5] -- Retrieves fifth folder from top a
|
|||
```
|
||||
|
||||
```lua
|
||||
for index, folder in ipairs(kobold.worldinfo.folders):
|
||||
for index, folder in ipairs(kobold.worldinfo.folders) do
|
||||
print(index, folder.name)
|
||||
end
|
||||
```
|
||||
|
||||
```lua
|
||||
for index = 1, #kobold.worldinfo.folders do:
|
||||
for index = 1, #kobold.worldinfo.folders do
|
||||
print(index, kobold.worldinfo.folders[index].name)
|
||||
end
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue