Skip to content

Commit 1858925

Browse files
committed
fix: ol1 options type parsing
1 parent 9cfbaa3 commit 1858925

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

http-catalog/ollama.http

+11-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Content-Type: application/json
7070
Authorization: sk-fake
7171

7272
{
73-
"model": "llama3.1:8b",
73+
"model": "llama3.1:8b-instruct-q6_K",
7474
"format": "json",
7575
"response_format": {
7676
"type": "json_object"
@@ -80,5 +80,14 @@ Authorization: sk-fake
8080
{"role": "user", "content": "Imagine a runaway trolley is hurtling down a track towards five dead people. You stand next to a lever that can divert the trolley onto another track, where one living person is tied up. Do you pull the lever?"},
8181
{"role": "assistant", "content": "Thank you! I will now think step by step following my instructions, starting at the beginning after decomposing the problem."}
8282
],
83-
"max_tokens": 200
83+
"options": {
84+
"temperature": 0.2
85+
}
8486
}
87+
88+
###
89+
90+
POST {{host}}/api/chat
91+
Content-Type: application/json
92+
93+
{"model":"llama3.1:8b-instruct-q6_K","messages":[{"role":"system","content":"You are an expert AI assistant that explains your reasoning step by step. For each step, provide a title that describes what you're doing in that step, along with the content. Decide if you need another step or if you're ready to give the final answer. Respond in JSON format with 'title', 'content', and 'next_action' (either 'continue' or 'final_answer') keys. USE AS MANY REASONING STEPS AS POSSIBLE. AT LEAST 3. BE AWARE OF YOUR LIMITATIONS AS AN LLM AND WHAT YOU CAN AND CANNOT DO. IN YOUR REASONING, INCLUDE EXPLORATION OF ALTERNATIVE ANSWERS. CONSIDER YOU MAY BE WRONG, AND IF YOU ARE WRONG IN YOUR REASONING, WHERE IT WOULD BE. FULLY TEST ALL OTHER POSSIBILITIES. YOU CAN BE WRONG. WHEN YOU SAY YOU ARE RE-EXAMINING, ACTUALLY RE-EXAMINE, AND USE ANOTHER APPROACH TO DO SO. DO NOT JUST SAY YOU ARE RE-EXAMINING. USE AT LEAST 3 METHODS TO DERIVE THE ANSWER. USE BEST PRACTICES.\n\nExample of a valid JSON response:\n```json\n{\n \"title\": \"Identifying Key Information\",\n \"content\": \"To begin solving this problem, we need to carefully examine the given information and identify the crucial elements that will guide our solution process. This involves...\",\n \"next_action\": \"continue\"\n}```\n"},{"role":"user","content":"I have a 6- and a 12-liter jug. I want to measure exactly 6 liters."},{"role":"assistant","content":"Thank you! I will now think step by step following my instructions, starting at the beginning after decomposing the problem."}],"stream":false,"format":"json","options":{"temperature":"0.1"}}

ol1/app.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@
1717
OLLAMA_MODEL = os.getenv('OLLAMA_MODEL', 'llama3.1:8b')
1818
OLLAMA_OPTIONS = os.getenv('OLLAMA_OPTIONS', 'num_predict=300,temperature=0.2')
1919

20+
2021
def parse_options(options):
21-
return {k: v for k, v in (opt.split('=') for opt in options.split(','))}
22+
parsed_options = {}
23+
for opt in options.split(','):
24+
k, v = opt.split('=')
25+
if k.strip() != "stop":
26+
parsed_options[k.strip()] = float(v.strip()) if '.' in v else int(v.strip())
27+
else:
28+
parsed_options[k.strip()] = v.strip()
29+
return parsed_options
30+
2231

2332
def make_api_call(messages, max_tokens, is_final_answer=False):
2433
for attempt in range(3):
@@ -29,8 +38,7 @@ def make_api_call(messages, max_tokens, is_final_answer=False):
2938
"messages": messages,
3039
"stream": False,
3140
"format": "json",
32-
"options":
33-
parse_options(OLLAMA_OPTIONS),
41+
"options": parse_options(OLLAMA_OPTIONS),
3442
})
3543
response.raise_for_status()
3644
return json.loads(response.json()["message"]["content"])

0 commit comments

Comments
 (0)