Dede16 commited on
Commit
1c85ea5
·
1 Parent(s): 4aa2a66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -106,12 +106,15 @@ def clean_scrap(artikel,link,models,api_key,azure_api_base):
106
  ]
107
  if models == 'openai':
108
  result = get_openai_response(messages,api_key)
109
- new_artikel.append(result)
110
  time.sleep(2)
 
 
 
111
  else:
112
  result = get_azure_response(messages,api_key,azure_api_base)
113
- new_artikel.append(result)
114
  time.sleep(2)
 
 
115
  else:
116
  for art in artikel:
117
  messages=[
@@ -120,12 +123,14 @@ def clean_scrap(artikel,link,models,api_key,azure_api_base):
120
  ]
121
  if models == 'openai':
122
  result = get_openai_response(messages,api_key)
123
- new_artikel.append(result)
124
  time.sleep(2)
 
 
 
125
  else:
126
  result = get_azure_response(messages,api_key,azure_api_base)
127
- new_artikel.append(result)
128
  time.sleep(2)
 
129
 
130
  new_art = [' '.join(new_artikel)]
131
  for art in new_art:
@@ -148,7 +153,6 @@ def clean_scrap(artikel,link,models,api_key,azure_api_base):
148
  {"role": "system", "content": "You are a professional translator and rewriter"},
149
  {"role": "user", "content": "Please translate and rewrite this sentence into Indonesian language with the following requirements: \n1. The sentence should be concise, compact, and clear. \n2. The sentence length should not exceed 50 characters. \n3. The sentences should be professional, similar to typical article titles and sound more natural for a human to read.:" +title+"\nDo not write any explanation and any pleasantries. Please use the following complete format to display the output: Judul:{hasil rewrite}"}
150
  ]
151
- judul = response['choices'][0]['message']['content']
152
  if models == 'openai':
153
  judul = get_openai_response(messages,api_key)
154
  else:
 
106
  ]
107
  if models == 'openai':
108
  result = get_openai_response(messages,api_key)
 
109
  time.sleep(2)
110
+ print(result)
111
+ new_artikel.append(result)
112
+
113
  else:
114
  result = get_azure_response(messages,api_key,azure_api_base)
 
115
  time.sleep(2)
116
+ new_artikel.append(result)
117
+
118
  else:
119
  for art in artikel:
120
  messages=[
 
123
  ]
124
  if models == 'openai':
125
  result = get_openai_response(messages,api_key)
 
126
  time.sleep(2)
127
+ print(result)
128
+ new_artikel.append(result)
129
+
130
  else:
131
  result = get_azure_response(messages,api_key,azure_api_base)
 
132
  time.sleep(2)
133
+ new_artikel.append(result)
134
 
135
  new_art = [' '.join(new_artikel)]
136
  for art in new_art:
 
153
  {"role": "system", "content": "You are a professional translator and rewriter"},
154
  {"role": "user", "content": "Please translate and rewrite this sentence into Indonesian language with the following requirements: \n1. The sentence should be concise, compact, and clear. \n2. The sentence length should not exceed 50 characters. \n3. The sentences should be professional, similar to typical article titles and sound more natural for a human to read.:" +title+"\nDo not write any explanation and any pleasantries. Please use the following complete format to display the output: Judul:{hasil rewrite}"}
155
  ]
 
156
  if models == 'openai':
157
  judul = get_openai_response(messages,api_key)
158
  else: