From 6250c189ba9dd7265943d1c465f5956985c18965 Mon Sep 17 00:00:00 2001 From: Chester Curme Date: Wed, 24 Apr 2024 16:33:41 -0400 Subject: [PATCH 01/10] update --- docs/docs/integrations/callbacks/llmonitor.md | 2 +- docs/docs/integrations/llms/anyscale.ipynb | 2 +- docs/docs/integrations/llms/aphrodite.ipynb | 2 +- docs/docs/integrations/llms/baichuan.ipynb | 2 +- docs/docs/integrations/llms/baidu_qianfan_endpoint.ipynb | 4 ++-- docs/docs/integrations/llms/ctransformers.ipynb | 2 +- docs/docs/integrations/llms/ctranslate2.ipynb | 2 +- docs/docs/integrations/llms/google_vertex_ai_palm.ipynb | 8 ++++---- docs/docs/integrations/llms/koboldai.ipynb | 2 +- docs/docs/integrations/llms/replicate.ipynb | 6 +++--- docs/docs/integrations/llms/sparkllm.ipynb | 2 +- docs/docs/integrations/providers/flyte.mdx | 2 +- docs/docs/integrations/providers/konko.mdx | 2 +- docs/docs/use_cases/data_generation.ipynb | 2 +- 14 files changed, 20 insertions(+), 20 deletions(-) diff --git a/docs/docs/integrations/callbacks/llmonitor.md b/docs/docs/integrations/callbacks/llmonitor.md index a90e606e7bd68..d27a698c78eb7 100644 --- a/docs/docs/integrations/callbacks/llmonitor.md +++ b/docs/docs/integrations/callbacks/llmonitor.md @@ -107,7 +107,7 @@ User tracking allows you to identify your users, track their cost, conversations from langchain_community.callbacks.llmonitor_callback import LLMonitorCallbackHandler, identify with identify("user-123"): - llm("Tell me a joke") + llm.invoke("Tell me a joke") with identify("user-456", user_props={"email": "user456@test.com"}): agen.run("Who is Leo DiCaprio's girlfriend?") diff --git a/docs/docs/integrations/llms/anyscale.ipynb b/docs/docs/integrations/llms/anyscale.ipynb index 105746779c59e..5bba14d951bdf 100644 --- a/docs/docs/integrations/llms/anyscale.ipynb +++ b/docs/docs/integrations/llms/anyscale.ipynb @@ -147,7 +147,7 @@ "\n", "@ray.remote(num_cpus=0.1)\n", "def send_query(llm, prompt):\n", - " resp = llm(prompt)\n", + " resp = llm.invoke(prompt)\n", " return resp\n", "\n", "\n", diff --git a/docs/docs/integrations/llms/aphrodite.ipynb b/docs/docs/integrations/llms/aphrodite.ipynb index f90c4fae25efc..724f271ac5a73 100644 --- a/docs/docs/integrations/llms/aphrodite.ipynb +++ b/docs/docs/integrations/llms/aphrodite.ipynb @@ -96,7 +96,7 @@ ")\n", "\n", "print(\n", - " llm(\n", + " llm.invoke(\n", " '<|system|>Enter RP mode. You are Ayumu \"Osaka\" Kasuga.<|user|>Hey Osaka. Tell me about yourself.<|model|>'\n", " )\n", ")" diff --git a/docs/docs/integrations/llms/baichuan.ipynb b/docs/docs/integrations/llms/baichuan.ipynb index 7c92d17717ebf..ec55b305bd487 100644 --- a/docs/docs/integrations/llms/baichuan.ipynb +++ b/docs/docs/integrations/llms/baichuan.ipynb @@ -45,7 +45,7 @@ "# Load the model\n", "llm = BaichuanLLM()\n", "\n", - "res = llm(\"What's your name?\")\n", + "res = llm.invoke(\"What's your name?\")\n", "print(res)" ] }, diff --git a/docs/docs/integrations/llms/baidu_qianfan_endpoint.ipynb b/docs/docs/integrations/llms/baidu_qianfan_endpoint.ipynb index cff3fc145cd97..aaedf7891ccfe 100644 --- a/docs/docs/integrations/llms/baidu_qianfan_endpoint.ipynb +++ b/docs/docs/integrations/llms/baidu_qianfan_endpoint.ipynb @@ -80,7 +80,7 @@ "os.environ[\"QIANFAN_SK\"] = \"your_sk\"\n", "\n", "llm = QianfanLLMEndpoint(streaming=True)\n", - "res = llm(\"hi\")\n", + "res = llm.invoke(\"hi\")\n", "print(res)" ] }, @@ -185,7 +185,7 @@ " model=\"ERNIE-Bot-turbo\",\n", " endpoint=\"eb-instant\",\n", ")\n", - "res = llm(\"hi\")" + "res = llm.invoke(\"hi\")" ] }, { diff --git a/docs/docs/integrations/llms/ctransformers.ipynb b/docs/docs/integrations/llms/ctransformers.ipynb index 7c6248c01360f..8d98510af5f9e 100644 --- a/docs/docs/integrations/llms/ctransformers.ipynb +++ b/docs/docs/integrations/llms/ctransformers.ipynb @@ -85,7 +85,7 @@ " model=\"marella/gpt-2-ggml\", callbacks=[StreamingStdOutCallbackHandler()]\n", ")\n", "\n", - "response = llm(\"AI is going to\")" + "response = llm.invoke(\"AI is going to\")" ] }, { diff --git a/docs/docs/integrations/llms/ctranslate2.ipynb b/docs/docs/integrations/llms/ctranslate2.ipynb index c13a4d762557e..3f177af52c3cf 100644 --- a/docs/docs/integrations/llms/ctranslate2.ipynb +++ b/docs/docs/integrations/llms/ctranslate2.ipynb @@ -97,7 +97,7 @@ ], "source": [ "print(\n", - " llm(\n", + " llm.invoke(\n", " \"He presented me with plausible evidence for the existence of unicorns: \",\n", " max_length=256,\n", " sampling_topk=50,\n", diff --git a/docs/docs/integrations/llms/google_vertex_ai_palm.ipynb b/docs/docs/integrations/llms/google_vertex_ai_palm.ipynb index 425b5bb3f5d86..65ae7900f782e 100644 --- a/docs/docs/integrations/llms/google_vertex_ai_palm.ipynb +++ b/docs/docs/integrations/llms/google_vertex_ai_palm.ipynb @@ -359,7 +359,7 @@ "}\n", "message = HumanMessage(content=[text_message, image_message])\n", "\n", - "output = llm([message])\n", + "output = llm.invoke([message])\n", "print(output.content)" ] }, @@ -432,7 +432,7 @@ "}\n", "message = HumanMessage(content=[text_message, image_message])\n", "\n", - "output = llm([message])\n", + "output = llm.invoke([message])\n", "print(output.content)" ] }, @@ -457,7 +457,7 @@ "outputs": [], "source": [ "message2 = HumanMessage(content=\"And where the image is taken?\")\n", - "output2 = llm([message, output, message2])\n", + "output2 = llm.invoke([message, output, message2])\n", "print(output2.content)" ] }, @@ -486,7 +486,7 @@ "}\n", "message = HumanMessage(content=[text_message, image_message])\n", "\n", - "output = llm([message])\n", + "output = llm.invoke([message])\n", "print(output.content)" ] }, diff --git a/docs/docs/integrations/llms/koboldai.ipynb b/docs/docs/integrations/llms/koboldai.ipynb index d55a73efc264f..cc6fe549610e8 100644 --- a/docs/docs/integrations/llms/koboldai.ipynb +++ b/docs/docs/integrations/llms/koboldai.ipynb @@ -57,7 +57,7 @@ }, "outputs": [], "source": [ - "response = llm(\"### Instruction:\\nWhat is the first book of the bible?\\n### Response:\")" + "response = llm.invoke(\"### Instruction:\\nWhat is the first book of the bible?\\n### Response:\")" ] } ], diff --git a/docs/docs/integrations/llms/replicate.ipynb b/docs/docs/integrations/llms/replicate.ipynb index 95260e4096a55..569d33155e67f 100644 --- a/docs/docs/integrations/llms/replicate.ipynb +++ b/docs/docs/integrations/llms/replicate.ipynb @@ -323,7 +323,7 @@ "User: Answer the following yes/no question by reasoning step by step. Can a dog drive a car?\n", "Assistant:\n", "\"\"\"\n", - "_ = llm(prompt)" + "_ = llm.invoke(prompt)" ] }, { @@ -376,13 +376,13 @@ "Assistant:\n", "\"\"\"\n", "start_time = time.perf_counter()\n", - "raw_output = llm(prompt) # raw output, no stop\n", + "raw_output = llm.invoke(prompt) # raw output, no stop\n", "end_time = time.perf_counter()\n", "print(f\"Raw output:\\n {raw_output}\")\n", "print(f\"Raw output runtime: {end_time - start_time} seconds\")\n", "\n", "start_time = time.perf_counter()\n", - "stopped_output = llm(prompt, stop=[\"\\n\\n\"]) # stop on double newlines\n", + "stopped_output = llm.invoke(prompt, stop=[\"\\n\\n\"]) # stop on double newlines\n", "end_time = time.perf_counter()\n", "print(f\"Stopped output:\\n {stopped_output}\")\n", "print(f\"Stopped output runtime: {end_time - start_time} seconds\")" diff --git a/docs/docs/integrations/llms/sparkllm.ipynb b/docs/docs/integrations/llms/sparkllm.ipynb index f17c33a36d381..63642a81c77e6 100644 --- a/docs/docs/integrations/llms/sparkllm.ipynb +++ b/docs/docs/integrations/llms/sparkllm.ipynb @@ -65,7 +65,7 @@ "# Load the model\n", "llm = SparkLLM()\n", "\n", - "res = llm(\"What's your name?\")\n", + "res = llm.invoke(\"What's your name?\")\n", "print(res)" ] }, diff --git a/docs/docs/integrations/providers/flyte.mdx b/docs/docs/integrations/providers/flyte.mdx index c37fe96c65fd0..5fe20d896517c 100644 --- a/docs/docs/integrations/providers/flyte.mdx +++ b/docs/docs/integrations/providers/flyte.mdx @@ -83,7 +83,7 @@ def langchain_llm() -> str: temperature=0.2, callbacks=[FlyteCallbackHandler()], ) - return llm([HumanMessage(content="Tell me a joke")]).content + return llm.invoke([HumanMessage(content="Tell me a joke")]).content ``` ### Chain diff --git a/docs/docs/integrations/providers/konko.mdx b/docs/docs/integrations/providers/konko.mdx index 47f3f088f87d7..88b612dbc09b2 100644 --- a/docs/docs/integrations/providers/konko.mdx +++ b/docs/docs/integrations/providers/konko.mdx @@ -44,7 +44,7 @@ See a usage [example](/docs/integrations/llms/konko). from langchain.llms import Konko llm = Konko(max_tokens=800, model='mistralai/Mistral-7B-v0.1') prompt = "Generate a Product Description for Apple Iphone 15" - response = llm(prompt) + response = llm.invoke(prompt) ``` ## Chat Models diff --git a/docs/docs/use_cases/data_generation.ipynb b/docs/docs/use_cases/data_generation.ipynb index f96737b2debcb..208af24bd0d16 100644 --- a/docs/docs/use_cases/data_generation.ipynb +++ b/docs/docs/use_cases/data_generation.ipynb @@ -545,7 +545,7 @@ ")\n", "\n", "_input = prompt.format_prompt(text=dataset[0][\"text\"])\n", - "output = llm(_input.to_string())\n", + "output = llm.invoke(_input.to_string())\n", "\n", "parsed = parser.parse(output)\n", "parsed" From b1c81f8f712802939fc22a647bb325ba42069ccd Mon Sep 17 00:00:00 2001 From: Chester Curme Date: Wed, 24 Apr 2024 16:37:56 -0400 Subject: [PATCH 02/10] update --- docs/docs/integrations/callbacks/promptlayer.ipynb | 5 +++-- docs/docs/integrations/llms/predibase.ipynb | 4 ++-- docs/docs/integrations/providers/gpt4all.mdx | 2 +- docs/docs/integrations/providers/predibase.md | 6 +++--- docs/docs/integrations/providers/rwkv.mdx | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/docs/integrations/callbacks/promptlayer.ipynb b/docs/docs/integrations/callbacks/promptlayer.ipynb index 8deba48be5249..2ec4ce425a80e 100644 --- a/docs/docs/integrations/callbacks/promptlayer.ipynb +++ b/docs/docs/integrations/callbacks/promptlayer.ipynb @@ -129,10 +129,11 @@ "from langchain_community.llms import GPT4All\n", "\n", "model = GPT4All(model=\"./models/gpt4all-model.bin\", n_ctx=512, n_threads=8)\n", + "callbacks = [PromptLayerCallbackHandler(pl_tags=[\"langchain\", \"gpt4all\"])]\n", "\n", - "response = model(\n", + "response = model.invoke(\n", " \"Once upon a time, \",\n", - " callbacks=[PromptLayerCallbackHandler(pl_tags=[\"langchain\", \"gpt4all\"])],\n", + " config={\"callbacks\": callbacks},\n", ")" ] }, diff --git a/docs/docs/integrations/llms/predibase.ipynb b/docs/docs/integrations/llms/predibase.ipynb index fabd36d75fb30..b128b7cb0d6c9 100644 --- a/docs/docs/integrations/llms/predibase.ipynb +++ b/docs/docs/integrations/llms/predibase.ipynb @@ -94,7 +94,7 @@ "metadata": {}, "outputs": [], "source": [ - "response = model(\"Can you recommend me a nice dry wine?\")\n", + "response = model.invoke(\"Can you recommend me a nice dry wine?\")\n", "print(response)" ] }, @@ -262,7 +262,7 @@ "metadata": {}, "outputs": [], "source": [ - "# response = model(\"Can you help categorize the following emails into positive, negative, and neutral?\")" + "# response = model.invoke(\"Can you help categorize the following emails into positive, negative, and neutral?\")" ] } ], diff --git a/docs/docs/integrations/providers/gpt4all.mdx b/docs/docs/integrations/providers/gpt4all.mdx index 1050015961a56..231fae5f67641 100644 --- a/docs/docs/integrations/providers/gpt4all.mdx +++ b/docs/docs/integrations/providers/gpt4all.mdx @@ -27,7 +27,7 @@ from langchain_community.llms import GPT4All model = GPT4All(model="./models/mistral-7b-openorca.Q4_0.gguf", n_threads=8) # Generate text -response = model("Once upon a time, ") +response = model.invoke("Once upon a time, ") ``` You can also customize the generation parameters, such as n_predict, temp, top_p, top_k, and others. diff --git a/docs/docs/integrations/providers/predibase.md b/docs/docs/integrations/providers/predibase.md index 5a88ff117f372..77ed76021cf99 100644 --- a/docs/docs/integrations/providers/predibase.md +++ b/docs/docs/integrations/providers/predibase.md @@ -19,7 +19,7 @@ from langchain_community.llms import Predibase model = Predibase(model="mistral-7b"", predibase_api_key=os.environ.get("PREDIBASE_API_TOKEN")) -response = model("Can you recommend me a nice dry wine?") +response = model.invoke("Can you recommend me a nice dry wine?") print(response) ``` @@ -34,7 +34,7 @@ from langchain_community.llms import Predibase # The fine-tuned adapter is hosted at Predibase (adapter_version can be specified; omitting it is equivalent to the most recent version). model = Predibase(model="mistral-7b"", adapter_id="e2e_nlg", adapter_version=1, predibase_api_key=os.environ.get("PREDIBASE_API_TOKEN")) -response = model("Can you recommend me a nice dry wine?") +response = model.invoke("Can you recommend me a nice dry wine?") print(response) ``` @@ -49,6 +49,6 @@ from langchain_community.llms import Predibase # The fine-tuned adapter is hosted at HuggingFace (adapter_version does not apply and will be ignored). model = Predibase(model="mistral-7b"", adapter_id="predibase/e2e_nlg", predibase_api_key=os.environ.get("PREDIBASE_API_TOKEN")) -response = model("Can you recommend me a nice dry wine?") +response = model.invoke("Can you recommend me a nice dry wine?") print(response) ``` diff --git a/docs/docs/integrations/providers/rwkv.mdx b/docs/docs/integrations/providers/rwkv.mdx index 2b5f827aa2282..90a795a420865 100644 --- a/docs/docs/integrations/providers/rwkv.mdx +++ b/docs/docs/integrations/providers/rwkv.mdx @@ -44,7 +44,7 @@ def generate_prompt(instruction, input=None): model = RWKV(model="./models/RWKV-4-Raven-3B-v7-Eng-20230404-ctx4096.pth", strategy="cpu fp32", tokens_path="./rwkv/20B_tokenizer.json") -response = model(generate_prompt("Once upon a time, ")) +response = model.invoke(generate_prompt("Once upon a time, ")) ``` ## Model File From 8da2c627441a76977d4fe11e97f564ba5f5bc86f Mon Sep 17 00:00:00 2001 From: Chester Curme Date: Wed, 24 Apr 2024 16:39:55 -0400 Subject: [PATCH 03/10] update --- docs/docs/integrations/chat/alibaba_cloud_pai_eas.ipynb | 4 ++-- docs/docs/integrations/chat/llama_edge.ipynb | 2 +- docs/docs/integrations/chat/zhipuai.ipynb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/integrations/chat/alibaba_cloud_pai_eas.ipynb b/docs/docs/integrations/chat/alibaba_cloud_pai_eas.ipynb index c2eb76754750d..342835629d520 100644 --- a/docs/docs/integrations/chat/alibaba_cloud_pai_eas.ipynb +++ b/docs/docs/integrations/chat/alibaba_cloud_pai_eas.ipynb @@ -72,7 +72,7 @@ "metadata": {}, "outputs": [], "source": [ - "output = chat([HumanMessage(content=\"write a funny joke\")])\n", + "output = chat.invoke([HumanMessage(content=\"write a funny joke\")])\n", "print(\"output:\", output)" ] }, @@ -90,7 +90,7 @@ "outputs": [], "source": [ "kwargs = {\"temperature\": 0.8, \"top_p\": 0.8, \"top_k\": 5}\n", - "output = chat([HumanMessage(content=\"write a funny joke\")], **kwargs)\n", + "output = chat.invoke([HumanMessage(content=\"write a funny joke\")], **kwargs)\n", "print(\"output:\", output)" ] }, diff --git a/docs/docs/integrations/chat/llama_edge.ipynb b/docs/docs/integrations/chat/llama_edge.ipynb index 003439844a443..16fb92b0b0c75 100644 --- a/docs/docs/integrations/chat/llama_edge.ipynb +++ b/docs/docs/integrations/chat/llama_edge.ipynb @@ -62,7 +62,7 @@ "messages = [system_message, user_message]\n", "\n", "# chat with wasm-chat service\n", - "response = chat(messages)\n", + "response = chat.invoke(messages)\n", "\n", "print(f\"[Bot] {response.content}\")" ] diff --git a/docs/docs/integrations/chat/zhipuai.ipynb b/docs/docs/integrations/chat/zhipuai.ipynb index 7d7c0777f6706..7dd4ae931cca0 100644 --- a/docs/docs/integrations/chat/zhipuai.ipynb +++ b/docs/docs/integrations/chat/zhipuai.ipynb @@ -119,7 +119,7 @@ "metadata": {}, "outputs": [], "source": [ - "response = chat(messages)\n", + "response = chat.invoke(messages)\n", "print(response.content) # Displays the AI-generated poem" ] }, From 406e3302fbfcb18520ff2253252e6551b618ac1d Mon Sep 17 00:00:00 2001 From: Chester Curme Date: Wed, 24 Apr 2024 16:40:55 -0400 Subject: [PATCH 04/10] format --- docs/docs/integrations/llms/koboldai.ipynb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/docs/integrations/llms/koboldai.ipynb b/docs/docs/integrations/llms/koboldai.ipynb index cc6fe549610e8..de6502c0a8bbc 100644 --- a/docs/docs/integrations/llms/koboldai.ipynb +++ b/docs/docs/integrations/llms/koboldai.ipynb @@ -57,7 +57,9 @@ }, "outputs": [], "source": [ - "response = llm.invoke(\"### Instruction:\\nWhat is the first book of the bible?\\n### Response:\")" + "response = llm.invoke(\n", + " \"### Instruction:\\nWhat is the first book of the bible?\\n### Response:\"\n", + ")" ] } ], From 0b1aaf9301e57abbb8ac5364e1347045515ffa2d Mon Sep 17 00:00:00 2001 From: Chester Curme Date: Wed, 24 Apr 2024 16:45:23 -0400 Subject: [PATCH 05/10] update cookbook --- cookbook/Multi_modal_RAG_google.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/Multi_modal_RAG_google.ipynb b/cookbook/Multi_modal_RAG_google.ipynb index 6df5b20cdaf19..3ba989edcfdb8 100644 --- a/cookbook/Multi_modal_RAG_google.ipynb +++ b/cookbook/Multi_modal_RAG_google.ipynb @@ -256,7 +256,7 @@ " \"\"\"Make image summary\"\"\"\n", " model = ChatVertexAI(model_name=\"gemini-pro-vision\", max_output_tokens=1024)\n", "\n", - " msg = model(\n", + " msg = model.invoke(\n", " [\n", " HumanMessage(\n", " content=[\n", From f488dc5e3d3e24f0ac56f727051bee6ca3f7cfd9 Mon Sep 17 00:00:00 2001 From: Chester Curme Date: Wed, 24 Apr 2024 16:50:22 -0400 Subject: [PATCH 06/10] update --- .../integrations/callbacks/labelstudio.ipynb | 2 +- docs/docs/integrations/llms/ctransformers.ipynb | 2 +- docs/docs/integrations/llms/deepsparse.ipynb | 2 +- docs/docs/integrations/llms/edenai.ipynb | 2 +- docs/docs/integrations/llms/konko.ipynb | 2 +- docs/docs/integrations/llms/llm_caching.ipynb | 16 ++++++++-------- .../integrations/providers/ctransformers.mdx | 2 +- docs/docs/integrations/providers/deepsparse.mdx | 2 +- docs/docs/integrations/providers/helicone.mdx | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/docs/integrations/callbacks/labelstudio.ipynb b/docs/docs/integrations/callbacks/labelstudio.ipynb index 68e17408c589d..b0a4418534fda 100644 --- a/docs/docs/integrations/callbacks/labelstudio.ipynb +++ b/docs/docs/integrations/callbacks/labelstudio.ipynb @@ -194,7 +194,7 @@ "llm = OpenAI(\n", " temperature=0, callbacks=[LabelStudioCallbackHandler(project_name=\"My Project\")]\n", ")\n", - "print(llm(\"Tell me a joke\"))" + "print(llm.invoke(\"Tell me a joke\"))" ] }, { diff --git a/docs/docs/integrations/llms/ctransformers.ipynb b/docs/docs/integrations/llms/ctransformers.ipynb index 8d98510af5f9e..ce7bbce11fe0b 100644 --- a/docs/docs/integrations/llms/ctransformers.ipynb +++ b/docs/docs/integrations/llms/ctransformers.ipynb @@ -62,7 +62,7 @@ "metadata": {}, "outputs": [], "source": [ - "print(llm(\"AI is going to\"))" + "print(llm.invoke(\"AI is going to\"))" ] }, { diff --git a/docs/docs/integrations/llms/deepsparse.ipynb b/docs/docs/integrations/llms/deepsparse.ipynb index bdec459e733b1..138663b69cf3a 100644 --- a/docs/docs/integrations/llms/deepsparse.ipynb +++ b/docs/docs/integrations/llms/deepsparse.ipynb @@ -32,7 +32,7 @@ " model=\"zoo:nlg/text_generation/codegen_mono-350m/pytorch/huggingface/bigpython_bigquery_thepile/base-none\"\n", ")\n", "\n", - "print(llm(\"def fib():\"))" + "print(llm.invoke(\"def fib():\"))" ] }, { diff --git a/docs/docs/integrations/llms/edenai.ipynb b/docs/docs/integrations/llms/edenai.ipynb index b6231654df50d..be68b1275d7f5 100644 --- a/docs/docs/integrations/llms/edenai.ipynb +++ b/docs/docs/integrations/llms/edenai.ipynb @@ -203,7 +203,7 @@ "User: Answer the following yes/no question by reasoning step by step. Can a dog drive a car?\n", "Assistant:\n", "\"\"\"\n", - "print(llm(prompt))" + "print(llm.invoke(prompt))" ] }, { diff --git a/docs/docs/integrations/llms/konko.ipynb b/docs/docs/integrations/llms/konko.ipynb index ef1ffc15d851f..8592a09d8362d 100644 --- a/docs/docs/integrations/llms/konko.ipynb +++ b/docs/docs/integrations/llms/konko.ipynb @@ -90,7 +90,7 @@ "llm = Konko(model=\"mistralai/mistral-7b-v0.1\", temperature=0.1, max_tokens=128)\n", "\n", "input_ = \"\"\"You are a helpful assistant. Explain Big Bang Theory briefly.\"\"\"\n", - "print(llm(input_))" + "print(llm.invoke(input_))" ] }, { diff --git a/docs/docs/integrations/llms/llm_caching.ipynb b/docs/docs/integrations/llms/llm_caching.ipynb index 65e55ee1dadb6..504a771ea249f 100644 --- a/docs/docs/integrations/llms/llm_caching.ipynb +++ b/docs/docs/integrations/llms/llm_caching.ipynb @@ -1020,7 +1020,7 @@ "source": [ "%%time\n", "\n", - "print(llm(\"Why is the Moon always showing the same side?\"))" + "print(llm.invoke(\"Why is the Moon always showing the same side?\"))" ] }, { @@ -1044,7 +1044,7 @@ "source": [ "%%time\n", "\n", - "print(llm(\"Why is the Moon always showing the same side?\"))" + "print(llm.invoke(\"Why is the Moon always showing the same side?\"))" ] }, { @@ -1109,7 +1109,7 @@ "source": [ "%%time\n", "\n", - "print(llm(\"Why is the Moon always showing the same side?\"))" + "print(llm.invoke(\"Why is the Moon always showing the same side?\"))" ] }, { @@ -1133,7 +1133,7 @@ "source": [ "%%time\n", "\n", - "print(llm(\"How come we always see one face of the moon?\"))" + "print(llm.invoke(\"How come we always see one face of the moon?\"))" ] }, { @@ -1238,7 +1238,7 @@ "source": [ "%%time\n", "\n", - "print(llm(\"Is a true fakery the same as a fake truth?\"))" + "print(llm.invoke(\"Is a true fakery the same as a fake truth?\"))" ] }, { @@ -1262,7 +1262,7 @@ "source": [ "%%time\n", "\n", - "print(llm(\"Is a true fakery the same as a fake truth?\"))" + "print(llm.invoke(\"Is a true fakery the same as a fake truth?\"))" ] }, { @@ -1327,7 +1327,7 @@ "source": [ "%%time\n", "\n", - "print(llm(\"Are there truths that are false?\"))" + "print(llm.invoke(\"Are there truths that are false?\"))" ] }, { @@ -1351,7 +1351,7 @@ "source": [ "%%time\n", "\n", - "print(llm(\"Is is possible that something false can be also true?\"))" + "print(llm.invoke(\"Is is possible that something false can be also true?\"))" ] }, { diff --git a/docs/docs/integrations/providers/ctransformers.mdx b/docs/docs/integrations/providers/ctransformers.mdx index a787a7ec2fc0c..09414a8fe7d44 100644 --- a/docs/docs/integrations/providers/ctransformers.mdx +++ b/docs/docs/integrations/providers/ctransformers.mdx @@ -23,7 +23,7 @@ It provides a unified interface for all models: ```python llm = CTransformers(model='/path/to/ggml-gpt-2.bin', model_type='gpt2') -print(llm('AI is going to')) +print(llm.invoke('AI is going to')) ``` If you are getting `illegal instruction` error, try using `lib='avx'` or `lib='basic'`: diff --git a/docs/docs/integrations/providers/deepsparse.mdx b/docs/docs/integrations/providers/deepsparse.mdx index 879b07c55c9ab..562d9e3e76512 100644 --- a/docs/docs/integrations/providers/deepsparse.mdx +++ b/docs/docs/integrations/providers/deepsparse.mdx @@ -22,7 +22,7 @@ It provides a unified interface for all models: ```python llm = DeepSparse(model='zoo:nlg/text_generation/codegen_mono-350m/pytorch/huggingface/bigpython_bigquery_thepile/base-none') -print(llm('def fib():')) +print(llm.invoke('def fib():')) ``` Additional parameters can be passed using the `config` parameter: diff --git a/docs/docs/integrations/providers/helicone.mdx b/docs/docs/integrations/providers/helicone.mdx index 548088d079118..9f2898870b365 100644 --- a/docs/docs/integrations/providers/helicone.mdx +++ b/docs/docs/integrations/providers/helicone.mdx @@ -29,7 +29,7 @@ openai.api_base = "https://oai.hconeai.com/v1" llm = OpenAI(temperature=0.9, headers={"Helicone-Cache-Enabled": "true"}) text = "What is a helicone?" -print(llm(text)) +print(llm.invoke(text)) ``` [Helicone caching docs](https://docs.helicone.ai/advanced-usage/caching) @@ -47,7 +47,7 @@ llm = OpenAI(temperature=0.9, headers={ "Helicone-Property-App": "mobile", }) text = "What is a helicone?" -print(llm(text)) +print(llm.invoke(text)) ``` [Helicone property docs](https://docs.helicone.ai/advanced-usage/custom-properties) From cb7724e4a6a4689dd24c139db82d2a31daac133c Mon Sep 17 00:00:00 2001 From: Chester Curme Date: Wed, 24 Apr 2024 16:55:24 -0400 Subject: [PATCH 07/10] update --- docs/docs/integrations/callbacks/labelstudio.ipynb | 2 +- docs/docs/integrations/callbacks/promptlayer.ipynb | 2 +- docs/docs/integrations/callbacks/trubrics.ipynb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/integrations/callbacks/labelstudio.ipynb b/docs/docs/integrations/callbacks/labelstudio.ipynb index b0a4418534fda..e6841025c9213 100644 --- a/docs/docs/integrations/callbacks/labelstudio.ipynb +++ b/docs/docs/integrations/callbacks/labelstudio.ipynb @@ -270,7 +270,7 @@ " )\n", " ]\n", ")\n", - "llm_results = chat_llm(\n", + "llm_results = chat_llm.invoke(\n", " [\n", " SystemMessage(content=\"Always use a lot of emojis\"),\n", " HumanMessage(content=\"Tell me a joke\"),\n", diff --git a/docs/docs/integrations/callbacks/promptlayer.ipynb b/docs/docs/integrations/callbacks/promptlayer.ipynb index 2ec4ce425a80e..89ed253613135 100644 --- a/docs/docs/integrations/callbacks/promptlayer.ipynb +++ b/docs/docs/integrations/callbacks/promptlayer.ipynb @@ -103,7 +103,7 @@ " temperature=0,\n", " callbacks=[PromptLayerCallbackHandler(pl_tags=[\"chatopenai\"])],\n", ")\n", - "llm_results = chat_llm(\n", + "llm_results = chat_llm.invoke(\n", " [\n", " HumanMessage(content=\"What comes after 1,2,3 ?\"),\n", " HumanMessage(content=\"Tell me another joke?\"),\n", diff --git a/docs/docs/integrations/callbacks/trubrics.ipynb b/docs/docs/integrations/callbacks/trubrics.ipynb index 89feb2c1d0ae6..4e3771c0a924d 100644 --- a/docs/docs/integrations/callbacks/trubrics.ipynb +++ b/docs/docs/integrations/callbacks/trubrics.ipynb @@ -315,7 +315,7 @@ } ], "source": [ - "chat_res = chat_llm(\n", + "chat_res = chat_llm.invoke(\n", " [\n", " SystemMessage(content=\"Every answer of yours must be about OpenAI.\"),\n", " HumanMessage(content=\"Tell me a joke\"),\n", From a661b7ef5e4ad676fa43663182008916d497762c Mon Sep 17 00:00:00 2001 From: Chester Curme Date: Wed, 24 Apr 2024 16:57:26 -0400 Subject: [PATCH 08/10] update --- docs/docs/integrations/callbacks/promptlayer.ipynb | 2 +- docs/docs/integrations/llms/bittensor.ipynb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/integrations/callbacks/promptlayer.ipynb b/docs/docs/integrations/callbacks/promptlayer.ipynb index 89ed253613135..acbe00324ae07 100644 --- a/docs/docs/integrations/callbacks/promptlayer.ipynb +++ b/docs/docs/integrations/callbacks/promptlayer.ipynb @@ -182,7 +182,7 @@ ")\n", "\n", "example_prompt = promptlayer.prompts.get(\"example\", version=1, langchain=True)\n", - "openai_llm(example_prompt.format(product=\"toasters\"))" + "openai_llm.invoke(example_prompt.format(product=\"toasters\"))" ] }, { diff --git a/docs/docs/integrations/llms/bittensor.ipynb b/docs/docs/integrations/llms/bittensor.ipynb index 1af3584faeade..89981589c7b98 100644 --- a/docs/docs/integrations/llms/bittensor.ipynb +++ b/docs/docs/integrations/llms/bittensor.ipynb @@ -62,7 +62,7 @@ " } \"\"\"\n", "\n", "multi_response_llm = NIBittensorLLM(top_responses=10)\n", - "multi_resp = multi_response_llm(\"What is Neural Network Feeding Mechanism?\")\n", + "multi_resp = multi_response_llm.invoke(\"What is Neural Network Feeding Mechanism?\")\n", "json_multi_resp = json.loads(multi_resp)\n", "pprint(json_multi_resp)" ] From 22f485a9000986366b507a25d1256f42602b91bd Mon Sep 17 00:00:00 2001 From: Chester Curme Date: Wed, 24 Apr 2024 17:00:57 -0400 Subject: [PATCH 09/10] update cookbook --- cookbook/forward_looking_retrieval_augmented_generation.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/forward_looking_retrieval_augmented_generation.ipynb b/cookbook/forward_looking_retrieval_augmented_generation.ipynb index 4406c1812db08..46200f04f5e04 100644 --- a/cookbook/forward_looking_retrieval_augmented_generation.ipynb +++ b/cookbook/forward_looking_retrieval_augmented_generation.ipynb @@ -362,7 +362,7 @@ ], "source": [ "llm = OpenAI()\n", - "llm(query)" + "llm.invoke(query)" ] }, { From 75f6bb35588e043186f6bf51ce829e2ea7c8e1bc Mon Sep 17 00:00:00 2001 From: Chester Curme Date: Wed, 24 Apr 2024 17:43:58 -0400 Subject: [PATCH 10/10] update --- cookbook/camel_role_playing.ipynb | 2 +- cookbook/gymnasium_agent_simulation.ipynb | 2 +- cookbook/multi_player_dnd.ipynb | 2 +- cookbook/multiagent_authoritarian.ipynb | 8 ++++---- cookbook/multiagent_bidding.ipynb | 4 ++-- cookbook/petting_zoo.ipynb | 2 +- cookbook/two_agent_debate_tools.ipynb | 2 +- cookbook/two_player_dnd.ipynb | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cookbook/camel_role_playing.ipynb b/cookbook/camel_role_playing.ipynb index ab8f44adf99b0..afa2215c15a70 100644 --- a/cookbook/camel_role_playing.ipynb +++ b/cookbook/camel_role_playing.ipynb @@ -90,7 +90,7 @@ " ) -> AIMessage:\n", " messages = self.update_messages(input_message)\n", "\n", - " output_message = self.model(messages)\n", + " output_message = self.model.invoke(messages)\n", " self.update_messages(output_message)\n", "\n", " return output_message" diff --git a/cookbook/gymnasium_agent_simulation.ipynb b/cookbook/gymnasium_agent_simulation.ipynb index 9990afd4d8f42..3997a644e2afa 100644 --- a/cookbook/gymnasium_agent_simulation.ipynb +++ b/cookbook/gymnasium_agent_simulation.ipynb @@ -108,7 +108,7 @@ " return obs_message\n", "\n", " def _act(self):\n", - " act_message = self.model(self.message_history)\n", + " act_message = self.model.invoke(self.message_history)\n", " self.message_history.append(act_message)\n", " action = int(self.action_parser.parse(act_message.content)[\"action\"])\n", " return action\n", diff --git a/cookbook/multi_player_dnd.ipynb b/cookbook/multi_player_dnd.ipynb index 05c4d45914678..9bb3489c538ff 100644 --- a/cookbook/multi_player_dnd.ipynb +++ b/cookbook/multi_player_dnd.ipynb @@ -74,7 +74,7 @@ " Applies the chatmodel to the message history\n", " and returns the message string\n", " \"\"\"\n", - " message = self.model(\n", + " message = self.model.invoke(\n", " [\n", " self.system_message,\n", " HumanMessage(content=\"\\n\".join(self.message_history + [self.prefix])),\n", diff --git a/cookbook/multiagent_authoritarian.ipynb b/cookbook/multiagent_authoritarian.ipynb index 893b35f7c7868..fd557083e20dd 100644 --- a/cookbook/multiagent_authoritarian.ipynb +++ b/cookbook/multiagent_authoritarian.ipynb @@ -79,7 +79,7 @@ " Applies the chatmodel to the message history\n", " and returns the message string\n", " \"\"\"\n", - " message = self.model(\n", + " message = self.model.invoke(\n", " [\n", " self.system_message,\n", " HumanMessage(content=\"\\n\".join(self.message_history + [self.prefix])),\n", @@ -234,7 +234,7 @@ " termination_clause=self.termination_clause if self.stop else \"\",\n", " )\n", "\n", - " self.response = self.model(\n", + " self.response = self.model.invoke(\n", " [\n", " self.system_message,\n", " HumanMessage(content=response_prompt),\n", @@ -263,7 +263,7 @@ " speaker_names=speaker_names,\n", " )\n", "\n", - " choice_string = self.model(\n", + " choice_string = self.model.invoke(\n", " [\n", " self.system_message,\n", " HumanMessage(content=choice_prompt),\n", @@ -299,7 +299,7 @@ " ),\n", " next_speaker=self.next_speaker,\n", " )\n", - " message = self.model(\n", + " message = self.model.invoke(\n", " [\n", " self.system_message,\n", " HumanMessage(content=next_prompt),\n", diff --git a/cookbook/multiagent_bidding.ipynb b/cookbook/multiagent_bidding.ipynb index fbb9f03f53d1f..886c47289919f 100644 --- a/cookbook/multiagent_bidding.ipynb +++ b/cookbook/multiagent_bidding.ipynb @@ -71,7 +71,7 @@ " Applies the chatmodel to the message history\n", " and returns the message string\n", " \"\"\"\n", - " message = self.model(\n", + " message = self.model.invoke(\n", " [\n", " self.system_message,\n", " HumanMessage(content=\"\\n\".join(self.message_history + [self.prefix])),\n", @@ -164,7 +164,7 @@ " message_history=\"\\n\".join(self.message_history),\n", " recent_message=self.message_history[-1],\n", " )\n", - " bid_string = self.model([SystemMessage(content=prompt)]).content\n", + " bid_string = self.model.invoke([SystemMessage(content=prompt)]).content\n", " return bid_string" ] }, diff --git a/cookbook/petting_zoo.ipynb b/cookbook/petting_zoo.ipynb index c0db7653b0919..14d6435b47f1e 100644 --- a/cookbook/petting_zoo.ipynb +++ b/cookbook/petting_zoo.ipynb @@ -129,7 +129,7 @@ " return obs_message\n", "\n", " def _act(self):\n", - " act_message = self.model(self.message_history)\n", + " act_message = self.model.invoke(self.message_history)\n", " self.message_history.append(act_message)\n", " action = int(self.action_parser.parse(act_message.content)[\"action\"])\n", " return action\n", diff --git a/cookbook/two_agent_debate_tools.ipynb b/cookbook/two_agent_debate_tools.ipynb index 3815889ff2576..78c2469c6ee0a 100644 --- a/cookbook/two_agent_debate_tools.ipynb +++ b/cookbook/two_agent_debate_tools.ipynb @@ -84,7 +84,7 @@ " Applies the chatmodel to the message history\n", " and returns the message string\n", " \"\"\"\n", - " message = self.model(\n", + " message = self.model.invoke(\n", " [\n", " self.system_message,\n", " HumanMessage(content=\"\\n\".join(self.message_history + [self.prefix])),\n", diff --git a/cookbook/two_player_dnd.ipynb b/cookbook/two_player_dnd.ipynb index d90e4f9365fe7..74f3b0c566d95 100644 --- a/cookbook/two_player_dnd.ipynb +++ b/cookbook/two_player_dnd.ipynb @@ -70,7 +70,7 @@ " Applies the chatmodel to the message history\n", " and returns the message string\n", " \"\"\"\n", - " message = self.model(\n", + " message = self.model.invoke(\n", " [\n", " self.system_message,\n", " HumanMessage(content=\"\\n\".join(self.message_history + [self.prefix])),\n",