From 8b71a22da3a9be8ee2c9bf2756fe46d26d8dd83b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tuana=20=C3=87elik?= Date: Fri, 10 Nov 2023 21:53:40 +0100 Subject: [PATCH] Update index.md --- .../index.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/content/blog/customizing-rag-to-summarize-hacker-news-posts-with-haystack2/index.md b/content/blog/customizing-rag-to-summarize-hacker-news-posts-with-haystack2/index.md index 9d9ec62b..cd0a86a3 100644 --- a/content/blog/customizing-rag-to-summarize-hacker-news-posts-with-haystack2/index.md +++ b/content/blog/customizing-rag-to-summarize-hacker-news-posts-with-haystack2/index.md @@ -81,7 +81,7 @@ class HackernewsNewestFetcher(): article = Article(url) article.download() article.parse() - docs.append(Document(text=article.text, metadata={'title': article.title, 'url': url})) + docs.append(Document(content=article.text, meta={'title': article.title, 'url': url})) except: print(f"Couldn't download {url}, skipped") return {'articles': docs} @@ -116,7 +116,7 @@ First, we initialize all of the components we will need for the pipeline: ```python from haystack.preview import Pipeline from haystack.preview.components.builders.prompt_builder import PromptBuilder -from haystack.preview.components.generators.openai import GPTGenerator +from haystack.preview.components.generators import GPTGenerator prompt_template = """ You will be provided a few of the latest posts in HackerNews, followed by their URL. @@ -124,8 +124,8 @@ For each post, provide a brief summary followed by the URL the full post can be Posts: {% for article in articles %} - {{article.text}} - URL: {{article.metadata['url']}} + {{article.content}} + URL: {{article.meta['url']}} {% endfor %} """ @@ -151,8 +151,8 @@ Here, notice how we connect `hackernews_fetcher.articles` to `prompt_builder.art ``` Posts: {% for article in articles %} - {{article.text}} - URL: {{article.metadata['url']}} + {{article.contnet}} + URL: {{article.meta['url']}} {% endfor %} ``` The output and input keys do not need to have matching names. Additionally, `prompt_builder` makes _all_ of the input keys available to your prompt template. We could, for example, provide a `documents` input to `prompt_builder` instead of `articles`. Then our code might look like this: @@ -164,8 +164,8 @@ For each post, provide a brief summary followed by the URL the full post can be Posts: {% for document in documents %} - {{document.text}} - URL: {{document.metadata['url']}} + {{document.content}} + URL: {{document.meta['url']}} {% endfor %} """