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

New http-request agent #537

Merged
merged 5 commits into from
Oct 9, 2023
Merged

New http-request agent #537

merged 5 commits into from
Oct 9, 2023

Conversation

nicoloboschi
Copy link
Member

@nicoloboschi nicoloboschi commented Oct 5, 2023

  • Added new http-request agent
  • It accepts
    • url: http(s) url to call without query-string
    • query-string (map): accepts string as template. encoding is done automatically
    • method: "get" by default
    • headers (map): accepts string as template e.g. X-Custom-Header: {{{ value.id }}}
    • body: body to send, must be a string: accepts string as template e.g. X-Custom-Header: {{{ value.id }}}
    • output-field: field where to output in the record. in case the response return content-type: application/json it will be deserialized as map. otherwise will be threated as string
    • allow-redirects: set to false to never redirect
    • handle-cookies: set to false to not manage cookies during redirects

Example with authentication

                                  - name: "http-request"
                                    type: "http-request"
                                    input: input-topic
                                    output: output-topic
                                    id: step1
                                    configuration:
                                        output-field: value.api
                                        url: "https://somewhere/api/test/{{{ value.id }}}"
                                        method: POST
                                        body: '{"id": "{{{ value.id }}}"}'
                                        headers:
                                          Content-Type: application/json
                                          Authorization: Bearer {{{ secrets.s1.token }}}

Copy link
Member

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

I would make the query string parameters configurable, otherwise you have to provide a way to perform escaping.

Also I would make the url a constant in the first iteration, this way we prevent malicious usage, like calling URLs forged by a chatbot user

@nicoloboschi nicoloboschi force-pushed the http-agent branch 2 times, most recently from f6baebc to 8ea3a05 Compare October 5, 2023 13:53
Copy link
Member

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

LGTM

@cbornet
Copy link
Member

cbornet commented Oct 5, 2023

It can be interesting to look at what features LangChain loaders provide when we create these Sources.

@nicoloboschi nicoloboschi merged commit fa0f240 into main Oct 9, 2023
7 of 8 checks passed
@nicoloboschi nicoloboschi deleted the http-agent branch October 9, 2023 07:01
benfrank241 pushed a commit to vectorize-io/langstream that referenced this pull request May 2, 2024
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

Successfully merging this pull request may close these issues.

None yet

3 participants