Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- uses: actions/setup-python@v6
id: setup-python
with:
python-version: "3.9.25"
python-version: "3.11.14"

# ---- Install uv ----
- name: Install uv
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.9"
python-version: "3.11"

- name: Install uv
run: |
Expand Down
6 changes: 3 additions & 3 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

# Installation Guide

1. Create an environment with Python `3.9` or higher, using `pyenv` or `conda`.
1. Create an environment with Python `3.11` or higher, using `pyenv` or `conda`.
* For `pyenv`, use the following commands:
```bash
brew install pyenv
pyenv install 3.9
pyenv local 3.9
pyenv install 3.11
pyenv local 3.11
```
* To set up your PATH automatically every time you open a shell session, add this to your .zshrc file:
```bash
Expand Down
59 changes: 29 additions & 30 deletions docs/library/sygra_library.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The **SyGra Library** provides a high-level Python interface for building and ex

## Installation

Requirements: Python 3.9-3.11 recommended. We also recommend upgrading `pip` first.
Requirements: Python 3.11-3.13 recommended. We also recommend upgrading `pip` first.

**Install from PyPI**
```bash
Expand Down Expand Up @@ -117,7 +117,7 @@ workflow.llm("gpt-4o", "Summarize: {text}")
```python
workflow.llm(
model={
"name": "gpt-4o",
"name": "gpt-4o",
"parameters": {"temperature": 0.7, "max_tokens": 2000}
},
prompt=[
Expand Down Expand Up @@ -180,8 +180,8 @@ class TextProcessor(LambdaFunction):
def apply(lambda_node_dict: dict, state: SygraState):
text = state.get("text", "").strip().lower()
return {
**state,
"processed_text": text,
**state,
"processed_text": text,
"word_count": len(text.split())
}

Expand All @@ -205,11 +205,11 @@ workflow.lambda_func(extract_keywords, output="keywords")
class DataValidator:
def __init__(self, config):
self.config = config

def __call__(self, data):
score = len(data["text"]) / 100
return {
"quality_score": min(1.0, score),
"quality_score": min(1.0, score),
"is_valid": score > self.config["threshold"]
}

Expand Down Expand Up @@ -239,9 +239,9 @@ workflow = sygra.Workflow("existing_task") \

```python
workflow.override_model(
node_name="analyzer",
model_name="gpt-4o",
temperature=0.8,
node_name="analyzer",
model_name="gpt-4o",
temperature=0.8,
max_tokens=1500
)
```
Expand All @@ -250,9 +250,9 @@ workflow.override_model(

```python
workflow.override_prompt(
node_name="generator",
role="system",
content="You are a helpful assistant",
node_name="generator",
role="system",
content="You are a helpful assistant",
index=0
)
```
Expand All @@ -263,15 +263,15 @@ workflow.override_prompt(
# Override glaive_code_assistant task configuration
workflow = sygra.Workflow("examples/glaive_code_assistant") \
.override_prompt(
"generate_answer",
"user",
"Solve step by step: {question}",
"generate_answer",
"user",
"Solve step by step: {question}",
index=1
) \
.override_prompt(
"critique_answer",
"system",
"Be thorough in your code review",
"critique_answer",
"system",
"Be thorough in your code review",
index=0
) \
.override_model("generate_answer", "gpt-4o", temperature=0.2) \
Expand Down Expand Up @@ -342,17 +342,17 @@ class InputValidator(NodePreProcessor):
# Validate required fields
if "text" not in state or not state["text"]:
state["text"] = "[MISSING_TEXT]"

# Add metadata
state["validated"] = True
state["timestamp"] = datetime.now().isoformat()

return state

# Use in workflow
workflow.llm(
"gpt-4o",
"Process: {text}",
"gpt-4o",
"Process: {text}",
pre_process=InputValidator
)
```
Expand All @@ -367,7 +367,7 @@ from sygra.core.graph.functions.node_processor import NodePostProcessor
class ResponseFormatter(NodePostProcessor):
def apply(self, response: SygraMessage) -> SygraState:
content = response.message.content

