Skip to content

Commit

Permalink
resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
alimosaed committed Oct 22, 2024
2 parents ec6944c + 22632a4 commit 75e25c0
Show file tree
Hide file tree
Showing 20 changed files with 934 additions and 118 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ Contributions are encouraged! Please read [CONTRIBUTING](CONTRIBUTING.md) for de

## License

See the LICENSE file for details.
See the [LICENSE](LICENSE) file for details.
16 changes: 13 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,24 @@ A flow is an instance of a pipeline that processes events in a sequential manner

Flows can be communicating together if programmed to do so. For example, a flow can send a message to a broker and another flow can subscribe to the same topic to receive the message.

flows can be spread across multiple configuration files. The connector will merge the flows from all the files and run them together.
Flows can be spread across multiple configuration files. The connector will merge the flows from all the files and run them together.

The `flows` section is a list of flow configurations. Each flow configuration is a dictionary with the
following keys:

- `name`: <string> - The unique name of the flow
- `components`: A list of component configurations. Check [Component Configuration](#component-configuration) for more details

```yaml
flows:
- name: <flow name>
components:
- component_name: <component name>
- name: <flow name>
components:
- component_name: <component name>
```

## Message Data

Between each component in a flow, a message is passed. This message is a dictionary that is used to pass data between components within the same flow. The message object has different properties, some are available throughout the whole flow, some only between two immediate components, and some have other characteristics.
Expand All @@ -153,7 +163,7 @@ This data type is available only after a topic subscription and then it will be

- `previous`: The complete output of the previous component in the flow. This can be used to completely forward the output of the previous component as an input to the next component or be modified in the `input_transforms` section of the next component.

- transform specific variables: Some transforms function will add specific variables to the message object that are ONLY accessible in that transform. For example, the [`map` transform](./transforms/map.md) will add `item`, `index`, and `source_list` to the message object or the [`reduce` transform](./transforms/reduce.md) will add `accumulated_value`, `current_value`, and `source_list` to the message object. You can find these details in each transform documentation.
- Transform specific variables: Some transforms function will add specific variables to the message object that are ONLY accessible in that transform. For example, the [`map` transform](./transforms/map.md) will add `item`, `index`, and `source_list` to the message object or the [`reduce` transform](./transforms/reduce.md) will add `accumulated_value`, `current_value`, and `source_list` to the message object. You can find these details in each [transform](transforms/index.md) documentation.

## Expression Syntax

Expand Down Expand Up @@ -601,4 +611,4 @@ You can find various usecase examples in the [examples directory](../examples/)

---

Checkout [components.md](./components/index.md), [transforms.md](./transforms/index.md), or [tips_and_tricks](tips_and_tricks.md) next.
Checkout [components](./components/index.md), [transforms](./transforms/index.md), or [tips_and_tricks](tips_and_tricks.md) next.
26 changes: 17 additions & 9 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ To get started with creating a solace PubSub+ event broker follow the instructio

### Install the connector

Optionally create a virtual environment:
(Optional) Create a virtual environment:

```sh
python3 -m venv env
source env/bin/activate
```

Set up the connector package
```sh
pip install solace-ai-connector
```
Expand Down Expand Up @@ -53,6 +54,12 @@ export SOLACE_BROKER_PASSWORD=default
export SOLACE_BROKER_VPN=default
```

(Optional) Store the environment variables permanently in ~/.profile file and activate them by:

```sh
source ~/.profile
```

Run the connector:

```sh
Expand Down Expand Up @@ -83,10 +90,9 @@ export OPENAI_API_ENDPOINT=<base url of your OpenAI endpoint>
export MODEL_NAME=<model name>
```

Note that if you want to use the default OpenAI endpoint, just delete that line from the openai_chat.yaml file.
Note that if you want to use the default OpenAI endpoint, just delete that line from the langchain_openai_with_history_chat.yaml file.

Install the langchain openai dependencies:

```sh
pip install langchain_openai openai
```
Expand All @@ -113,7 +119,7 @@ Payload:
In the "Try Me!" also subscribe to `demo/joke/subject/response` to see the response


## Installation
## Running From Source Code


1. Clone the repository and enter its directory:
Expand All @@ -123,7 +129,7 @@ In the "Try Me!" also subscribe to `demo/joke/subject/response` to see the respo
cd solace-ai-connector
```

2. Optionally create a virtual environment:
2. (Optional) Create a virtual environment:

```sh
python -m venv .venv
Expand All @@ -136,11 +142,13 @@ In the "Try Me!" also subscribe to `demo/joke/subject/response` to see the respo
pip install -r requirements.txt
```

## Configuration
### Configuration

1. Edit the example configuration file at the root of the repository:
1. (Optional) Edit the example configuration file at the root of the repository:

```sh
config.yaml
```

2. Set up the environment variables that you need for the config.yaml file. The default one requires the following variables:

Expand All @@ -152,7 +160,7 @@ In the "Try Me!" also subscribe to `demo/joke/subject/response` to see the respo
```


## Running the AI Event Connector
### Running the AI Event Connector

1. Start the AI Event Connector:

Expand All @@ -176,4 +184,4 @@ make build

---

Checkout [configuration.md](configuration.md) or [overview.md](overview.md) next
Checkout [configuration](configuration.md) or [overview](overview.md) next
42 changes: 42 additions & 0 deletions examples/websocket/websocket.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# Example configuration for a WebSocket flow
# This flow creates a WebSocket server that echoes messages back to clients
# It also serves an example HTML file for easy testing

log:
stdout_log_level: INFO
log_file_level: DEBUG
log_file: solace_ai_connector.log

flows:
- name: websocket_echo
components:
# WebSocket Input
- component_name: websocket_input
component_module: websocket_input
component_config:
listen_port: 5000
serve_html: true
html_path: "examples/websocket/websocket_example_app.html"

# Pass Through
- component_name: pass_through
component_module: pass_through
component_config: {}
input_transforms:
- type: copy
source_expression: input.payload
dest_expression: user_data.input:payload
- type: copy
source_expression: input.user_properties:socket_id
dest_expression: user_data.input:socket_id
input_selection:
source_expression: user_data.input

# WebSocket Output
- component_name: websocket_output
component_module: websocket_output
component_config:
payload_encoding: none
input_selection:
source_expression: previous
Loading

0 comments on commit 75e25c0

Please sign in to comment.