Skip to content

Commit ae5951f

Browse files
committed
Adapt parameters for GPT-4 Turbo
1 parent 484c067 commit ae5951f

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

hacker_news/llm/coze.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
'Authorization': f'Bearer {config.coze_api_key}',
1414
}
1515

16+
1617
# example response (SSEs):
1718
# b'event:message
1819
# data:{
@@ -56,18 +57,23 @@ def summarize_by_coze(content: str) -> str:
5657
# Seems coze adds more context in prompt, and even answer is counted
5758
content = sanitize_for_openai(content, overhead=1000)
5859

60+
# For model: GPT-4 Turbo (128K), temperature: 0.5 - GPT-4 Turbo is an excellent rule follower.
5961
prompt = (f'Use third person mood to summarize the main points of the following article delimited by triple backticks in 2 concise sentences. '
60-
f'Ensure the summary does not exceed 100 characters.\n'
62+
f'Ensure the summary does not exceed 300 characters.\n'
6163
f'```{content}.```')
6264

6365
try:
64-
resp = session.post(config.coze_api_endpoint, headers=coze_headers, stream=True, json={
65-
'conversation_id': f'{random.randint(100, 9999)}',
66-
'bot_id': config.coze_bot_id,
67-
'user': 'single_user',
68-
'query': prompt,
69-
'stream': False,
70-
})
66+
resp = session.post(url=config.coze_api_endpoint,
67+
headers=coze_headers,
68+
stream=True,
69+
timeout=30,
70+
json={
71+
'conversation_id': f'{random.randint(100, 9999)}',
72+
'bot_id': config.coze_bot_id,
73+
'user': 'single_user',
74+
'query': prompt,
75+
'stream': False,
76+
})
7177
resp.raise_for_status()
7278

7379
for line in resp.iter_lines():

0 commit comments

Comments
 (0)