Skip to content

Commit bcc3fc3

Browse files
committed
feat: Add created_at stamp for chat messages to allow agents and conversational app to reason over current time
1 parent 6f8b038 commit bcc3fc3

29 files changed

+236
-92
lines changed

coverage-badge.svg

Lines changed: 1 addition & 1 deletion
Loading

examples/16_sql_agent.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ class Query(synalinks.DataModel):
309309

310310
class SQLResult(synalinks.DataModel):
311311
"""The result of the SQL agent's analysis."""
312+
312313
answer: str = synalinks.Field(
313314
description="A clear, natural language answer to the user's question"
314315
)
@@ -454,10 +455,7 @@ async def populate_knowledge_base(kb):
454455
# Sample customers
455456
customers = [
456457
Customer(
457-
id="C001",
458-
name="Alice Johnson",
459-
email="alice@example.com",
460-
country="USA"
458+
id="C001", name="Alice Johnson", email="alice@example.com", country="USA"
461459
),
462460
Customer(
463461
id="C002",
@@ -537,7 +535,7 @@ async def populate_knowledge_base(kb):
537535
stock=120,
538536
),
539537
Product(
540-
id="P008",
538+
id="P008",
541539
name="Notebook Set",
542540
category="Office",
543541
price=12.99,
@@ -738,7 +736,9 @@ async def main():
738736
tool_calls_count += 1
739737
args = tool_call.get("arguments", {})
740738
args_str = ", ".join(f"{k}={repr(v)}" for k, v in args.items())
741-
print(f"Tool Call {tool_calls_count}: {tool_call['name']}({args_str})")
739+
print(
740+
f"Tool Call {tool_calls_count}: {tool_call['name']}({args_str})"
741+
)
742742
elif msg.get("role") == "tool":
743743
content = msg.get("content", "")
744744
# Truncate long results for readability

examples/7_reward_metrics_and_optimizers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
## Understanding Rewards
55
66
`Reward`s are an essential part of reinforcement learning frameworks.
7-
They are scalar values (between 0.0 and 1.0 for synalinks)
7+
They are scalar values (between 0.0 and 1.0 for synalinks)
88
that guide the process into making more efficient decisions or
99
predictions. During training, the goal is to maximize the reward function.
1010
The reward gives the system an indication of how well it performed for that task.

guides/10_output_guard.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ async def main():
202202

203203
import synalinks
204204

205-
206205
# =============================================================================
207206
# Data Models
208207
# =============================================================================
@@ -331,7 +330,7 @@ async def main():
331330
print("=" * 60)
332331

333332
result = await program(Query(query="What is the capital of France?"))
334-
print(f"\nQuery: 'What is the capital of France?'")
333+
print("\nQuery: 'What is the capital of France?'")
335334
print(f"Result: {result.get_json()}")
336335

337336
# -------------------------------------------------------------------------
@@ -342,7 +341,7 @@ async def main():
342341
print("=" * 60)
343342

344343
result = await program(Query(query="Explain what Python is used for"))
345-
print(f"\nQuery: 'Explain what Python is used for'")
344+
print("\nQuery: 'Explain what Python is used for'")
346345
print(f"Result: {result.get_json()}")
347346

348347
# -------------------------------------------------------------------------

guides/1_getting_started.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,8 @@ class Question(synalinks.DataModel):
246246
class Answer(synalinks.DataModel):
247247
"""Output: An answer with reasoning."""
248248

249-
thinking: str = synalinks.Field(
250-
description="Your step-by-step reasoning process"
251-
)
252-
answer: str = synalinks.Field(
253-
description="The final answer based on your reasoning"
254-
)
249+
thinking: str = synalinks.Field(description="Your step-by-step reasoning process")
250+
answer: str = synalinks.Field(description="The final answer based on your reasoning")
255251

256252

257253
async def main():

guides/2_data_models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ class MovieReview(synalinks.DataModel):
108108
109109
### Using Enums for Constrained Outputs
110110
111-
When you need the LLM to choose from specific options, use Python Enums (similar to the Literal above):
111+
When you need the LLM to choose from specific options,
112+
use Python Enums (similar to the Literal above):
112113
113114
```python
114115
from enum import Enum

guides/3_programs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ async def build(self, inputs: synalinks.SymbolicDataModel) -> None:
330330

331331
import synalinks
332332

333-
334333
# =============================================================================
335334
# Data Models
336335
# =============================================================================

guides/6_knowledge_base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ async def main():
345345

346346
import synalinks
347347

348-
349348
# =============================================================================
350349
# Data Models
351350
# =============================================================================

guides/7_training.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,10 @@ async def main():
249249
(MathProblem(problem="5 * 4"), MathAnswer(thinking="5 * 4 = 20", answer="20")),
250250
(MathProblem(problem="10 - 3"), MathAnswer(thinking="10 - 3 = 7", answer="7")),
251251
(MathProblem(problem="8 / 2"), MathAnswer(thinking="8 / 2 = 4", answer="4")),
252-
(MathProblem(problem="3 + 3 + 3"), MathAnswer(thinking="3 + 3 + 3 = 9", answer="9")),
252+
(
253+
MathProblem(problem="3 + 3 + 3"),
254+
MathAnswer(thinking="3 + 3 + 3 = 9", answer="9"),
255+
),
253256
(MathProblem(problem="7 * 2"), MathAnswer(thinking="7 * 2 = 14", answer="14")),
254257
]
255258
@@ -398,7 +401,6 @@ async def main():
398401

399402
import synalinks
400403

401-
402404
# =============================================================================
403405
# Data Models
404406
# =============================================================================
@@ -478,7 +480,7 @@ async def main():
478480
],
479481
dtype="object",
480482
)
481-
y_test = np.array(
483+
_y_test = np.array( # noqa: F841
482484
[
483485
MathAnswer(thinking="4 + 5 = 9", answer="9"),
484486
MathAnswer(thinking="6 * 3 = 18", answer="18"),

guides/8_observability.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ async def main():
308308

309309
import synalinks
310310

311-
312311
# =============================================================================
313312
# Data Models
314313
# =============================================================================

0 commit comments

Comments
 (0)