return {
"formatted_response": content.strip(),
"response_length": len(content),
Expand All @@ -377,8 +377,8 @@ class ResponseFormatter(NodePostProcessor):

# Use in workflow
workflow.llm(
"gpt-4o",
"Analyze: {text}",
"gpt-4o",
"Analyze: {text}",
post_process=ResponseFormatter
)
```
Expand All @@ -394,17 +394,17 @@ class QualityAnalyzer(NodePostProcessorWithState):
def apply(self, response: SygraMessage, state: SygraState) -> SygraState:
content = response.message.content
original_text = state.get("text", "")

# Calculate quality metrics
quality_score = self._calculate_quality(original_text, content)

return {
**state, # Preserve original state
"processed_response": content,
"quality_score": quality_score,
"is_high_quality": quality_score > 0.7
}

def _calculate_quality(self, original, response):
# Your quality calculation logic
return 0.85
Expand Down Expand Up @@ -531,7 +531,7 @@ workflow = sygra.Workflow("research_assistant") \
) \
.multi_llm(
models={
"summarizer": "gpt-4o",
"summarizer": "gpt-4o",
"reviewer": "claude-3-sonnet"
},
prompt="Synthesize research findings: {messages}"
Expand All @@ -551,4 +551,3 @@ workflow = sygra.Workflow("research_assistant") \
| `workflow.run()` | `List[Dict]` or `Any` | Processed results |
| `graph.build()` | `ExecutableGraph` | Built graph object |
| `graph.run()` | `List[Dict]` or `Any` | Execution results |

16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "sygra"
version = "1.0.0"
description = "Graph-oriented Synthetic data generation Pipeline library"
readme = "README.md"
requires-python = ">=3.9,<3.12,!=3.9.7"
requires-python = ">=3.11,<3.14"
authors = [{ name = "Bidyapati Pradhan, Surajit Dasgupta, Amit Kumar Saha, Sriram Puttagunta, Omkar Anustoop, Vipul Mittal, Gopal Sarda", email = "[email protected]" }]
maintainers = [
{ name = "SyGra Team", email = "[email protected]" }
Expand All @@ -20,9 +20,9 @@ classifiers = [
"Topic :: Software Development :: Libraries",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Operating System :: OS Independent",
]
keywords = ["llm", "fine-tuning", "data generation", "synthetic data", "nlp", "sft", "dpo", "data quality", "metadata tagging", "graph",]
Expand Down Expand Up @@ -51,22 +51,22 @@ dependencies = [
"langchain-openai>=0.3,<1.0",
"ollama>=0.5,<1.0",
"torch>=2.8,<3.0",
"mlxtend>=0.23,<1.0",
"mlxtend>=0.24,<1.0",
"pandarallel>=1.6,<2.0",
"sentence-transformers>=5.1,<6.0",
"soundfile>=0.13,<1.0",
"types-pyyaml>=6.0,<7.0",
"fasttext-wheel>=0.9.2,<0.10.0",
"litellm>=1.79.3,<2.0.0",
"pysnc>=1.1.0,<1.2.0",
"boto3>=1.40.71,<2.0.0",
"litellm>=1.80.11,<2.0.0",
"pysnc>=1.2.0,<2.0.0",
"boto3>=1.34,<2.0.0",
"google-auth>=2.43.0,<3.0.0",
"google-cloud-aiplatform>=1.128.0,<2.0.0",
]

[project.optional-dependencies]
ui = [
"streamlit>=1.49,<2.0; python_version != '3.9.7'",
"streamlit>=1.49,<2.0",
"streamlit-agraph>=0.0,<1.0",
"streamlit-autorefresh>=1.0,<2.0",
"streamlit-flow-component>=1.6,<2.0",
Expand Down
Loading