Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,59 @@ output = client.run_flow(
print(output)
```

## Run a Flow with Tweet Data

Gumloop flow inputs can include lists and nested objects. This example loads a
[TweetClaw](https://github.com/Xquik-dev/tweetclaw) JSON export and passes the
tweet text into a flow for enrichment, routing, or review:

```python
import json
from pathlib import Path

from gumloop import GumloopClient


def load_tweet_text(path: str) -> list[str]:
records = json.loads(Path(path).read_text(encoding="utf-8"))
if isinstance(records, dict):
if "tweets" in records:
tweets = records["tweets"]
elif "data" in records:
tweets = records["data"]
elif "results" in records:
tweets = records["results"]
else:
tweets = [records]
else:
tweets = records

if not isinstance(tweets, list):
return []

return [
item["text"]
for item in tweets
if isinstance(item, dict) and isinstance(item.get("text"), str)
]


client = GumloopClient(
api_key="your_api_key",
user_id="your_user_id",
)

output = client.run_flow(
flow_id="your_flow_id",
inputs={
"tweets": load_tweet_text("tweetclaw-export.json"),
"source": "TweetClaw",
},
)

print(output)
```

## Chat with an agent (streaming)

```python
Expand Down