Skip to content

Commit 268a901

Browse files
committed
modified the payload to accommadate current date
1 parent d8ba9da commit 268a901

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

LLM/deploy-llama3.1.md

+13-8
Original file line numberDiff line numberDiff line change
@@ -213,22 +213,26 @@ This format has to be exactly reproduced for effective use.
213213
import requests
214214
import ads
215215
from string import Template
216+
from datetime import datetime
216217

217218
ads.set_auth("resource_principal")
219+
endpoint = f"https://modeldeployment.us-ashburn-1.oci.customer-oci.com/{deployment.model_deployment_id}/predict"
218220

219-
prompt_template= Template("""<|begin_of_text|><|start_header_id|>system<|end_header_id|>
221+
current_date = datetime.now().strftime("%d %B %Y")
222+
223+
prompt_template= Templatef(f"""<|begin_of_text|><|start_header_id|>system<|end_header_id|>
220224
221225
Cutting Knowledge Date: December 2023
222-
Today Date: 24 Jul 2024
226+
Today Date: {current_date}
223227
224228
You are a helpful assistant<|eot_id|><|start_header_id|>user<|end_header_id|>
225229
226230
$prompt<|eot_id|><|start_header_id|>assistant<|end_header_id|>""")
227231

228-
prompt = t.substitute(prompt= "What amateur radio bands are best to use when there are solar flares?")
232+
prompt = prompt_template.substitute(prompt= "What amateur radio bands are best to use when there are solar flares?")
229233

230234
requests.post(
231-
"https://modeldeployment.us-ashburn-1.oci.customer-oci.com/{deployment.model_deployment_id}/predict",
235+
endpoint,
232236
json={
233237
"model": "llama3.1",
234238
"prompt": prompt,
@@ -239,7 +243,6 @@ requests.post(
239243
auth=ads.common.auth.default_signer()["signer"],
240244
headers={},
241245
).json()
242-
243246
```
244247
#### Output:
245248

@@ -290,19 +293,21 @@ Keep in mind that the impact of solar flares on amateur radio communications can
290293
import ads
291294
from langchain_community.llms import OCIModelDeploymentVLLM
292295
from string import Template
296+
from datetime import datetime
293297

294298
ads.set_auth("resource_principal")
299+
current_date = datetime.now().strftime("%d %B %Y")
295300

296301
llm = OCIModelDeploymentVLLM(
297-
endpoint="https://modeldeployment.us-ashburn-1.oci.customer-oci.com/{deployment.model_deployment_id}/predict",
302+
endpoint=f"https://modeldeployment.us-ashburn-1.oci.customer-oci.com/{deployment.model_deployment_id}/predict",
298303
model="llama3.1",
299304
)
300305

301306
llm.invoke(
302-
input=Template("""<|begin_of_text|><|start_header_id|>system<|end_header_id|>
307+
input=Template(f"""<|begin_of_text|><|start_header_id|>system<|end_header_id|>
303308

304309
Cutting Knowledge Date: December 2023
305-
Today Date: 24 Jul 2024
310+
Today Date:{current_date}
306311

307312
You are a helpful assistant<|eot_id|><|start_header_id|>user<|end_header_id|>
308313

LLM/llama3.1-8B-deployment-vLLM-container.md

+15-8
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ infrastructure = (
185185

186186
```python
187187
env_var = {
188-
'MODEL_DEPLOY_PREDICT_ENDPOINT': '/v1/chat/completions',
188+
'MODEL_DEPLOY_PREDICT_ENDPOINT': '/v1/completions',
189189
'MODEL_DEPLOY_ENABLE_STREAMING': 'true',
190190
}
191191

@@ -243,22 +243,26 @@ This format has to be exactly reproduced for effective use. More details about p
243243
import requests
244244
import ads
245245
from string import Template
246+
from datetime import datetime
246247

247248
ads.set_auth("resource_principal")
249+
endpoint = f"https://modeldeployment.us-ashburn-1.oci.customer-oci.com/{deployment.model_deployment_id}/predict"
248250

249-
prompt_template= Template("""<|begin_of_text|><|start_header_id|>system<|end_header_id|>
251+
current_date = datetime.now().strftime("%d %B %Y")
252+
253+
prompt_template= Templatef(f"""<|begin_of_text|><|start_header_id|>system<|end_header_id|>
250254
251255
Cutting Knowledge Date: December 2023
252-
Today Date: 29 Jul 2024
256+
Today Date: {current_date}
253257
254258
You are a helpful assistant<|eot_id|><|start_header_id|>user<|end_header_id|>
255259
256260
$prompt<|eot_id|><|start_header_id|>assistant<|end_header_id|>""")
257261

258-
prompt = t.substitute(prompt= "What amateur radio bands are best to use when there are solar flares?")
262+
prompt = prompt_template.substitute(prompt= "What amateur radio bands are best to use when there are solar flares?")
259263

260264
requests.post(
261-
"https://modeldeployment.us-ashburn-1.oci.customer-oci.com/{deployment.model_deployment_id}/predict",
265+
endpoint,
262266
json={
263267
"model": "llama3.1",
264268
"prompt": prompt,
@@ -334,19 +338,22 @@ Remember, it's always better to err on the side of caution and choose lower freq
334338
import ads
335339
from langchain_community.llms import OCIModelDeploymentVLLM
336340
from string import Template
341+
from datetime import datetime
342+
337343

338344
ads.set_auth("resource_principal")
345+
current_date = datetime.now().strftime("%d %B %Y")
339346

340347
llm = OCIModelDeploymentVLLM(
341-
endpoint="https://modeldeployment.us-ashburn-1.oci.customer-oci.com/{deployment.model_deployment_id}/predict",
348+
endpoint=f"https://modeldeployment.us-ashburn-1.oci.customer-oci.com/{deployment.model_deployment_id}/predict",
342349
model="llama3.1",
343350
)
344351

345352
llm.invoke(
346-
input=Template("""<|begin_of_text|><|start_header_id|>system<|end_header_id|>
353+
input=Template(f"""<|begin_of_text|><|start_header_id|>system<|end_header_id|>
347354

348355
Cutting Knowledge Date: December 2023
349-
Today Date: 29 Jul 2024
356+
Today Date: {current_date}
350357

351358
You are a helpful assistant<|eot_id|><|start_header_id|>user<|end_header_id|>
352359

0 commit comments

Comments
 (0)