Skip to content

Commit ba7090e

Browse files
committed
Use OpenAI models
1 parent d3df79c commit ba7090e

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

.github/scripts/gen-imgs.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -96,28 +96,21 @@ def get_painting_feature(name, description):
9696
prompt += f" which is described as “{description}”"
9797

9898
prompt += f""".
99-
From that name and description extract some language that can be featured in the image.
100-
Eg. if the description is “foo is a bridge to bar” then output BRIDGE.
101-
Keep it physical. If the description is "foo is a dynamic runtime bridge to bar” then output BRIDGE, not DYNAMIC RUNTIME BRIDGE.
102-
Remember I need to paint this!
103-
If the name is a play on words then find the play on words. Eg “deno” is a play on dino ie. a dinosaur.
104-
If you know the logo for a project and the logo is a good theme, then say that. Eg. “deno”’s logo is a dinosaur.
105-
If the name contains a word I can paint, use it! Eg. from `libcap` you can say `cap`.
106-
Don’t be generic. I have ten million open source packages. eg. don’t pick `lib` or `code` or `syntax`, but eg. database is ok.
107-
I need the output as JSON "{{theme: ""}}.
108-
I am feeding the output to a script, so if you don’t output json in the above form my script will break.
99+
From that name and description extract a word or two that can be the *feature* of the painting.
100+
Remember it needs to be painted! So stick to objects, animals, plants, or other things that can be painted.
109101
Thank you sir.
110102
"""
111103
prompt = re.sub(r'\s+', ' ', prompt).strip()
112104

113105
print(prompt)
114106

115-
proc = subprocess.run(['pkgx', 'ollama', 'run', 'deepseek-r1', f"Instruct: {prompt}\nOutput: "], capture_output=True, text=True)
107+
proc = subprocess.run(['pkgx', 'llm', 'prompt', f"Instruct: {prompt}\nOutput: "], capture_output=True, text=True)
116108
result = proc.stdout
117109

118110
console.print(result, style="yellow")
119111

120-
result = result[result.index("</think>") + len("</think>"):].strip()
112+
if "</think>" in result:
113+
result = result[result.index("</think>") + len("</think>"):].strip()
121114

122115
output = {}
123116

@@ -151,12 +144,13 @@ def get_painting_feature(name, description):
151144

152145
prompt = f"Instruct: {prompt}\nOutput: "
153146

154-
proc = subprocess.run(['pkgx', 'ollama', 'run', 'deepseek-r1', prompt], capture_output=True, text=True)
147+
proc = subprocess.run(['pkgx', 'llm', 'prompt', prompt], capture_output=True, text=True)
155148
result = proc.stdout
156149

157150
console.print(result, style="blue")
158151

159-
result = result[result.index("</think>") + len("</think>"):].strip()
152+
if "</think>" in result:
153+
result = result[result.index("</think>") + len("</think>"):].strip()
160154

161155
match = re.search(r'{\s*"?colors"?:(.*?)}', result, re.DOTALL)
162156
if match:
@@ -167,7 +161,8 @@ def get_painting_feature(name, description):
167161

168162
prompt = f"""
169163
I have a theme: {output['theme']} and colors: {output['colors']}.
170-
Now pick from following list of imagery options to best fit that theme and color selection:
164+
Now I need surrounding imagery. Here’s a list of possible imagery *collections*.
165+
But these are just examples, I would prefer you come up with your own based on the theme and colors.
171166
172167
```markdown
173168
- oceans, waves, tides, coral reefs
@@ -182,22 +177,22 @@ def get_painting_feature(name, description):
182177
- twilight, dawn, dusk, moonlight
183178
```
184179
185-
If none fit and you are inspired please provide your own imagery or adapt the options.
180+
Don’t go overboard, I only want three or four items.
186181
I need the output as JSON "{{imagery: "FOO, BAR, BAZ, ETC"}}.
187-
Output the complete list item of imagery items, not just selected items.
188182
I am feeding the output to a script, so if you don’t output json in the above form my script will break.
189183
Thank you sir.
190184
"""
191185
print(prompt)
192186

193187
prompt = f"Instruct: {prompt}\nOutput: "
194188

195-
proc = subprocess.run(['pkgx', 'ollama', 'run', 'deepseek-r1', prompt], capture_output=True, text=True)
189+
proc = subprocess.run(['pkgx', 'llm', 'prompt', prompt], capture_output=True, text=True)
196190
result = proc.stdout
197191

198192
console.print(result, style="green")
199193

200-
result = result[result.index("</think>") + len("</think>"):].strip()
194+
if "</think>" in result:
195+
result = result[result.index("</think>") + len("</think>"):].strip()
201196

202197
match = re.search(r'{\s*"?imagery"?:(.*?)}', result, re.DOTALL)
203198
if match:

0 commit comments

Comments
 (0)