Skip to content

Commit

Permalink
update langchain rag (#2357)
Browse files Browse the repository at this point in the history
1. to align with this PR:

langchain-ai/langchain@1c31234#diff-072c45917082c5132a4631ee3fa519e3732985c436c1ca60fce0c4e03d21d2ba

2. support text completion for llama_index
  • Loading branch information
openvino-dev-samples authored Sep 3, 2024
1 parent 2ca0214 commit 6225f99
Show file tree
Hide file tree
Showing 3 changed files with 413 additions and 56 deletions.
6 changes: 3 additions & 3 deletions notebooks/llm-agent-react/llm-agent-rag-llamaindex.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@
" return f\"<|system|><|end|><|user|>{completion}<|end|><|assistant|>\\n\"\n",
"\n",
"\n",
"def llama_completion_to_prompt(completion):\n",
" return f\"<|begin_of_text|><|start_header_id|>system<|end_header_id|><|eot_id|><|start_header_id|>user<|end_header_id|>{completion}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\\n\"\n",
"def llama3_completion_to_prompt(completion):\n",
" return f\"<|begin_of_text|><|start_header_id|>system<|end_header_id|>\\n\\n<|eot_id|><|start_header_id|>user<|end_header_id|>\\n\\n{completion}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\\n\\n\"\n",
"\n",
"\n",
"llm = OpenVINOLLM(\n",
Expand All @@ -319,7 +319,7 @@
" max_new_tokens=1000,\n",
" model_kwargs={\"ov_config\": ov_config},\n",
" generate_kwargs={\"do_sample\": False, \"temperature\": None, \"top_p\": None},\n",
" completion_to_prompt=phi_completion_to_prompt if llm_model_path == \"Phi-3-mini-4k-instruct-int4-ov\" else llama_completion_to_prompt,\n",
" completion_to_prompt=phi_completion_to_prompt if llm_model_path == \"Phi-3-mini-4k-instruct-int4-ov\" else llama3_completion_to_prompt,\n",
" device_map=llm_device.value,\n",
")"
]
Expand Down
Loading

0 comments on commit 6225f99

Please sign in to comment.