freeplay 0.3.10__tar.gz → 0.3.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: freeplay
3
- Version: 0.3.10
3
+ Version: 0.3.11
4
4
  Summary:
5
5
  License: MIT
6
6
  Author: FreePlay Engineering
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "freeplay"
3
- version = "0.3.10"
3
+ version = "0.3.11"
4
4
  description = ""
5
5
  authors = ["FreePlay Engineering <engineering@freeplay.ai>"]
6
6
  license = "MIT"
@@ -4,7 +4,7 @@ import logging
4
4
  from abc import ABC, abstractmethod
5
5
  from dataclasses import asdict, dataclass
6
6
  from pathlib import Path
7
- from typing import Dict, Optional, List, cast, Any, Union, runtime_checkable, Protocol
7
+ from typing import Dict, Optional, List, Sequence, cast, Any, Union, runtime_checkable, Protocol
8
8
 
9
9
  from freeplay.errors import FreeplayConfigurationError, FreeplayClientError, log_freeplay_client_warning
10
10
  from freeplay.llm_parameters import LLMParameters
@@ -211,12 +211,15 @@ class TemplatePrompt:
211
211
  self.tool_schema = tool_schema
212
212
  self.messages = messages
213
213
 
214
- def bind(self, variables: InputVariables, history: Optional[List[Dict[str, str]]] = None) -> BoundPrompt:
214
+ def bind(self, variables: InputVariables, history: Optional[Sequence[GenericProviderMessage]] = None) -> BoundPrompt:
215
215
  # check history for a system message
216
216
  history_clean = []
217
217
  if history:
218
- for msg in history:
219
- if (msg.get('role') == 'system') and ('system' in [message.get('role') for message in self.messages]):
218
+ template_messages_contain_system = any(message.get('role') == 'system' for message in self.messages)
219
+ history_dict = [convert_provider_message_to_dict(msg) for msg in history]
220
+ for msg in history_dict:
221
+ history_has_system = msg.get('role', None) == 'system'
222
+ if history_has_system and template_messages_contain_system:
220
223
  log_freeplay_client_warning("System message found in history, and prompt template."
221
224
  "Removing system message from the history")
222
225
  else:
@@ -341,7 +344,12 @@ class FilesystemTemplateResolver(TemplateResolver):
341
344
  params=metadata.get('params'),
342
345
  provider_info=metadata.get('provider_info')
343
346
  ),
344
- project_id=str(json_dom.get('project_id'))
347
+ project_id=str(json_dom.get('project_id')),
348
+ tool_schema=[ToolSchema(
349
+ name=schema.get('name'),
350
+ description=schema.get('description'),
351
+ parameters=schema.get('parameters')
352
+ ) for schema in json_dom.get('tool_schema', [])] if json_dom.get('tool_schema') else None
345
353
  )
346
354
  else:
347
355
  metadata = json_dom['metadata']
@@ -518,7 +526,7 @@ class Prompts:
518
526
  template_name: str,
519
527
  environment: str,
520
528
  variables: InputVariables,
521
- history: Optional[List[Dict[str, str]]] = None,
529
+ history: Optional[Sequence[GenericProviderMessage]] = None,
522
530
  flavor_name: Optional[str] = None
523
531
  ) -> FormattedPrompt:
524
532
  bound_prompt = self.get(
File without changes
File without changes