···11+# Using llama model yo
22+FROM llama3.2
33+MESSAGE user hi
+26
fixtures/a.modelfile
···11+# Modelfile generated by "ollama show"
22+# To build a new Modelfile based on this one, replace the FROM line with:
33+FROM llama3.2:latest
44+# FROM /Users/pdevine/.ollama/models/blobs/sha256-00e1317cbf74d901080d7100f57580ba8dd8de57203072dc6f668324ba545f29
55+TEMPLATE """{{ if .System }}<|start_header_id|>system<|end_header_id|>
66+77+{{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|>
88+99+{{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|>
1010+1111+{{ .Response }}<|eot_id|>"""
1212+1313+PARAMETER stop "<|start_header_id|>"
1414+PARAMETER stop "<|end_header_id|>"
1515+PARAMETER stop "<|eot_id|>"
1616+PARAMETER stop "<|reserved_special_token"
1717+1818+MESSAGE user """Is Toronto in Canada?
1919+or Is cologne in france"""
2020+MESSAGE assistant yes
2121+MESSAGE user Is Sacramento in Canada?
2222+MESSAGE assistant no
2323+MESSAGE user Is Ontario in Canada?
2424+MESSAGE assistant yes
2525+# FROM llama3.2
2626+
+14
fixtures/llama_bad.Modelfile
···11+# Modelfile generated by "ollama show"
22+# To build a new Modelfile based on this, replace FROM with:
33+# FROM x/llama3.2-vision:latest
44+55+FROM /mnt/space/ollama/models/blobs/sha256-652e85aa1e14c9087a4ccc3ab516fb794cbcf152f8b4b8d3c0b828da4ada62d9
66+FROM /mnt/space/ollama/models/blobs/sha256-622429e8d31810962dd984bc98559e706db2fb1d40e99cb073beb7148d909d73
77+TEMPLATE "{{- range $i, $_ := .Messages }}<|start_header_id|>{{ .Role }}<|end_header_id|>
88+99+{{ .Content }}<|eot_id|>
1010+{{- end }}<|start_header_id|>assistant<|end_header_id|>
1111+1212+"
1313+PARAMETER temperature 0
1414+PARAMETER top_p 0.9
+223
fixtures/mistral.modelfile
···11+# Modelfile generated by "ollama show"
22+# To build a new Modelfile based on this, replace FROM with:
33+# FROM mistral-nemo:latest
44+55+FROM /mnt/space/ollama/models/blobs/sha256-b559938ab7a0392fc9ea9675b82280f2a15669ec3e0e0fc491c9cb0a7681cf94
66+TEMPLATE """{{- range $i, $_ := .Messages }}
77+{{- if eq .Role "user" }}
88+{{- if and $.Tools (le (len (slice $.Messages $i)) 2) }}[AVAILABLE_TOOLS] {{ $.Tools }}[/AVAILABLE_TOOLS]
99+{{- end }}[INST] {{ if and $.System (eq (len (slice $.Messages $i)) 1) }}{{ $.System }}
1010+1111+{{ end }}{{ .Content }}[/INST]
1212+{{- else if eq .Role "assistant" }}
1313+{{- if .Content }} {{ .Content }}{{ if not (eq (len (slice $.Messages $i)) 1) }}</s>{{ end }}
1414+{{- else if .ToolCalls }}[TOOL_CALLS] [
1515+{{- range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
1616+{{- end }}]</s>
1717+{{- end }}
1818+{{- else if eq .Role "tool" }}[TOOL_RESULTS] {"content": {{ .Content }}} [/TOOL_RESULTS]
1919+{{- end }}
2020+{{- end }}"""
2121+PARAMETER stop [INST]
2222+PARAMETER stop [/INST]
2323+LICENSE """ Apache License
2424+ Version 2.0, January 2004
2525+ http://www.apache.org/licenses/
2626+2727+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
2828+2929+ 1. Definitions.
3030+3131+ "License" shall mean the terms and conditions for use, reproduction,
3232+ and distribution as defined by Sections 1 through 9 of this document.
3333+3434+ "Licensor" shall mean the copyright owner or entity authorized by
3535+ the copyright owner that is granting the License.
3636+3737+ "Legal Entity" shall mean the union of the acting entity and all
3838+ other entities that control, are controlled by, or are under common
3939+ control with that entity. For the purposes of this definition,
4040+ "control" means (i) the power, direct or indirect, to cause the
4141+ direction or management of such entity, whether by contract or
4242+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
4343+ outstanding shares, or (iii) beneficial ownership of such entity.
4444+4545+ "You" (or "Your") shall mean an individual or Legal Entity
4646+ exercising permissions granted by this License.
4747+4848+ "Source" form shall mean the preferred form for making modifications,
4949+ including but not limited to software source code, documentation
5050+ source, and configuration files.
5151+5252+ "Object" form shall mean any form resulting from mechanical
5353+ transformation or translation of a Source form, including but
5454+ not limited to compiled object code, generated documentation,
5555+ and conversions to other media types.
5656+5757+ "Work" shall mean the work of authorship, whether in Source or
5858+ Object form, made available under the License, as indicated by a
5959+ copyright notice that is included in or attached to the work
6060+ (an example is provided in the Appendix below).
6161+6262+ "Derivative Works" shall mean any work, whether in Source or Object
6363+ form, that is based on (or derived from) the Work and for which the
6464+ editorial revisions, annotations, elaborations, or other modifications
6565+ represent, as a whole, an original work of authorship. For the purposes
6666+ of this License, Derivative Works shall not include works that remain
6767+ separable from, or merely link (or bind by name) to the interfaces of,
6868+ the Work and Derivative Works thereof.
6969+7070+ "Contribution" shall mean any work of authorship, including
7171+ the original version of the Work and any modifications or additions
7272+ to that Work or Derivative Works thereof, that is intentionally
7373+ submitted to Licensor for inclusion in the Work by the copyright owner
7474+ or by an individual or Legal Entity authorized to submit on behalf of
7575+ the copyright owner. For the purposes of this definition, "submitted"
7676+ means any form of electronic, verbal, or written communication sent
7777+ to the Licensor or its representatives, including but not limited to
7878+ communication on electronic mailing lists, source code control systems,
7979+ and issue tracking systems that are managed by, or on behalf of, the
8080+ Licensor for the purpose of discussing and improving the Work, but
8181+ excluding communication that is conspicuously marked or otherwise
8282+ designated in writing by the copyright owner as "Not a Contribution."
8383+8484+ "Contributor" shall mean Licensor and any individual or Legal Entity
8585+ on behalf of whom a Contribution has been received by Licensor and
8686+ subsequently incorporated within the Work.
8787+8888+ 2. Grant of Copyright License. Subject to the terms and conditions of
8989+ this License, each Contributor hereby grants to You a perpetual,
9090+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
9191+ copyright license to reproduce, prepare Derivative Works of,
9292+ publicly display, publicly perform, sublicense, and distribute the
9393+ Work and such Derivative Works in Source or Object form.
9494+9595+ 3. Grant of Patent License. Subject to the terms and conditions of
9696+ this License, each Contributor hereby grants to You a perpetual,
9797+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
9898+ (except as stated in this section) patent license to make, have made,
9999+ use, offer to sell, sell, import, and otherwise transfer the Work,
100100+ where such license applies only to those patent claims licensable
101101+ by such Contributor that are necessarily infringed by their
102102+ Contribution(s) alone or by combination of their Contribution(s)
103103+ with the Work to which such Contribution(s) was submitted. If You
104104+ institute patent litigation against any entity (including a
105105+ cross-claim or counterclaim in a lawsuit) alleging that the Work
106106+ or a Contribution incorporated within the Work constitutes direct
107107+ or contributory patent infringement, then any patent licenses
108108+ granted to You under this License for that Work shall terminate
109109+ as of the date such litigation is filed.
110110+111111+ 4. Redistribution. You may reproduce and distribute copies of the
112112+ Work or Derivative Works thereof in any medium, with or without
113113+ modifications, and in Source or Object form, provided that You
114114+ meet the following conditions:
115115+116116+ (a) You must give any other recipients of the Work or
117117+ Derivative Works a copy of this License; and
118118+119119+ (b) You must cause any modified files to carry prominent notices
120120+ stating that You changed the files; and
121121+122122+ (c) You must retain, in the Source form of any Derivative Works
123123+ that You distribute, all copyright, patent, trademark, and
124124+ attribution notices from the Source form of the Work,
125125+ excluding those notices that do not pertain to any part of
126126+ the Derivative Works; and
127127+128128+ (d) If the Work includes a "NOTICE" text file as part of its
129129+ distribution, then any Derivative Works that You distribute must
130130+ include a readable copy of the attribution notices contained
131131+ within such NOTICE file, excluding those notices that do not
132132+ pertain to any part of the Derivative Works, in at least one
133133+ of the following places: within a NOTICE text file distributed
134134+ as part of the Derivative Works; within the Source form or
135135+ documentation, if provided along with the Derivative Works; or,
136136+ within a display generated by the Derivative Works, if and
137137+ wherever such third-party notices normally appear. The contents
138138+ of the NOTICE file are for informational purposes only and
139139+ do not modify the License. You may add Your own attribution
140140+ notices within Derivative Works that You distribute, alongside
141141+ or as an addendum to the NOTICE text from the Work, provided
142142+ that such additional attribution notices cannot be construed
143143+ as modifying the License.
144144+145145+ You may add Your own copyright statement to Your modifications and
146146+ may provide additional or different license terms and conditions
147147+ for use, reproduction, or distribution of Your modifications, or
148148+ for any such Derivative Works as a whole, provided Your use,
149149+ reproduction, and distribution of the Work otherwise complies with
150150+ the conditions stated in this License.
151151+152152+ 5. Submission of Contributions. Unless You explicitly state otherwise,
153153+ any Contribution intentionally submitted for inclusion in the Work
154154+ by You to the Licensor shall be under the terms and conditions of
155155+ this License, without any additional terms or conditions.
156156+ Notwithstanding the above, nothing herein shall supersede or modify
157157+ the terms of any separate license agreement you may have executed
158158+ with Licensor regarding such Contributions.
159159+160160+ 6. Trademarks. This License does not grant permission to use the trade
161161+ names, trademarks, service marks, or product names of the Licensor,
162162+ except as required for reasonable and customary use in describing the
163163+ origin of the Work and reproducing the content of the NOTICE file.
164164+165165+ 7. Disclaimer of Warranty. Unless required by applicable law or
166166+ agreed to in writing, Licensor provides the Work (and each
167167+ Contributor provides its Contributions) on an "AS IS" BASIS,
168168+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
169169+ implied, including, without limitation, any warranties or conditions
170170+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
171171+ PARTICULAR PURPOSE. You are solely responsible for determining the
172172+ appropriateness of using or redistributing the Work and assume any
173173+ risks associated with Your exercise of permissions under this License.
174174+175175+ 8. Limitation of Liability. In no event and under no legal theory,
176176+ whether in tort (including negligence), contract, or otherwise,
177177+ unless required by applicable law (such as deliberate and grossly
178178+ negligent acts) or agreed to in writing, shall any Contributor be
179179+ liable to You for damages, including any direct, indirect, special,
180180+ incidental, or consequential damages of any character arising as a
181181+ result of this License or out of the use or inability to use the
182182+ Work (including but not limited to damages for loss of goodwill,
183183+ work stoppage, computer failure or malfunction, or any and all
184184+ other commercial damages or losses), even if such Contributor
185185+ has been advised of the possibility of such damages.
186186+187187+ 9. Accepting Warranty or Additional Liability. While redistributing
188188+ the Work or Derivative Works thereof, You may choose to offer,
189189+ and charge a fee for, acceptance of support, warranty, indemnity,
190190+ or other liability obligations and/or rights consistent with this
191191+ License. However, in accepting such obligations, You may act only
192192+ on Your own behalf and on Your sole responsibility, not on behalf
193193+ of any other Contributor, and only if You agree to indemnify,
194194+ defend, and hold each Contributor harmless for any liability
195195+ incurred by, or claims asserted against, such Contributor by reason
196196+ of your accepting any such warranty or additional liability.
197197+198198+ END OF TERMS AND CONDITIONS
199199+200200+ APPENDIX: How to apply the Apache License to your work.
201201+202202+ To apply the Apache License to your work, attach the following
203203+ boilerplate notice, with the fields enclosed by brackets "[]"
204204+ replaced with your own identifying information. (Don't include
205205+ the brackets!) The text should be enclosed in the appropriate
206206+ comment syntax for the file format. We also recommend that a
207207+ file or class name and description of purpose be included on the
208208+ same "printed page" as the copyright notice for easier
209209+ identification within third-party archives.
210210+211211+ Copyright [yyyy] [name of copyright owner]
212212+213213+ Licensed under the Apache License, Version 2.0 (the "License");
214214+ you may not use this file except in compliance with the License.
215215+ You may obtain a copy of the License at
216216+217217+ http://www.apache.org/licenses/LICENSE-2.0
218218+219219+ Unless required by applicable law or agreed to in writing, software
220220+ distributed under the License is distributed on an "AS IS" BASIS,
221221+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
222222+ See the License for the specific language governing permissions and
223223+ limitations under the License."""
+2-12
src/lib.rs
···11-pub fn add(left: u64, right: u64) -> u64 {
22- left + right
33-}
11+pub mod modelfile;
4253#[cfg(test)]
66-mod tests {
77- use super::*;
88-99- #[test]
1010- fn it_works() {
1111- let result = add(2, 2);
1212- assert_eq!(result, 4);
1313- }
1414-}
44+mod tests {}