symbolicai 1.0.0__py3-none-any.whl → 1.1.0__py3-none-any.whl

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.
Files changed (127) hide show
  1. symai/__init__.py +198 -134
  2. symai/backend/base.py +51 -51
  3. symai/backend/engines/drawing/engine_bfl.py +33 -33
  4. symai/backend/engines/drawing/engine_gpt_image.py +4 -10
  5. symai/backend/engines/embedding/engine_llama_cpp.py +50 -35
  6. symai/backend/engines/embedding/engine_openai.py +22 -16
  7. symai/backend/engines/execute/engine_python.py +16 -16
  8. symai/backend/engines/files/engine_io.py +51 -49
  9. symai/backend/engines/imagecaptioning/engine_blip2.py +27 -23
  10. symai/backend/engines/imagecaptioning/engine_llavacpp_client.py +53 -46
  11. symai/backend/engines/index/engine_pinecone.py +116 -88
  12. symai/backend/engines/index/engine_qdrant.py +1011 -0
  13. symai/backend/engines/index/engine_vectordb.py +78 -52
  14. symai/backend/engines/lean/engine_lean4.py +65 -25
  15. symai/backend/engines/neurosymbolic/__init__.py +28 -28
  16. symai/backend/engines/neurosymbolic/engine_anthropic_claudeX_chat.py +137 -135
  17. symai/backend/engines/neurosymbolic/engine_anthropic_claudeX_reasoning.py +145 -152
  18. symai/backend/engines/neurosymbolic/engine_cerebras.py +328 -0
  19. symai/backend/engines/neurosymbolic/engine_deepseekX_reasoning.py +75 -49
  20. symai/backend/engines/neurosymbolic/engine_google_geminiX_reasoning.py +199 -155
  21. symai/backend/engines/neurosymbolic/engine_groq.py +106 -72
  22. symai/backend/engines/neurosymbolic/engine_huggingface.py +100 -67
  23. symai/backend/engines/neurosymbolic/engine_llama_cpp.py +121 -93
  24. symai/backend/engines/neurosymbolic/engine_openai_gptX_chat.py +213 -132
  25. symai/backend/engines/neurosymbolic/engine_openai_gptX_reasoning.py +180 -137
  26. symai/backend/engines/ocr/engine_apilayer.py +18 -20
  27. symai/backend/engines/output/engine_stdout.py +9 -9
  28. symai/backend/engines/{webscraping → scrape}/engine_requests.py +25 -11
  29. symai/backend/engines/search/engine_openai.py +95 -83
  30. symai/backend/engines/search/engine_parallel.py +665 -0
  31. symai/backend/engines/search/engine_perplexity.py +40 -41
  32. symai/backend/engines/search/engine_serpapi.py +33 -28
  33. symai/backend/engines/speech_to_text/engine_local_whisper.py +37 -27
  34. symai/backend/engines/symbolic/engine_wolframalpha.py +14 -8
  35. symai/backend/engines/text_to_speech/engine_openai.py +15 -19
  36. symai/backend/engines/text_vision/engine_clip.py +34 -28
  37. symai/backend/engines/userinput/engine_console.py +3 -4
  38. symai/backend/mixin/anthropic.py +48 -40
  39. symai/backend/mixin/deepseek.py +4 -5
  40. symai/backend/mixin/google.py +5 -4
  41. symai/backend/mixin/groq.py +2 -4
  42. symai/backend/mixin/openai.py +132 -110
  43. symai/backend/settings.py +14 -14
  44. symai/chat.py +164 -94
  45. symai/collect/dynamic.py +13 -11
  46. symai/collect/pipeline.py +39 -31
  47. symai/collect/stats.py +109 -69
  48. symai/components.py +556 -238
  49. symai/constraints.py +14 -5
  50. symai/core.py +1495 -1210
  51. symai/core_ext.py +55 -50
  52. symai/endpoints/api.py +113 -58
  53. symai/extended/api_builder.py +22 -17
  54. symai/extended/arxiv_pdf_parser.py +13 -5
  55. symai/extended/bibtex_parser.py +8 -4
  56. symai/extended/conversation.py +88 -69
  57. symai/extended/document.py +40 -27
  58. symai/extended/file_merger.py +45 -7
  59. symai/extended/graph.py +38 -24
  60. symai/extended/html_style_template.py +17 -11
  61. symai/extended/interfaces/blip_2.py +1 -1
  62. symai/extended/interfaces/clip.py +4 -2
  63. symai/extended/interfaces/console.py +5 -3
  64. symai/extended/interfaces/dall_e.py +3 -1
  65. symai/extended/interfaces/file.py +2 -0
  66. symai/extended/interfaces/flux.py +3 -1
  67. symai/extended/interfaces/gpt_image.py +15 -6
  68. symai/extended/interfaces/input.py +2 -1
  69. symai/extended/interfaces/llava.py +1 -1
  70. symai/extended/interfaces/{naive_webscraping.py → naive_scrape.py} +3 -2
  71. symai/extended/interfaces/naive_vectordb.py +2 -2
  72. symai/extended/interfaces/ocr.py +4 -2
  73. symai/extended/interfaces/openai_search.py +2 -0
  74. symai/extended/interfaces/parallel.py +30 -0
  75. symai/extended/interfaces/perplexity.py +2 -0
  76. symai/extended/interfaces/pinecone.py +6 -4
  77. symai/extended/interfaces/python.py +2 -0
  78. symai/extended/interfaces/serpapi.py +2 -0
  79. symai/extended/interfaces/terminal.py +0 -1
  80. symai/extended/interfaces/tts.py +2 -1
  81. symai/extended/interfaces/whisper.py +2 -1
  82. symai/extended/interfaces/wolframalpha.py +1 -0
  83. symai/extended/metrics/__init__.py +1 -1
  84. symai/extended/metrics/similarity.py +5 -2
  85. symai/extended/os_command.py +31 -22
  86. symai/extended/packages/symdev.py +39 -34
  87. symai/extended/packages/sympkg.py +30 -27
  88. symai/extended/packages/symrun.py +46 -35
  89. symai/extended/repo_cloner.py +10 -9
  90. symai/extended/seo_query_optimizer.py +15 -12
  91. symai/extended/solver.py +104 -76
  92. symai/extended/summarizer.py +8 -7
  93. symai/extended/taypan_interpreter.py +10 -9
  94. symai/extended/vectordb.py +28 -15
  95. symai/formatter/formatter.py +39 -31
  96. symai/formatter/regex.py +46 -44
  97. symai/functional.py +184 -86
  98. symai/imports.py +85 -51
  99. symai/interfaces.py +1 -1
  100. symai/memory.py +33 -24
  101. symai/menu/screen.py +28 -19
  102. symai/misc/console.py +27 -27
  103. symai/misc/loader.py +4 -3
  104. symai/models/base.py +147 -76
  105. symai/models/errors.py +1 -1
  106. symai/ops/__init__.py +1 -1
  107. symai/ops/measures.py +17 -14
  108. symai/ops/primitives.py +933 -635
  109. symai/post_processors.py +28 -24
  110. symai/pre_processors.py +58 -52
  111. symai/processor.py +15 -9
  112. symai/prompts.py +714 -649
  113. symai/server/huggingface_server.py +115 -32
  114. symai/server/llama_cpp_server.py +14 -6
  115. symai/server/qdrant_server.py +206 -0
  116. symai/shell.py +98 -39
  117. symai/shellsv.py +307 -223
  118. symai/strategy.py +135 -81
  119. symai/symbol.py +276 -225
  120. symai/utils.py +62 -46
  121. {symbolicai-1.0.0.dist-info → symbolicai-1.1.0.dist-info}/METADATA +19 -9
  122. symbolicai-1.1.0.dist-info/RECORD +168 -0
  123. symbolicai-1.0.0.dist-info/RECORD +0 -163
  124. {symbolicai-1.0.0.dist-info → symbolicai-1.1.0.dist-info}/WHEEL +0 -0
  125. {symbolicai-1.0.0.dist-info → symbolicai-1.1.0.dist-info}/entry_points.txt +0 -0
  126. {symbolicai-1.0.0.dist-info → symbolicai-1.1.0.dist-info}/licenses/LICENSE +0 -0
  127. {symbolicai-1.0.0.dist-info → symbolicai-1.1.0.dist-info}/top_level.txt +0 -0
