-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathask-deep-seek-by-ollama.py
47 lines (43 loc) · 1.08 KB
/
ask-deep-seek-by-ollama.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import requests
local_ollama_api_url = 'http://localhost:11434/api/chat'
headers = {
'Content-Type': 'application/json',
}
json_data = {
'messages': [
{
'content': 'You are a helpful assistant',
'role': 'system',
},
{
'content': '9.11 and 9.8, which is greater?',
'role': 'user',
},
],
# using deepseek-r1:7b on local ollama server
# ref https://ollama.com/library/deepseek-r1:7b
'model': 'deepseek-r1:latest',
'frequency_penalty': 0,
'max_tokens': 2048,
'presence_penalty': 0,
'response_format': {
'type': 'text',
},
'stop': None,
'stream': False,
'stream_options': None,
'temperature': 1,
'top_p': 1,
'tools': None,
'tool_choice': 'none',
'logprobs': False,
'top_logprobs': None,
}
response = requests.post(local_ollama_api_url, headers=headers, json=json_data)
json = response.json()
'''
<think>
think 标签之间的内容代表推理内容,注意该部分内容有可能为空。
</think>
'''
print(json['message']['content'])