subconscious-python
Advanced tools
+1
-1
| Metadata-Version: 2.4 | ||
| Name: subconscious-python | ||
| Version: 0.1.2 | ||
| Version: 0.1.21 | ||
| Summary: Python SDK for Subconscious AI agent framework | ||
@@ -5,0 +5,0 @@ Author-email: Subconscious Systems <hongyin@subconscious.dev> |
+1
-1
@@ -7,3 +7,3 @@ [build-system] | ||
| name = "subconscious-python" | ||
| version = "0.1.2" | ||
| version = "0.1.21" | ||
| description = "Python SDK for Subconscious AI agent framework" | ||
@@ -10,0 +10,0 @@ readme = "README.md" |
| Metadata-Version: 2.4 | ||
| Name: subconscious-python | ||
| Version: 0.1.2 | ||
| Version: 0.1.21 | ||
| Summary: Python SDK for Subconscious AI agent framework | ||
@@ -5,0 +5,0 @@ Author-email: Subconscious Systems <hongyin@subconscious.dev> |
@@ -12,3 +12,3 @@ """ | ||
| __version__ = "0.1.2" | ||
| __version__ = "0.1.21" | ||
| __author__ = "Subconscious Systems" | ||
@@ -15,0 +15,0 @@ __email__ = "contact@subconscious.dev" |
@@ -5,3 +5,3 @@ import json | ||
| from openai import OpenAI | ||
| from typing import List, Dict, Type, Union, Tuple, Optional | ||
| from typing import List, Dict, Type, Union, Tuple, Optional, get_origin, get_args | ||
@@ -124,2 +124,26 @@ from .tim_api import tim_streaming | ||
| def check_task_array(self, task_model, task_title): | ||
| if task_model is not None: | ||
| origin = get_origin(task_model) | ||
| # Check if it's a direct List or Tuple | ||
| if origin in (list, tuple): | ||
| pass # Valid | ||
| # Check if it's a Union | ||
| elif origin is Union: | ||
| union_args = get_args(task_model) | ||
| # Verify all union members are List or Tuple | ||
| for arg in union_args: | ||
| arg_origin = get_origin(arg) | ||
| if arg_origin not in (list, tuple): | ||
| raise TypeError( | ||
| f"Invalid {task_title} type: {task_model}. " | ||
| f"Only List[...], Tuple[...], or Union[List[...], Tuple[...], ...] are accepted." | ||
| ) | ||
| else: | ||
| raise TypeError( | ||
| f"Invalid {task_title} type: {task_model}. " | ||
| f"Only List[...], Tuple[...], or Union[List[...], Tuple[...], ...] are accepted." | ||
| ) | ||
| def create_task( | ||
@@ -130,3 +154,3 @@ self, | ||
| thought: str = None, | ||
| tools: Tuple[str] = None, | ||
| tools: Union[Tuple[str], List[str]] = None, | ||
| subtasks: Type = None, | ||
@@ -136,8 +160,11 @@ flex: bool = False | ||
| if type(tools) is str: | ||
| tools = (tools, ) | ||
| # Type guard for subtasks - only accept List[...], Tuple[...], or Union[List[], Tuple[], ...] | ||
| self.check_task_array(subtasks, 'subtasks') | ||
| agent_toolkit = self.agent.toolkit.toolmap.get(agent_name, {}) | ||
| agent_tool_subset = tuple(agent_toolkit[tool_name] for tool_name in tools) if tools else None | ||
| # print(agent_tool_subset) | ||
| # sys.exit() | ||
| task_model = Task.create( | ||
@@ -162,2 +189,4 @@ task_name, | ||
| ) -> Type: | ||
| self.check_task_array(reasoning_model, 'reasoning_model') | ||
| thread_model = create_thread_grammar( | ||
@@ -164,0 +193,0 @@ reasoning_type=reasoning_model, |
@@ -196,3 +196,10 @@ from pydantic import BaseModel, Field, create_model | ||
| def create(task_name, thought=None, tools=None, subtasks=None, flex=False) -> BaseModel: | ||
| def create( | ||
| task_name, | ||
| thought=None, | ||
| tools=None, | ||
| subtasks=None, | ||
| depth: int = 1, | ||
| flex=False | ||
| ) -> BaseModel: | ||
| # task_model = create_model( | ||
@@ -215,9 +222,3 @@ # task_name, | ||
| if tools is None and subtasks is None: | ||
| task_model = create_model( | ||
| task_name, | ||
| thought=(str, ...) if thought is None else (Literal[thought], ...), | ||
| # tooluse=(Union[tools], ...) if tools else None, | ||
| # subtasks=subtasks if subtasks else None, | ||
| conclusion=(str, ...), | ||
| ) | ||
| task_model = create_task_with_depth(task_name, depth=depth, thought=thought) | ||
@@ -224,0 +225,0 @@ elif tools is None and subtasks is not None: |
@@ -84,2 +84,3 @@ import json | ||
| try: | ||
| # if True: | ||
| # Make streaming request | ||
@@ -119,3 +120,3 @@ response = openai_client.chat.completions.create( | ||
| open('tmp/final_answer_raw.json', 'w').write(full_content) | ||
| # open('tmp/final_answer_raw.json', 'w').write(full_content) | ||
| return TIMResponse( | ||
@@ -122,0 +123,0 @@ latency = time.time() - start_time, |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
55818
2.29%949
2.93%