@@ -11,7 +11,7 @@ from ... import config_manager
11
11
 
12
12
  class PackageInitializer:
13
13
  def __init__(self):
14
- self.package_dir = Path(config_manager.config_dir) / 'packages'
14
+ self.package_dir = Path(config_manager.config_dir) / "packages"
15
15
 
16
16
  if not self.package_dir.exists():
17
17
  self.package_dir.mkdir(parents=True)
@@ -19,71 +19,76 @@ class PackageInitializer:
19
19
  os.chdir(self.package_dir)
20
20
 
21
21
  parser = argparse.ArgumentParser(
22
- description='''SymbolicAI package initializer.
23
- Initialize a new GitHub package from the command line.''',
24
- usage='''symdev <command> <username>/<package_name>
22
+ description="""SymbolicAI package initializer.
23
+ Initialize a new GitHub package from the command line.""",
24
+ usage="""symdev <command> <username>/<package_name>
25
25
  Available commands:
26
26
  c Create a new package [default if no command is given]
27
- '''
27
+ """,
28
28
  )
29
29
 
30
- parser.add_argument('command', help='Subcommand to run')
30
+ parser.add_argument("command", help="Subcommand to run")
31
31
  args = parser.parse_args(sys.argv[1:2])
32
32
  if len(args.command) > 1 and not hasattr(self, args.command):
33
33
  args.package = args.command
34
34
  self.c(args)
35
35
  elif len(args.command) == 1 and not hasattr(self, args.command):
36
- logger.error('Unrecognized command')
36
+ logger.error("Unrecognized command")
37
37
  parser.print_help()
38
38
  exit(1)
39
39
  else:
40
40
  getattr(self, args.command)()
41
41
 
42
- def c(self, args = None):
42
+ def c(self, args=None):
43
43
  parser = argparse.ArgumentParser(
44
- description='Create a new package',
45
- usage='symdev c <username>/<package>'
44
+ description="Create a new package", usage="symdev c <username>/<package>"
45
+ )
46
+ parser.add_argument(
47
+ "package", help="Name of user based on GitHub username and package to install"
46
48
  )
47
- parser.add_argument('package', help='Name of user based on GitHub username and package to install')
48
49
  if args is None:
49
50
  args = parser.parse_args(sys.argv[2:3])
50
- vals = args.package.split('/')
51
+ vals = args.package.split("/")
51
52
  try:
52
53
  username = vals[0]
53
54
  package_name = vals[1]
54
55
  except IndexError:
55
- logger.error('Invalid package name: {git_username}/{package_name}')
56
+ logger.error("Invalid package name: {git_username}/{package_name}")
56
57
  parser.print_help()
57
58
  exit(1)
58
59
 
59
60
  package_path = self.package_dir / username / package_name
60
61
  if package_path.exists():
61
- logger.info('Package already exists')
62
+ logger.info("Package already exists")
62
63
  exit(1)
63
64
 
64
- logger.info('Creating package...')
65
+ logger.info("Creating package...")
65
66
  package_path.mkdir(parents=True)
66
- src_path = package_path / 'src'
67
+ src_path = package_path / "src"
67
68
  src_path.mkdir(parents=True)
68
69
 
69
- with (package_path / '.gitignore').open('w'):
70
+ with (package_path / ".gitignore").open("w"):
70
71
  pass
71
- with (package_path / 'LICENSE').open('w') as f:
72
- f.write('MIT License')
73
- with (package_path / 'README.md').open('w') as f:
74
- f.write('# ' + package_name + '\n## <Project Description>')
75
- with (package_path / 'requirements.txt').open('w'):
72
+ with (package_path / "LICENSE").open("w") as f:
73
+ f.write("MIT License")
74
+ with (package_path / "README.md").open("w") as f:
75
+ f.write("# " + package_name + "\n## <Project Description>")
76
+ with (package_path / "requirements.txt").open("w"):
76
77
  pass
77
- with (package_path / 'package.json').open('w') as f:
78
- json.dump({
79
- 'version': '0.0.1',
80
- 'name': username+'/'+package_name,
81
- 'description': '<Project Description>',
82
- 'expressions': [{'module': 'src/func', 'type': 'MyExpression'}],
83
- 'run': {'module': 'src/func', 'type': 'MyExpression'},
84
- 'dependencies': []
85
- }, f, indent=4)
86
- with (src_path / 'func.py').open('w') as f:
78
+ with (package_path / "package.json").open("w") as f:
79
+ json.dump(
80
+ {
81
+ "version": "0.0.1",
82
+ "name": username + "/" + package_name,
83
+ "description": "<Project Description>",
84
+ "expressions": [{"module": "src/func", "type": "MyExpression"}],
85
+ "run": {"module": "src/func", "type": "MyExpression"},
86
+ "dependencies": [],
87
+ },
88
+ f,
89
+ indent=4,
90
+ )
91
+ with (src_path / "func.py").open("w") as f:
87
92
  f.write("""from symai import Expression, Function
88
93
 
89
94
 
@@ -102,12 +107,12 @@ class MyExpression(Expression):
102
107
  data = self._to_symbol(data)
103
108
  self.fn.format(template=template)
104
109
  return self.fn(data, *args, **kwargs)""")
105
- logger.success('Package created successfully at: ' + str(package_path))
110
+ logger.success("Package created successfully at: " + str(package_path))
106
111
 
107
112
 
108
113
  def run() -> None:
109
114
  PackageInitializer()
110
115
 
111
116
 
112
- if __name__ == '__main__':
117
+ if __name__ == "__main__":
113
118
  run()
@@ -13,7 +13,7 @@ from ...utils import UserMessage
13
13
 
14
14
  class PackageHandler:
15
15
  def __init__(self):
16
- self.package_dir = Path(config_manager.config_dir) / 'packages'
16
+ self.package_dir = Path(config_manager.config_dir) / "packages"
17
17
 
18
18
  if not self.package_dir.exists():
19
19
  self.package_dir.mkdir(parents=True)
@@ -21,10 +21,10 @@ class PackageHandler:
21
21
  os.chdir(self.package_dir)
22
22
 
23
23
  parser = argparse.ArgumentParser(
24
- description='''SymbolicAI package manager.
24
+ description="""SymbolicAI package manager.
25
25
  Manage extensions from the command line.
26
- You can (i) install, (r) remove, (l) list installed, (u) update a module or (U) update all modules.''',
27
- usage='''sympkg <command> [<args>]
26
+ You can (i) install, (r) remove, (l) list installed, (u) update a module or (U) update all modules.""",
27
+ usage="""sympkg <command> [<args>]
28
28
 
29
29
  The most commonly used sympkg commands are:
30
30
  i Install a new package (--local-path PATH, --submodules)
@@ -32,31 +32,33 @@ class PackageHandler:
32
32
  l List all installed packages
33
33
  u Update an installed package (--submodules)
34
34
  U Update all installed packages (--submodules)
35
- '''
35
+ """,
36
36
  )
37
37
 
38
- parser.add_argument('command', help='Subcommand to run')
38
+ parser.add_argument("command", help="Subcommand to run")
39
39
  args = parser.parse_args(sys.argv[1:2])
40
- command_aliases = {'l': 'list_packages'}
40
+ command_aliases = {"l": "list_packages"}
41
41
  command = command_aliases.get(args.command, args.command)
42
42
  if len(command) > 1 and not hasattr(self, command):
43
43
  args.package = args.command
44
44
  self.i(args)
45
45
  elif len(command) == 1 and not hasattr(self, command):
46
- logger.error('Unrecognized command')
46
+ logger.error("Unrecognized command")
47
47
  parser.print_help()
48
48
  exit(1)
49
49
  else:
50
50
  getattr(self, command)()
51
51
 
52
- def i(self, args = None):
52
+ def i(self, args=None):
53
53
  parser = argparse.ArgumentParser(
54
- description='Install a new package',
55
- usage='sympkg i [package] [--local-path PATH] [--submodules]'
54
+ description="Install a new package",
55
+ usage="sympkg i [package] [--local-path PATH] [--submodules]",
56
+ )
57
+ parser.add_argument("package", help="Name of package to install")
58
+ parser.add_argument("--local-path", "-l", help="Local path to package directory")
59
+ parser.add_argument(
60
+ "--submodules", "-s", action="store_true", help="Initialize submodules for GitHub repos"
56
61
  )
57
- parser.add_argument('package', help='Name of package to install')
58
- parser.add_argument('--local-path', '-l', help='Local path to package directory')
59
- parser.add_argument('--submodules', '-s', action='store_true', help='Initialize submodules for GitHub repos')
60
62
 
61
63
  if args is None:
62
64
  args = parser.parse_args(sys.argv[2:])
@@ -65,10 +67,9 @@ class PackageHandler:
65
67
 
66
68
  def r(self):
67
69
  parser = argparse.ArgumentParser(
68
- description='Remove an installed package',
69
- usage='sympkg r [package]'
70
+ description="Remove an installed package", usage="sympkg r [package]"
70
71
  )
71
- parser.add_argument('package', help='Name of package to remove')
72
+ parser.add_argument("package", help="Name of package to remove")
72
73
  args = parser.parse_args(sys.argv[2:])
73
74
  Import.remove(args.package)
74
75
 
@@ -77,34 +78,36 @@ class PackageHandler:
77
78
 
78
79
  def u(self):
79
80
  parser = argparse.ArgumentParser(
80
- description='Update an installed package',
81
- usage='sympkg u [package] [--submodules]'
81
+ description="Update an installed package", usage="sympkg u [package] [--submodules]"
82
+ )
83
+ parser.add_argument("package", help="Name of package to update")
84
+ parser.add_argument(
85
+ "--submodules", "-s", action="store_true", help="Update submodules as well"
82
86
  )
83
- parser.add_argument('package', help='Name of package to update')
84
- parser.add_argument('--submodules', '-s', action='store_true', help='Update submodules as well')
85
87
  args = parser.parse_args(sys.argv[2:])
86
88
  Import.update(args.package, args.submodules)
87
89
 
88
90
  def U(self):
89
91
  parser = argparse.ArgumentParser(
90
- description='Update all installed packages',
91
- usage='sympkg U [--submodules]'
92
+ description="Update all installed packages", usage="sympkg U [--submodules]"
93
+ )
94
+ parser.add_argument(
95
+ "--submodules", "-s", action="store_true", help="Update submodules as well"
92
96
  )
93
- parser.add_argument('--submodules', '-s', action='store_true', help='Update submodules as well')
94
97
  args = parser.parse_args(sys.argv[2:])
95
98
 
96
99
  packages = Import.list_installed()
97
100
  for package in packages:
98
101
  try:
99
- logger.info(f'[UPDATE]: Updating {package}...')
102
+ logger.info(f"[UPDATE]: Updating {package}...")
100
103
  Import.update(package, args.submodules)
101
104
  except Exception as e:
102
- logger.error(f'[SKIP]: Error updating {package}: {e}')
105
+ logger.error(f"[SKIP]: Error updating {package}: {e}")
103
106
 
104
107
 
105
108
  def run() -> None:
106
109
  PackageHandler()
107
110
 
108
111
 
109
- if __name__ == '__main__':
112
+ if __name__ == "__main__":
110
113
  run()
@@ -14,8 +14,8 @@ from ...misc.loader import Loader
14
14
 
15
15
  class PackageRunner:
16
16
  def __init__(self):
17
- self.package_dir = Path(config_manager.config_dir) / 'packages'
18
- self.aliases_file = self.package_dir / 'aliases.json'
17
+ self.package_dir = Path(config_manager.config_dir) / "packages"
18
+ self.aliases_file = self.package_dir / "aliases.json"
19
19
 
20
20
  if not self.package_dir.exists():
21
21
  self.package_dir.mkdir(parents=True)
@@ -24,20 +24,20 @@ class PackageRunner:
24
24
 
25
25
  try:
26
26
  parser = argparse.ArgumentParser(
27
- description='''SymbolicAI package runner.
28
- Run a package in command line.''',
29
- usage='''symrun <alias> [<args>] | <command> <alias> [<package>]
27
+ description="""SymbolicAI package runner.
28
+ Run a package in command line.""",
29
+ usage="""symrun <alias> [<args>] | <command> <alias> [<package>]
30
30
  The most commonly used symrun commands are:
31
31
  <alias> [<args>] Run an alias
32
32
  c <alias> <package> Create a new alias
33
33
  l List all aliases
34
34
  r <alias> Remove an alias
35
- '''
35
+ """,
36
36
  )
