@@ -185,7 +185,7 @@ infrastructure = (
185
185
186
186
``` python
187
187
env_var = {
188
- ' MODEL_DEPLOY_PREDICT_ENDPOINT' : ' /v1/chat/ completions' ,
188
+ ' MODEL_DEPLOY_PREDICT_ENDPOINT' : ' /v1/completions' ,
189
189
' MODEL_DEPLOY_ENABLE_STREAMING' : ' true' ,
190
190
}
191
191
@@ -243,22 +243,26 @@ This format has to be exactly reproduced for effective use. More details about p
243
243
import requests
244
244
import ads
245
245
from string import Template
246
+ from datetime import datetime
246
247
247
248
ads.set_auth(" resource_principal" )
249
+ endpoint = f " https://modeldeployment.us-ashburn-1.oci.customer-oci.com/ { deployment.model_deployment_id} /predict "
248
250
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|>
250
254
251
255
Cutting Knowledge Date: December 2023
252
- Today Date: 29 Jul 2024
256
+ Today Date: { current_date }
253
257
254
258
You are a helpful assistant<|eot_id|><|start_header_id|>user<|end_header_id|>
255
259
256
260
$prompt<|eot_id|><|start_header_id|>assistant<|end_header_id|> """ )
257
261
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?" )
259
263
260
264
requests.post(
261
- " https://modeldeployment.us-ashburn-1.oci.customer-oci.com/ {deployment.model_deployment_id} /predict " ,
265
+ endpoint ,
262
266
json = {
263
267
" model" : " llama3.1" ,
264
268
" prompt" : prompt,
@@ -334,19 +338,22 @@ Remember, it's always better to err on the side of caution and choose lower freq
334
338
import ads
335
339
from langchain_community.llms import OCIModelDeploymentVLLM
336
340
from string import Template
341
+ from datetime import datetime
342
+
337
343
338
344
ads.set_auth("resource_principal")
345
+ current_date = datetime.now().strftime("%d %B %Y")
339
346
340
347
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",
342
349
model="llama3.1",
343
350
)
344
351
345
352
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|>
347
354
348
355
Cutting Knowledge Date: December 2023
349
- Today Date: 29 Jul 2024
356
+ Today Date: {current_date}
350
357
351
358
You are a helpful assistant<|eot_id|><|start_header_id|>user<|end_header_id|>
352
359
0 commit comments