Skip to content

Commit b52d756

Browse files
authored
Merge pull request #54 from WorkflowAI/guillaume/update-deps
Update dependencies
2 parents 90b5c4c + 0d09dd4 commit b52d756

23 files changed

+288
-248
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ class FeedbackPoint(BaseModel):
105105
# Model representing the structured analysis of the customer feedback call
106106
class CallFeedbackOutput(BaseModel):
107107
"""Structured analysis of the customer feedback call."""
108-
positive_points: List[FeedbackPoint] = Field(
108+
positive_points: list[FeedbackPoint] = Field(
109109
default_factory=list,
110110
description="List of positive feedback points, each with a supporting quote."
111111
)
112-
negative_points: List[FeedbackPoint] = Field(
112+
negative_points: list[FeedbackPoint] = Field(
113113
default_factory=list,
114114
description="List of negative feedback points, each with a supporting quote."
115115
)
@@ -267,7 +267,6 @@ async for chunk in analyze_call_feedback(feedback_input):
267267
> For example, a function with the signature `async def foo() -> AsyncIterator[int]` may be called
268268
> `async for c in await foo():...` in certain cases...
269269
270-
271270
#### Streaming the run object
272271

273272
Use `AsyncIterator[Run[Output]]` to get the **run** object as it is generated, which allows you, for the **last chunk**, to access the cost and duration of the run.
@@ -331,7 +330,7 @@ class PDFQuestionInput(BaseModel):
331330

332331
class PDFAnswerOutput(BaseModel):
333332
answer: str = Field(description="The answer to the question based on the PDF content")
334-
quotes: List[str] = Field(description="Relevant quotes from the PDF that support the answer")
333+
quotes: list[str] = Field(description="Relevant quotes from the PDF that support the answer")
335334

336335
@workflowai.agent(id="pdf-answer", model=Model.CLAUDE_3_5_SONNET_LATEST)
337336
async def answer_pdf_question(input: PDFQuestionInput) -> PDFAnswerOutput:
@@ -610,8 +609,8 @@ values.
610609

611610
```python
612611
class CallFeedbackOutputStrict(BaseModel):
613-
positive_points: List[FeedbackPoint]
614-
negative_points: List[FeedbackPoint]
612+
positive_points: list[FeedbackPoint]
613+
negative_points: list[FeedbackPoint]
615614

616615
@workflowai.agent()
617616
async def analyze_call_feedback_strict(input: CallFeedbackInput) -> CallFeedbackOutputStrict:
@@ -628,8 +627,8 @@ except WorkflowAIError as e:
628627
print(e.code) # "invalid_generation" error code means that the generation did not match the schema
629628

630629
class CallFeedbackOutputTolerant(BaseModel):
631-
positive_points: List[FeedbackPoint] = Field(default_factory=list)
632-
negative_points: List[FeedbackPoint] = Field(default_factory=list)
630+
positive_points: list[FeedbackPoint] = Field(default_factory=list)
631+
negative_points: list[FeedbackPoint] = Field(default_factory=list)
633632

634633
@workflowai.agent()
635634
async def analyze_call_feedback_tolerant(input: CallFeedbackInput) -> CallFeedbackOutputTolerant:

examples/08_pdf_agent.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import asyncio
22
import os
3-
from typing import List
43

54
from dotenv import load_dotenv
65
from pydantic import BaseModel, Field # pyright: ignore [reportUnknownVariableType]
@@ -18,7 +17,7 @@ class PDFQuestionInput(BaseModel):
1817

1918
class PDFAnswerOutput(BaseModel):
2019
answer: str = Field(description="The answer to the question based on the PDF content")
21-
quotes: List[str] = Field(description="Relevant quotes from the PDF that support the answer")
20+
quotes: list[str] = Field(description="Relevant quotes from the PDF that support the answer")
2221

2322

2423
@workflowai.agent(id="pdf-answer", model=Model.CLAUDE_3_5_SONNET_LATEST)

examples/11_ecommerce_chatbot.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import asyncio
1010
from enum import Enum
11-
from typing import List, Optional
11+
from typing import Optional
1212

1313
from pydantic import BaseModel, Field
1414

@@ -18,12 +18,14 @@
1818

1919
class Role(str, Enum):
2020
"""Enum representing possible message roles."""
21+
2122
USER = "user"
2223
ASSISTANT = "assistant"
2324

2425

2526
class Product(BaseModel):
2627
"""Model representing a product recommendation."""
28+
2729
name: str = Field(
2830
description="Name of the product",
2931
examples=["Wireless Noise-Cancelling Headphones", "4K Smart TV"],
@@ -56,6 +58,7 @@ class Product(BaseModel):
5658

5759
class Message(BaseModel):
5860
"""Model representing a chat message."""
61+
5962
role: Role = Field()
6063
content: str = Field(
6164
description="The content of the message",
@@ -64,28 +67,31 @@ class Message(BaseModel):
6467
"Based on your requirements, here are some great headphone options...",
6568
],
6669
)
67-
recommended_products: Optional[List[Product]] = Field(
70+
recommended_products: Optional[list[Product]] = Field(
6871
default=None,
6972
description="Product recommendations included with this message, if any",
7073
)
7174

7275

7376
class AssistantMessage(Message):
7477
"""Model representing a message from the assistant."""
78+
7579
role: Role = Role.ASSISTANT
7680
content: str = ""
7781

7882

7983
class ChatbotOutput(BaseModel):
8084
"""Output model for the chatbot response."""
85+
8186
assistant_message: AssistantMessage = Field(
8287
description="The chatbot's response message",
8388
)
8489

8590

8691
class ChatInput(BaseModel):
8792
"""Input model containing the user's message and conversation history."""
88-
conversation_history: Optional[List[Message]] = Field(
93+
94+
conversation_history: Optional[list[Message]] = Field(
8995
default=None,
9096
description="Previous messages in the conversation, if any",
9197
)

examples/13_rag.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import asyncio
1414
from enum import Enum
15-
from typing import List, Optional
15+
from typing import Optional
1616

1717
from pydantic import BaseModel, Field
1818

@@ -22,12 +22,14 @@
2222

2323
class Role(str, Enum):
2424
"""Enum representing possible message roles."""
25+
2526
USER = "user"
2627
ASSISTANT = "assistant"
2728

2829

2930
class SearchResult(BaseModel):
3031
"""Model representing a search result from the knowledge base."""
32+
3133
content: str = Field(
3234
description="The content of the search result",
3335
)
@@ -38,7 +40,7 @@ class SearchResult(BaseModel):
3840

3941
# Simulated knowledge base search tool
4042
# ruff: noqa: ARG001
41-
async def search_faq(query: str) -> List[SearchResult]:
43+
async def search_faq(query: str) -> list[SearchResult]:
4244
"""
4345
Search the knowledge base for relevant information.
4446
@@ -79,6 +81,7 @@ async def search_faq(query: str) -> List[SearchResult]:
7981

8082
class Message(BaseModel):
8183
"""Model representing a chat message."""
84+
8285
role: Role
8386
content: str = Field(
8487
description="The content of the message",
@@ -87,20 +90,24 @@ class Message(BaseModel):
8790

8891
class AssistantMessage(Message):
8992
"""Model representing a message from the assistant."""
93+
9094
role: Role = Role.ASSISTANT
9195
content: str = ""
9296

9397

9498
class ChatbotOutput(BaseModel):
9599
"""Output model for the chatbot response."""
96-
assistant_message: AssistantMessage = Field(default_factory=AssistantMessage,
100+
101+
assistant_message: AssistantMessage = Field(
102+
default_factory=AssistantMessage,
97103
description="The chatbot's response message",
98104
)
99105

100106

101107
class ChatInput(BaseModel):
102108
"""Input model containing the user's message and conversation history."""
103-
conversation_history: Optional[List[Message]] = Field(
109+
110+
conversation_history: Optional[list[Message]] = Field(
104111
default=None,
105112
description="Previous messages in the conversation, if any",
106113
)

examples/workflows/chain_of_agents.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"""
1717

1818
import asyncio
19-
from typing import List
2019

2120
from pydantic import BaseModel, Field # pyright: ignore [reportUnknownVariableType]
2221

@@ -47,7 +46,7 @@ class WorkerOutput(BaseModel):
4746
findings: str = Field(
4847
description="Key findings and information extracted from this chunk.",
4948
)
50-
evidence: List[str] = Field(
49+
evidence: list[str] = Field(
5150
default_factory=list,
5251
description="Supporting evidence or quotes from the chunk.",
5352
)
@@ -70,7 +69,7 @@ class ManagerOutput(BaseModel):
7069

7170
answer: str = Field(description="The final answer to the query.")
7271
reasoning: str = Field(description="Explanation of how the answer was derived.")
73-
supporting_evidence: List[str] = Field(
72+
supporting_evidence: list[str] = Field(
7473
default_factory=list,
7574
description="Key evidence supporting the answer.",
7675
)

examples/workflows/evaluator_optimizer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import asyncio
2-
from typing import List, TypedDict
2+
from typing import TypedDict
33

44
from pydantic import BaseModel, Field # pyright: ignore [reportUnknownVariableType]
55

@@ -45,8 +45,8 @@ class TranslationEvaluationOutput(BaseModel):
4545
preserves_tone: bool = Field(description="Whether the translation preserves the original tone.")
4646
preserves_nuance: bool = Field(description="Whether the translation preserves subtle nuances.")
4747
culturally_accurate: bool = Field(description="Whether the translation is culturally appropriate.")
48-
specific_issues: List[str] = Field(description="List of specific issues identified.")
49-
improvement_suggestions: List[str] = Field(description="List of suggested improvements.")
48+
specific_issues: list[str] = Field(description="List of specific issues identified.")
49+
improvement_suggestions: list[str] = Field(description="List of suggested improvements.")
5050

5151

5252
# Uses O1 for its strong analytical and evaluation capabilities
@@ -65,8 +65,8 @@ class TranslationImprovementInput(BaseModel):
6565
original_text: str = Field(description="The original text.")
6666
current_translation: str = Field(description="The current translation.")
6767
target_language: str = Field(description="The target language.")
68-
specific_issues: List[str] = Field(description="Issues to address.")
69-
improvement_suggestions: List[str] = Field(description="Suggestions for improvement.")
68+
specific_issues: list[str] = Field(description="Issues to address.")
69+
improvement_suggestions: list[str] = Field(description="Suggestions for improvement.")
7070

7171

7272
class TranslationImprovementOutput(BaseModel):

examples/workflows/orchestrator_worker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
from enum import Enum
3-
from typing import List, TypedDict
3+
from typing import TypedDict
44

55
from pydantic import BaseModel, Field # pyright: ignore [reportUnknownVariableType]
66

@@ -37,7 +37,7 @@ class ImplementationPlanInput(BaseModel):
3737
class ImplementationPlanOutput(BaseModel):
3838
"""Output containing the implementation plan."""
3939

40-
files: List[FileChange] = Field(description="List of files to be changed.")
40+
files: list[FileChange] = Field(description="List of files to be changed.")
4141
estimated_complexity: ComplexityLevel = Field(description="Estimated complexity of the implementation.")
4242

4343

@@ -86,7 +86,7 @@ class ImplementationChange(TypedDict):
8686

8787
class FeatureImplementationResult(TypedDict):
8888
plan: ImplementationPlanOutput
89-
changes: List[ImplementationChange]
89+
changes: list[ImplementationChange]
9090

9191

9292
async def implement_feature(feature_request: str) -> FeatureImplementationResult:
@@ -117,7 +117,7 @@ async def implement_feature(feature_request: str) -> FeatureImplementationResult
117117
)
118118

119119
# Combine results
120-
changes: List[ImplementationChange] = [
120+
changes: list[ImplementationChange] = [
121121
{
122122
"file": implementation_plan.files[i],
123123
"implementation": change,

examples/workflows/parallel_processing.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
from enum import Enum
3-
from typing import List, TypedDict
3+
from typing import TypedDict
44

55
from pydantic import BaseModel, Field # pyright: ignore [reportUnknownVariableType]
66

@@ -23,9 +23,9 @@ class SecurityReviewInput(BaseModel):
2323
class SecurityReviewOutput(BaseModel):
2424
"""Output from security code review."""
2525

26-
vulnerabilities: List[str] = Field(description="List of identified security vulnerabilities.")
26+
vulnerabilities: list[str] = Field(description="List of identified security vulnerabilities.")
2727
risk_level: RiskLevel = Field(description="Overall security risk level.")
28-
suggestions: List[str] = Field(description="Security improvement suggestions.")
28+
suggestions: list[str] = Field(description="Security improvement suggestions.")
2929

3030

3131
# Uses Claude 3.5 Sonnet for its strong security analysis capabilities
@@ -47,9 +47,9 @@ class PerformanceReviewInput(BaseModel):
4747
class PerformanceReviewOutput(BaseModel):
4848
"""Output from performance code review."""
4949

50-
issues: List[str] = Field(description="List of identified performance issues.")
50+
issues: list[str] = Field(description="List of identified performance issues.")
5151
impact: RiskLevel = Field(description="Impact level of performance issues.")
52-
optimizations: List[str] = Field(description="Performance optimization suggestions.")
52+
optimizations: list[str] = Field(description="Performance optimization suggestions.")
5353

5454

5555
# Uses O1 Mini for its expertise in performance optimization
@@ -71,9 +71,9 @@ class MaintainabilityReviewInput(BaseModel):
7171
class MaintainabilityReviewOutput(BaseModel):
7272
"""Output from maintainability code review."""
7373

74-
concerns: List[str] = Field(description="List of maintainability concerns.")
74+
concerns: list[str] = Field(description="List of maintainability concerns.")
7575
quality_score: int = Field(description="Code quality score (1-10).", ge=1, le=10)
76-
recommendations: List[str] = Field(description="Maintainability improvement recommendations.")
76+
recommendations: list[str] = Field(description="Maintainability improvement recommendations.")
7777

7878

7979
# Uses Claude 3.5 Sonnet for its strong code quality and readability analysis

0 commit comments

Comments
 (0)