37
37
 
38
- parser.add_argument('command', help='Subcommand to run')
38
+ parser.add_argument("command", help="Subcommand to run")
39
39
  args = parser.parse_args(sys.argv[1:2])
40
- command_aliases = {'l': 'list_aliases'}
40
+ command_aliases = {"l": "list_aliases"}
41
41
  command = command_aliases.get(args.command, args.command)
42
42
  getattr(self, command)()
43
43
  except Exception:
@@ -55,46 +55,50 @@ class PackageRunner:
55
55
  return json.load(f)
56
56
 
57
57
  def save_aliases(self, aliases):
58
- with self.aliases_file.open('w') as f:
58
+ with self.aliases_file.open("w") as f:
59
59
  json.dump(aliases, f)
60
60
 
61
61
  def console(self, header: str, output: object | None = None):
62
- with ConsoleStyle('success'):
62
+ with ConsoleStyle("success"):
63
63
  logger.success(header)
64
64
  if output is not None:
65
- with ConsoleStyle('info'):
65
+ with ConsoleStyle("info"):
66
66
  logger.info(str(output))
67
67
 
68
68
  def run_alias(self):
69
69
  parser = argparse.ArgumentParser(
70
- description='This command runs the alias from the aliases.json file. If the alias is not found, it will run the command as a package.',
71
- usage='symrun <alias> [<args> | <kwargs>]*'
70
+ description="This command runs the alias from the aliases.json file. If the alias is not found, it will run the command as a package.",
71
+ usage="symrun <alias> [<args> | <kwargs>]*",
72
+ )
73
+ parser.add_argument("alias", help="Name of alias to run")
74
+ parser.add_argument("params", nargs=argparse.REMAINDER)
75
+ parser.add_argument(
76
+ "--submodules", "-s", action="store_true", help="Initialize submodules for GitHub repos"
72
77
  )
73
- parser.add_argument('alias', help='Name of alias to run')
74
- parser.add_argument('params', nargs=argparse.REMAINDER)
75
- parser.add_argument('--submodules', '-s', action='store_true', help='Initialize submodules for GitHub repos')
76
78
  args = parser.parse_args(sys.argv[1:])
77
79
 
78
80
  aliases = self.load_aliases()
79
81
  # try running the alias or as package
80
82
  package = aliases.get(args.alias) or args.alias
81
83
 
82
- arg_values = [arg for arg in args.params if '=' not in arg]
83
- kwargs = {arg.split('=')[0]: arg.split('=')[1] for arg in args.params if '=' in arg}
84
+ arg_values = [arg for arg in args.params if "=" not in arg]
85
+ kwargs = {arg.split("=")[0]: arg.split("=")[1] for arg in args.params if "=" in arg}
84
86
 
85
87
  if package is None:
86
- with ConsoleStyle('error'):
87
- logger.error(f"Alias run of `{args.alias}` not found. Please check your command {args}")
88
+ with ConsoleStyle("error"):
89
+ logger.error(
90
+ f"Alias run of `{args.alias}` not found. Please check your command {args}"
91
+ )
88
92
  parser.print_help()
89
93
  return None
90
94
 
91
- arg_values = [arg for arg in args.params if '=' not in arg]
92
- kwargs = {arg.split('=')[0]: arg.split('=')[1] for arg in args.params if '=' in arg}
95
+ arg_values = [arg for arg in args.params if "=" not in arg]
96
+ kwargs = {arg.split("=")[0]: arg.split("=")[1] for arg in args.params if "=" in arg}
93
97
 
94
98
  try:
95
99
  # Add submodules to kwargs if specified
96
100
  if args.submodules:
97
- kwargs['submodules'] = True
101
+ kwargs["submodules"] = True
98
102
 
99
103
  # Check if package is a local path
100
104
  package_path = Path(package)
@@ -105,12 +109,14 @@ class PackageRunner:
105
109
  # GitHub reference
106
110
  expr = Import(package, **kwargs)
107
111
  except Exception as e:
108
- with ConsoleStyle('error'):
109
- logger.error(f"Error: {e!s} in package `{package}`.\nPlease check your command {args} or if package is available.")
112
+ with ConsoleStyle("error"):
113
+ logger.error(
114
+ f"Error: {e!s} in package `{package}`.\nPlease check your command {args} or if package is available."
115
+ )
110
116
  parser.print_help()
111
117
  return None
112
118
 
113
- if '--disable-pbar' not in arg_values:
119
+ if "--disable-pbar" not in arg_values:
114
120
  with Loader(desc="Inference ...", end=""):
115
121
  result = expr(*arg_values, **kwargs)
116
122
  else:
@@ -125,11 +131,16 @@ class PackageRunner:
125
131
 
126
132
  def c(self):
127
133
  parser = argparse.ArgumentParser(
128
- description='This will create a new alias entry in the alias json file. Exsisting aliases will be overwritten.',
129
- usage='symrun c <alias> <package>'
134
+ description="This will create a new alias entry in the alias json file. Exsisting aliases will be overwritten.",
135
+ usage="symrun c <alias> <package>",
136
+ )
137
+ parser.add_argument(
138
+ "alias", help="Name of user based on GitHub username and package to install"
139
+ )
140
+ parser.add_argument(
141
+ "package",
142
+ help="Name of the package: <user>/<package> where user is based on GitHub username and package to install",
130
143
  )
131
- parser.add_argument('alias', help='Name of user based on GitHub username and package to install')
132
- parser.add_argument('package', help='Name of the package: <user>/<package> where user is based on GitHub username and package to install')
133
144
  args = parser.parse_args(sys.argv[2:])
134
145
 
135
146
  aliases = self.load_aliases()
@@ -142,15 +153,15 @@ class PackageRunner:
142
153
  # format the aliases output as a table of key value pairs
143
154
  self.console("Aliases:\n------------------")
144
155
  for alias, package in aliases.items():
145
- self.console(f'{alias} => {package}')
156
+ self.console(f"{alias} => {package}")
146
157
  self.console("------------------")
147
158
 
148
159
  def r(self):
149
160
  parser = argparse.ArgumentParser(
150
- description='This will remove the alias name from the alias json file.',
151
- usage='symrun r <alias>'
161
+ description="This will remove the alias name from the alias json file.",
162
+ usage="symrun r <alias>",
152
163
  )
153
- parser.add_argument('alias', help='Name of alias to remove')
164
+ parser.add_argument("alias", help="Name of alias to remove")
154
165
  args = parser.parse_args(sys.argv[2:])
155
166
 
156
167
  aliases = self.load_aliases()
@@ -164,5 +175,5 @@ def run() -> None:
164
175
  PackageRunner()
