Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using chat_with_website pipeline #15

Closed
ssword62 opened this issue May 10, 2024 · 2 comments
Closed

using chat_with_website pipeline #15

ssword62 opened this issue May 10, 2024 · 2 comments

Comments

@ssword62
Copy link

After deploying to the hayhooks server the pipeline chat_with_website, I'm trying to use it.
Starting from your example for test_pipeline_01.yml I'm trying
curl -X 'POST' \ 'http:https://localhost:1416/chat_with_website' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "converter": { "value": "what is haystack?" } }'
since converter is the name of the first element of the pipeline and th input is an HTML document (a simple string in my case)

this leads to the error 422 Unprocessable Entity
{"detail":[{"type":"missing","loc":["body","fetcher"],"msg":"Field required","input":{"converter":{"value":"what is haystack?"}}},{"type":"missing","loc":["body","llm"],"msg":"Field required","input":{"converter":{"value":"what is haystack?"}}},{"type":"missing","loc":["body","prompt"],"msg":"Field required","input":{"converter":{"value":"what is haystack?"}}}]}

What am I doing wrong?
Thanks.

@masci
Copy link
Contributor

masci commented May 10, 2024

With this pipeline (taken from Haystack's predefined templates and stripped from the {%raw%} blocks):

components:
  converter:
    init_parameters:
      extractor_type: DefaultExtractor
    type: haystack.components.converters.html.HTMLToDocument

  fetcher:
    init_parameters:
      raise_on_failure: true
      retry_attempts: 2
      timeout: 3
      user_agents:
      - haystack/LinkContentFetcher/2.0.0b8
    type: haystack.components.fetchers.link_content.LinkContentFetcher

  llm:
    init_parameters:
      api_base_url: null
      api_key:
        env_vars:
        - OPENAI_API_KEY
        strict: true
        type: env_var
      generation_kwargs: {}
      model: gpt-3.5-turbo
      streaming_callback: null
      system_prompt: null
    type: haystack.components.generators.openai.OpenAIGenerator

  prompt:
    init_parameters:
      template: |
        "According to the contents of this website:
        {% for document in documents %}
          {{document.content}}
        {% endfor %}
        Answer the given question: {{query}}
        Answer:
        "
    type: haystack.components.builders.prompt_builder.PromptBuilder

connections:
- receiver: converter.sources
  sender: fetcher.streams
- receiver: prompt.documents
  sender: converter.documents
- receiver: llm.prompt
  sender: prompt.prompt

metadata: {}

This is the curl command I used:

curl -X 'POST' \
  'http:https://localhost:1416/chat_with_website' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "converter": {
    "meta": {}
  },
  "fetcher": {
    "urls": [
      "https://haystack.deepset.ai"
    ]
  },
  "llm": {
    "generation_kwargs": {}
  },
  "prompt": {
    "query": "What is Haystack?"
  }
}'

@ssword62
Copy link
Author

@masci thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants