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

Introduce new gateway type: 'chat' #398

Merged
merged 3 commits into from
Sep 14, 2023
Merged

Introduce new gateway type: 'chat' #398

merged 3 commits into from
Sep 14, 2023

Conversation

nicoloboschi
Copy link
Member

@nicoloboschi nicoloboschi commented Sep 12, 2023

In many cases, the application declares two gateways for both producing and consuming messages at the end and beginning of the pipeline. This results in two connection opened to the gateway and hard configuration in the CLI.
It would be useful to have a simpler gateway that does both in only one connection and optimized for the chat-like communication.

Changes:

  • Added a new type 'chat' to the gateway types
- id: chat
   type: chat
   authentication:
      provider: google
      configuration:
        clientId: "{{ secrets.google.client-id }}"
   chat-options:
      headers:
      - value-from-parameters: session-id
      - value-from-authentication: user-id
      answers-topic: output-topic
      user-parameter: subject

questions-topic: (required). Topic for producing messages. Typically the input topic of the pipeline
answers-topic: (required). Topic for reading messages. Typically the output topic of the pipeline
headers: (optional). When set, they become a required parameters to be passed to the gateway connection (like parameters in other gateway types). All the value-from-parameters are generated automatically by the CLI.

The producer and consumer implicitly uses session-parameter and user-parameter to append headers to the produced messages and use them as consumer filters.

The above chat example is functionally equivalent to:

- id: produce-input-auth-google
  type: produce
  topic: input-topic
  parameters:
    - session-id
  authentication:
      provider: google
      configuration:
        clientId: "{{ secrets.google.client-id }}"
    produce-options:
      headers:
        - key: subject
          value-from-authentication: subject
        - key: session-id
          value-from-parameters: session-id

  - id: consume-output-auth-google
    type: consume
    topic: output-topic
    parameters:
      - session-id
    authentication:
      provider: google
      configuration:
        clientId: "{{ secrets.google.client-id }}"
    consume-options:
      filters:
        headers:
          - key: subject
            value-from-authentication: subject
          - key: session-id
            value-from-parameters: session-id
  • In the CLI you can connect to a chat gateway just by adding the id
langstream  gateway chat app chat -c TOKEN 

All the required parameters will be automatically generated by the CLI (UUID).

@eolivelli eolivelli merged commit d3555c8 into main Sep 14, 2023
8 checks passed
@eolivelli eolivelli deleted the chat-gw branch September 14, 2023 06:56
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants