Skip to content

Commit

Permalink
Update index.md
Browse files Browse the repository at this point in the history
  • Loading branch information
TuanaCelik authored Nov 10, 2023
1 parent abeeec6 commit 8b71a22
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -116,16 +116,16 @@ 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.
For each post, provide a brief summary followed by the URL the full post can be found at.
Posts:
{% for article in articles %}
{{article.text}}
URL: {{article.metadata['url']}}
{{article.content}}
URL: {{article.meta['url']}}
{% endfor %}
"""
Expand All @@ -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:
Expand All @@ -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 %}
"""
Expand Down

1 comment on commit 8b71a22

@vercel
Copy link

@vercel vercel bot commented on 8b71a22 Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.