File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 1
1
from ollama import generate
2
2
3
- prefix = '''def remove_non_ascii(s: str) -> str:
3
+ prompt = '''def remove_non_ascii(s: str) -> str:
4
4
""" '''
5
5
6
6
suffix = """
7
7
return result
8
8
"""
9
9
10
-
11
10
response = generate (
12
11
model = 'codellama:7b-code' ,
13
- prompt = f'<PRE> { prefix } <SUF>{ suffix } <MID>' ,
12
+ prompt = prompt ,
13
+ suffix = suffix ,
14
14
options = {
15
15
'num_predict' : 128 ,
16
16
'temperature' : 0 ,
Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ def generate(
102
102
self ,
103
103
model : str = '' ,
104
104
prompt : str = '' ,
105
+ suffix : str = '' ,
105
106
system : str = '' ,
106
107
template : str = '' ,
107
108
context : Optional [Sequence [int ]] = None ,
@@ -118,6 +119,7 @@ def generate(
118
119
self ,
119
120
model : str = '' ,
120
121
prompt : str = '' ,
122
+ suffix : str = '' ,
121
123
system : str = '' ,
122
124
template : str = '' ,
123
125
context : Optional [Sequence [int ]] = None ,
@@ -133,6 +135,7 @@ def generate(
133
135
self ,
134
136
model : str = '' ,
135
137
prompt : str = '' ,
138
+ suffix : str = '' ,
136
139
system : str = '' ,
137
140
template : str = '' ,
138
141
context : Optional [Sequence [int ]] = None ,
@@ -162,6 +165,7 @@ def generate(
162
165
json = {
163
166
'model' : model ,
164
167
'prompt' : prompt ,
168
+ 'suffix' : suffix ,
165
169
'system' : system ,
166
170
'template' : template ,
167
171
'context' : context or [],
@@ -518,6 +522,7 @@ async def generate(
518
522
self ,
519
523
model : str = '' ,
520
524
prompt : str = '' ,
525
+ suffix : str = '' ,
521
526
system : str = '' ,
522
527
template : str = '' ,
523
528
context : Optional [Sequence [int ]] = None ,
@@ -534,6 +539,7 @@ async def generate(
534
539
self ,
535
540
model : str = '' ,
536
541
prompt : str = '' ,
542
+ suffix : str = '' ,
537
543
system : str = '' ,
538
544
template : str = '' ,
539
545
context : Optional [Sequence [int ]] = None ,
@@ -549,6 +555,7 @@ async def generate(
549
555
self ,
550
556
model : str = '' ,
551
557
prompt : str = '' ,
558
+ suffix : str = '' ,
552
559
system : str = '' ,
553
560
template : str = '' ,
554
561
context : Optional [Sequence [int ]] = None ,
@@ -577,6 +584,7 @@ async def generate(
577
584
json = {
578
585
'model' : model ,
579
586
'prompt' : prompt ,
587
+ 'suffix' : suffix ,
580
588
'system' : system ,
581
589
'template' : template ,
582
590
'context' : context or [],
Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ def test_client_generate(httpserver: HTTPServer):
137
137
json = {
138
138
'model' : 'dummy' ,
139
139
'prompt' : 'Why is the sky blue?' ,
140
+ 'suffix' : '' ,
140
141
'system' : '' ,
141
142
'template' : '' ,
142
143
'context' : [],
@@ -182,6 +183,7 @@ def generate():
182
183
json = {
183
184
'model' : 'dummy' ,
184
185
'prompt' : 'Why is the sky blue?' ,
186
+ 'suffix' : '' ,
185
187
'system' : '' ,
186
188
'template' : '' ,
187
189
'context' : [],
@@ -210,6 +212,7 @@ def test_client_generate_images(httpserver: HTTPServer):
210
212
json = {
211
213
'model' : 'dummy' ,
212
214
'prompt' : 'Why is the sky blue?' ,
215
+ 'suffix' : '' ,
213
216
'system' : '' ,
214
217
'template' : '' ,
215
218
'context' : [],
@@ -619,6 +622,7 @@ async def test_async_client_generate(httpserver: HTTPServer):
619
622
json = {
620
623
'model' : 'dummy' ,
621
624
'prompt' : 'Why is the sky blue?' ,
625
+ 'suffix' : '' ,
622
626
'system' : '' ,
623
627
'template' : '' ,
624
628
'context' : [],
@@ -659,6 +663,7 @@ def generate():
659
663
json = {
660
664
'model' : 'dummy' ,
661
665
'prompt' : 'Why is the sky blue?' ,
666
+ 'suffix' : '' ,
662
667
'system' : '' ,
663
668
'template' : '' ,
664
669
'context' : [],
@@ -688,6 +693,7 @@ async def test_async_client_generate_images(httpserver: HTTPServer):
688
693
json = {
689
694
'model' : 'dummy' ,
690
695
'prompt' : 'Why is the sky blue?' ,
696
+ 'suffix' : '' ,
691
697
'system' : '' ,
692
698
'template' : '' ,
693
699
'context' : [],
You can’t perform that action at this time.
0 commit comments