165
176
 
166
177
 
167
- if __name__ == '__main__':
178
+ if __name__ == "__main__":
168
179
  run()
@@ -17,9 +17,10 @@ class RepositoryCloner(Expression):
17
17
  repo_path (Optional[str]): The path where to clone the repository.
18
18
  By default it will be at '~/.symai/repos/'.
19
19
  """
20
+
20
21
  def __init__(self, repo_path: str | None = None, **kwargs):
21
22
  super().__init__(**kwargs)
22
- self.repo_dir = HOME_PATH / 'repos/' if repo_path is None else Path(repo_path)
23
+ self.repo_dir = HOME_PATH / "repos/" if repo_path is None else Path(repo_path)
23
24
  if not self.repo_dir.exists():
24
25
  self.repo_dir.mkdir(parents=True, exist_ok=True)
25
26
 
@@ -34,26 +35,26 @@ class RepositoryCloner(Expression):
34
35
  Returns:
35
36
  str: The root path of the cloned repository.
36
37
  """
37
- repo_name = url.split('/')[-1].replace('.git', '')
38
+ repo_name = url.split("/")[-1].replace(".git", "")
38
39
  if (self.repo_dir / repo_name).is_dir():
39
- UserMessage(f'Repository {repo_name} already exists. Checking for updates...')
40
+ UserMessage(f"Repository {repo_name} already exists. Checking for updates...")
40
41
  try:
