Skip to content

Commit

Permalink
refactor: Fix Dart 3.1.0 linter issues (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmigloz authored Aug 18, 2023
1 parent ea090dc commit cc32f3f
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
uses: subosito/flutter-action@ed388baf1d5404fd6ef3c54c2f82e6159150b60f
with:
channel: 'stable'
flutter-version: '3.13.0'
cache: true

- name: Set-up Flutter
Expand Down
4 changes: 2 additions & 2 deletions packages/langchain/lib/src/agents/executors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class AgentExecutor extends BaseChain {
final List<AgentStep> intermediateSteps = [];

// Construct a mapping of tool name to tool for easy lookup
final nameToToolMap = {for (var tool in _internalTools) tool.name: tool};
final nameToToolMap = {for (final tool in _internalTools) tool.name: tool};

// Let's start tracking the number of iterations and time elapsed
int iterations = 0;
Expand Down Expand Up @@ -185,7 +185,7 @@ class AgentExecutor extends BaseChain {
tool: ExceptionTool.toolName,
toolInput: {Tool.inputVar: handleParsingErrors!(e)},
log: e.toString(),
)
),
];
}

Expand Down
2 changes: 1 addition & 1 deletion packages/langchain/lib/src/chains/sequential.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class SequentialChain extends BaseChain {
...?memory?.memoryKeys,
for (final chain in chains) ...{
...chain.outputKeys,
...?memory?.memoryKeys
...?memory?.memoryKeys,
},
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/langchain/lib/src/memory/vector_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class VectorStoreRetrieverMemory implements BaseMemory {
final excludeKeys = {memoryKey, ...excludeInputKeys};
final filteredInputs = {
for (final entry in inputValues.entries)
if (!excludeKeys.contains(entry.key)) entry.key: entry.value
if (!excludeKeys.contains(entry.key)) entry.key: entry.value,
};
final inputsOutputs = {...filteredInputs, ...outputValues};
final pageContent = inputsOutputs.entries.map((final entry) {
Expand Down
10 changes: 5 additions & 5 deletions packages/langchain/test/agents/executors_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void main() {
AgentAction(
tool: tool.name,
toolInput: {Tool.inputVar: 'mock'},
)
),
],
);
final executor = AgentExecutor(
Expand All @@ -33,7 +33,7 @@ void main() {
AgentAction(
tool: tool.name,
toolInput: {Tool.inputVar: 'mock'},
)
),
],
);
final executor = AgentExecutor(
Expand All @@ -55,7 +55,7 @@ void main() {
),
const AgentFinish(
returnValues: {BaseActionAgent.agentReturnKey: 'mock'},
)
),
],
);
final executor = AgentExecutor(agent: agent);
Expand All @@ -71,7 +71,7 @@ void main() {
const AgentAction(
tool: 'tool',
toolInput: {Tool.inputVar: 'mock'},
)
),
],
);
final executor = AgentExecutor(
Expand Down Expand Up @@ -99,7 +99,7 @@ void main() {
const AgentAction(
tool: 'invalid_tool',
toolInput: {Tool.inputVar: 'mock'},
)
),
],
);
final executor = AgentExecutor(
Expand Down
10 changes: 5 additions & 5 deletions packages/langchain/test/documents/vector_stores/memory_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,7 @@ final _helloVector = [
0.0023811953,
-0.016299868,
-0.0050565284,
-0.006120713
-0.006120713,
];
final _hiVector = [
-0.035099167,
Expand Down Expand Up @@ -3156,7 +3156,7 @@ final _hiVector = [
0.014291876,
-0.011592446,
-0.000933471,
0.004673102
0.004673102,
];
final _byeVector = [
-0.0084679825,
Expand Down Expand Up @@ -4694,7 +4694,7 @@ final _byeVector = [
0.0074337246,
-0.026218424,
0.007129912,
-0.025584942
-0.025584942,
];
final _whatsThisVector = [
-0.01297786,
Expand Down Expand Up @@ -6232,7 +6232,7 @@ final _whatsThisVector = [
-0.028123155,
-0.013459512,
-0.014369301,
-0.01910555
-0.01910555,
];
final _chaoVector = [
0.014674897,
Expand Down Expand Up @@ -7770,5 +7770,5 @@ final _chaoVector = [
-0.0033553813,
-0.0019796097,
-0.0054214867,
-0.00085516524
-0.00085516524,
];
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void main() {
test('Test SimpleMessagePromptTemplate', () {
const prompt = MessagesPlaceholder(variableName: 'foo');
final values = {
'foo': [ChatMessage.human("Hello Foo, I'm Bar")]
'foo': [ChatMessage.human("Hello Foo, I'm Bar")],
};
final messages = prompt.formatMessages(values);
expect(messages, [ChatMessage.human("Hello Foo, I'm Bar")]);
Expand Down
4 changes: 2 additions & 2 deletions packages/langchain/test/model_io/prompts/template_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() {
('{{pre{foo}post}}', {'foo': 'bar'}, '{prebarpost}'),
('text', {}, 'text'),
('}}{{', {}, '}{'),
('{first}_{second}', {'first': 'foo', 'second': 'bar'}, 'foo_bar')
('{first}_{second}', {'first': 'foo', 'second': 'bar'}, 'foo_bar'),
];

for (final scenario in scenarios) {
Expand All @@ -30,7 +30,7 @@ void main() {
('{', {}),
('}', {}),
('{foo', {}),
('foo}', {})
('foo}', {}),
];

for (final scenario in scenarios) {
Expand Down
2 changes: 1 addition & 1 deletion packages/langchain_openai/lib/src/agents/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class OpenAIFunctionsAgent extends BaseSingleActionAgent {
ChatMessage.function(
name: s.action.tool,
content: s.observation,
)
),
];
}).expand((final m) => m),
];
Expand Down
4 changes: 2 additions & 2 deletions packages/langchain_openai/lib/src/chains/qa_with_sources.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ class OpenAIQAWithSourcesChain extends OpenAIQAWithStructureChain {
'type': 'array',
'items': {'type': 'string'},
'description': 'The sources used to answer the question',
}
},
},
'required': ['answer', 'sources']
'required': ['answer', 'sources'],
},
),
outputParser: const QAWithSourcesOutputParser(),
Expand Down
10 changes: 5 additions & 5 deletions packages/langchain_openai/test/chat_models/openai_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ void main() {
'properties': {
'location': {
'type': 'string',
'description': 'The city and state, e.g. San Francisco, CA'
'description': 'The city and state, e.g. San Francisco, CA',
},
'unit': {
'type': 'string',
'description': 'The unit of temperature to return',
'enum': ['celsius', 'fahrenheit']
}
'enum': ['celsius', 'fahrenheit'],
},
},
'required': ['location']
'required': ['location'],
},
);

