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

[python] Add new agent type python-service #665

Merged
merged 21 commits into from
Oct 30, 2023
Merged

Conversation

eolivelli
Copy link
Member

@eolivelli eolivelli commented Oct 29, 2023

Summary:

  • add a new component type "SERVICE"
  • a Service doesn't use streaming to interact with external services
  • the service is supposed to open some port on the pod and serve an HTTP service (no need to support TLS at the moment)
  • initially this port is fixed and it must be 8000, in the future we can make it configurable
  • add a new agent "python-service" that allows you to deploy a python application without consuming from a topic or producing messages
  • add LangServe, FastAPI and Uvicorn to the bundled Python libraries

when you are running in docker the auto-reload feature works out of the box, as soon as you change your Python files the Python daemon is restarted

It is expected that the langstream gateway will act as a proxy to the service, adding:

  • TLS support for public networks
  • Authentication

Running Python application on Kubernetes

LangStream agents are already deployed as a StatefulSet (with persistent disks) and an headless Service.
Deploying an application here allows you to easily leverage all the Kubernetes features, for instance:

  • resource management (you can set set size of the machines, CPU, memory...)
  • scalability (you can set the number of replicats)
  • region awareness
  • ...

Bonus feature added by this PR:

When you declare a Python agent you can easily pass environment variables from secrets:

module: default
name: "Basic LangServe application"
pipeline:
  - name: "Start LangServe"
    id: agent1
    type: "python-service"
    configuration:
      className: example.ChatBotService
      environment:
        - key: "OPENAI_API_KEY"
          value: "${secrets.open-ai.access-key}"
        - key: "LANGCHAIN_TRACING_V2"
          value: "true"
        - key: "LANGCHAIN_ENDPOINT"
          value: "${ secrets.lang-smith.api-url }"
        - key: "LANGCHAIN_API_KEY"
          value: "${ secrets.lang-smith.api-key }"          

This PR adds a sample application about how to integrate also with LangSmith
image

@eolivelli eolivelli changed the title [python] Add new agent type python-service [python] Add new agent type python-service and add support for running LangServe applications Oct 30, 2023
@eolivelli eolivelli marked this pull request as ready for review October 30, 2023 11:14
docker/build.sh Outdated
clean_cmd=""
if [ "$clean" == "true" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

please revert, this was done on purpose, on some modules is better to clean before building

Copy link
Member Author

Choose a reason for hiding this comment

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

reverted

new ContainerPortBuilder().withName("http").withContainerPort(8080).build();

final ContainerPort portCustomServiceHttp =
Copy link
Member

Choose a reason for hiding this comment

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

always ? shouldn't we do it only if the application has a python-service ?

Copy link
Member Author

Choose a reason for hiding this comment

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

we have to tweak the CRD (again) in order to do it.
I am not sure it is worth.

a note:
it is not only for "python-service" but for any agent with componentType=SERVICE.

@eolivelli eolivelli merged commit 7ac2dec into main Oct 30, 2023
9 of 10 checks passed
@eolivelli eolivelli deleted the impl/python-services branch October 30, 2023 13:09
@eolivelli eolivelli changed the title [python] Add new agent type python-service and add support for running LangServe applications [python] Add new agent type python-service Oct 31, 2023
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

2 participants