41
42
  repo = Repo(self.repo_dir / repo_name)
42
43
  current = repo.head.commit
43
44
  repo.remotes.origin.pull()
44
45
  if current != repo.head.commit:
45
- UserMessage(f'Repository {repo_name} updated.')
46
+ UserMessage(f"Repository {repo_name} updated.")
46
47
  else:
47
- UserMessage(f'Repository {repo_name} is up-to-date.')
48
+ UserMessage(f"Repository {repo_name} is up-to-date.")
48
49
  except Exception as e:
49
- UserMessage(f'An error occurred: {e}')
50
+ UserMessage(f"An error occurred: {e}")
50
51
  raise e
51
52
  else:
52
- UserMessage(f'Cloning repository {repo_name}...')
53
+ UserMessage(f"Cloning repository {repo_name}...")
53
54
  try:
54
55
  Repo.clone_from(url, self.repo_dir / repo_name)
55
- UserMessage(f'Repository {repo_name} cloned successfully.')
56
+ UserMessage(f"Repository {repo_name} cloned successfully.")
56
57
  except Exception as e:
57
- UserMessage(f'Failed to clone the repository. An error occurred: {e}')
58
+ UserMessage(f"Failed to clone the repository. An error occurred: {e}")
58
59
  raise e
59
60
  return str(self.repo_dir / repo_name)
@@ -16,7 +16,7 @@ The number of resulting queries should be between 1 and 8 statements separated b
16
16
 
17
17
  class SEOQueryOptimizerPreProcessor(PreProcessor):
18
18
  def __call__(self, argument):
19
- return f'$> {argument.args[0]!s} =>'
19
+ return f"$> {argument.args[0]!s} =>"
20
20
 
21
21
 
22
22
  class SEOQueryOptimizer(Expression):
@@ -29,18 +29,21 @@ class SEOQueryOptimizer(Expression):
29
29
  self.sym_return_type = SEOQueryOptimizer
30
30
 
31
31
  def forward(self, sym: Symbol, **kwargs) -> Symbol:
32
- @core.few_shot(prompt="Extract relationships between entities:\n",
33
- examples=Prompt([
34
- '$> John has a dog. =>John dog EOF',
35
- '$> How can i find on wikipedia an article about programming? Preferably about python programming. =>Wikipedia python programming tutorial EOF',
36
- '$> Similarly, the term general linguistics is used to distinguish core linguistics from other types of study =>general linguistics term, core linguistics from other types of study EOF',
37
- ]),
38
- pre_processors=[SEOQueryOptimizerPreProcessor()],
39
- post_processors=[StripPostProcessor()],
40
- stop=['EOF'], **kwargs)
32
+ @core.few_shot(
33
+ prompt="Extract relationships between entities:\n",
34
+ examples=Prompt(
35
+ [
36
+ "$> John has a dog. =>John dog EOF",
37
+ "$> How can i find on wikipedia an article about programming? Preferably about python programming. =>Wikipedia python programming tutorial EOF",
38
+ "$> Similarly, the term general linguistics is used to distinguish core linguistics from other types of study =>general linguistics term, core linguistics from other types of study EOF",
39
+ ]
40
+ ),
41
+ pre_processors=[SEOQueryOptimizerPreProcessor()],
42
+ post_processors=[StripPostProcessor()],
43
+ stop=["EOF"],
44
+ **kwargs,
45
+ )
41
46
  def _func(_, text) -> str:
42
47
  pass
43
48
 
44
49
  return _func(self, sym)
45
-
46
-