Expand Down Expand Up @@ -145,7 +145,7 @@ void main() {
final functionResult = {
'temperature': '22',
'unit': 'celsius',
'description': 'Sunny'
'description': 'Sunny',
};
final functionMessage = ChatMessage.function(
name: function.name,
Expand Down
2 changes: 1 addition & 1 deletion packages/vertex_ai/test/gen_ai/mappers/chat_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void main() {
0.1,
],
blocked: false,
)
),
],
),
],
Expand Down
2 changes: 1 addition & 1 deletion packages/vertex_ai/test/gen_ai/mappers/text_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void main() {
'license': 'CC BY-SA 4.0',
'publicationDate': '2023-02-11',
},
]
],
},
'safetyAttributes': {
'scores': [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ void main() async {
authHttpClient: authClient,
project: Platform.environment['VERTEX_AI_PROJECT_ID']!,
rootUrl:
'https://1451028425.europe-west1-706285145183.vdb.vertexai.goog/',
'https://455238120.europe-west1-706285145183.vdb.vertexai.goog/',
);
final res = await machineEngineQuery.indexEndpoints.findNeighbors(
indexEndpointId: '8572232454792806400',
deployedIndexId: 'deployment1',
indexEndpointId: '1537609836840091648',
deployedIndexId: 'public_knowledge_base_index_deployed',
queries: const [
VertexAIFindNeighborsRequestQuery(
datapoint: VertexAIIndexDatapoint(
Expand Down Expand Up @@ -945,5 +945,5 @@ const _queryVector = [
0.04319629445672035,
-0.007710671983659267,
-0.00981274526566267,
0.006554502993822098
0.006554502993822098,
];
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ void main() {
'fractionLeafNodesToSearch': 0.1,
'leafNodeEmbeddingCount': 900,
'leafNodesToSearchPercent': 5,
}
},
},
'shardSize': 'SHARD_SIZE_MEDIUM',
}
},
},
indexUpdateMethod: 'BATCH_UPDATE',
indexStats: GoogleCloudAiplatformV1IndexStats(
Expand Down

0 comments on commit cc32f3f

Please sign in to comment.