beamlit 0.0.40rc84__py3-none-any.whl → 0.0.41rc85__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.
@@ -5,14 +5,14 @@ from typing import Callable
5
5
 
6
6
  import pydantic
7
7
  import typing_extensions as t
8
- from langchain_core.tools.base import BaseTool, ToolException
9
-
10
- from beamlit.api.functions import get_function
8
+ from beamlit.api.functions import get_function, list_functions
11
9
  from beamlit.authentication.authentication import AuthenticatedClient
12
10
  from beamlit.common.settings import get_settings
11
+ from beamlit.errors import UnexpectedStatus
13
12
  from beamlit.functions.mcp.mcp import MCPClient, MCPToolkit
14
13
  from beamlit.models import Function, StoreFunctionParameter
15
14
  from beamlit.run import RunClient
15
+ from langchain_core.tools.base import BaseTool, ToolException
16
16
 
17
17
 
18
18
  def create_dynamic_schema(name: str, parameters: list[StoreFunctionParameter]) -> type[pydantic.BaseModel]:
@@ -88,7 +88,22 @@ class RemoteToolkit:
88
88
  def initialize(self) -> None:
89
89
  """Initialize the session and retrieve tools list"""
90
90
  if self._function is None:
91
- self._function = get_function.sync_detailed(self.function, client=self.client).parsed
91
+ try:
92
+ response = get_function.sync_detailed(self.function, client=self.client)
93
+ self._function = response.parsed
94
+ except UnexpectedStatus as e:
95
+ settings = get_settings()
96
+ functions = list_functions.sync_detailed(
97
+ client=self.client,
98
+ environment=settings.environment,
99
+ ).parsed
100
+ names = [
101
+ f.metadata.name
102
+ for f in functions
103
+ ]
104
+ raise RuntimeError(
105
+ f"error: {e.status_code}. Available functions: {', '.join(names)}"
106
+ )
92
107
 
93
108
  @t.override
94
109
  def get_tools(self) -> list[BaseTool]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: beamlit
3
- Version: 0.0.40rc84
3
+ Version: 0.0.41rc85
4
4
  Summary: Add your description here
5
5
  Author-email: cploujoux <ch.ploujoux@gmail.com>
6
6
  Requires-Python: >=3.12
@@ -144,16 +144,8 @@ beamlit/deploy/format.py,sha256=U6UZEFAYLnGJJ7O2YmSdlUUFhnWNGAv6NZ-DW4KTgvI,2049
144
144
  beamlit/deploy/parser.py,sha256=Ga0poCZkoRnuTw082QnTcNGCBJncoRAnVsn8-1FsaJE,6907
145
145
  beamlit/functions/__init__.py,sha256=NcQPZZNfWhAJ1T1F6Xn21LFPMbZ7aMR2Sve3uZOkBCQ,170
146
146
  beamlit/functions/decorator.py,sha256=99oHbss0RZ6Km7Gf62otun1az9waZM0GPaOJvvwbmOI,8541
147
- beamlit/functions/github/__init__.py,sha256=gYnUkeegukOfbymdabuuJkScvH-_ZJygX05BoqkPn0o,49
148
- beamlit/functions/github/github.py,sha256=RfzWMT9nwPjsCOJr_-emN7eJHCIt2WsvkT9tq8-HfeA,568
149
- beamlit/functions/github/kit/__init__.py,sha256=jBwPqZv6C23_utukohxqXZwrlicNlI7PYPUj0Den7Cw,136
150
- beamlit/functions/github/kit/pull_request.py,sha256=wQVeRBakiqu-2ouflO8p1z7D5u07KNsitwyNRrp0KjM,1357
151
- beamlit/functions/math/__init__.py,sha256=wie4WME8jT-WpFRrtu-lDlHW31Mg6K2cwstjkUdLF3o,43
152
- beamlit/functions/math/math.py,sha256=CpoLJGwuvwCPGnVC8k9GYuIyvfUYPDQHKlZg3cx-z-A,1049
153
147
  beamlit/functions/mcp/mcp.py,sha256=c7OpmC_zIx1fc2lwoPiyJk_yMyRxWiwCpy9hvRV_C0Y,4080
154
- beamlit/functions/remote/remote.py,sha256=NldBFEostIX7yLw8ZE12MgVqhVpvKB4Z6FiQUBhPFsc,4207
155
- beamlit/functions/search/__init__.py,sha256=5NAthQ9PBwrkNg1FpLRx4flauvv0HyWuwaVS589c1Pw,49
156
- beamlit/functions/search/search.py,sha256=8s9ECltq7YE17j6rTxb12uY2EQY4_eTLHmwlIMThI0w,515
148
+ beamlit/functions/remote/remote.py,sha256=8dob5SbKaBTvPLZw-6yx955vfnbrjg048QIbW8xQDvA,4844
157
149
  beamlit/models/__init__.py,sha256=DB2EBTVX5lTO7CzXvZaqiPtgc9n8SMPu59zGD5_Vvno,9652
158
150
  beamlit/models/acl.py,sha256=tH67gsl_BMaviSbTaaIkO1g9cWZgJ6VgAnYVjQSzGZY,3952
159
151
  beamlit/models/agent.py,sha256=w2f_d_nLGVHW7blklH34Nmm2TI3MCoEiQN3HMVga5XI,4002
@@ -285,6 +277,6 @@ beamlit/serve/app.py,sha256=ROS_tb9cO4GvOQKCwloyAzpYraTdIb3oG6sChXikeNw,3285
285
277
  beamlit/serve/middlewares/__init__.py,sha256=1dVmnOmhAQWvWktqHkKSIX-YoF6fmMU8xkUQuhg_rJU,148
286
278
  beamlit/serve/middlewares/accesslog.py,sha256=Mu4T4_9OvHybjA0ApzZFpgi2C8f3X1NbUk-76v634XM,631
287
279
  beamlit/serve/middlewares/processtime.py,sha256=lDAaIasZ4bwvN-HKHvZpaD9r-yrkVNZYx4abvbjbrCg,411
288
- beamlit-0.0.40rc84.dist-info/METADATA,sha256=IIgQeS831MisY-EbiNZqA54a05M-Cb3h_2LT3dxqT7o,3715
289
- beamlit-0.0.40rc84.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
290
- beamlit-0.0.40rc84.dist-info/RECORD,,
280
+ beamlit-0.0.41rc85.dist-info/METADATA,sha256=uF6h-oK1OD8K0CafX1yGoM3gcQ1jCn1e5QyY_k88nxA,3715
281
+ beamlit-0.0.41rc85.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
282
+ beamlit-0.0.41rc85.dist-info/RECORD,,
@@ -1,3 +0,0 @@
1
- from .github import github
2
-
3
- __all__ = ["github"]
@@ -1,20 +0,0 @@
1
- from beamlit.common.secrets import Secret
2
-
3
- from . import kit
4
-
5
-
6
- def github(name: str, *args):
7
- """This function kit is used to perform actions on Github."""
8
- github_token = Secret.get("GITHUB_TOKEN")
9
- if not github_token:
10
- raise ValueError("github_token missing from configuration.")
11
-
12
- modes = {}
13
-
14
- for func_name in dir(kit):
15
- if not func_name.startswith("_"):
16
- modes[func_name] = getattr(kit, func_name)
17
- if name not in modes:
18
- msg = f"Invalid mode: {name}"
19
- raise ValueError(msg)
20
- return modes[name](*args)
@@ -1,7 +0,0 @@
1
- """Kit for interacting with GitHub."""
2
-
3
- from .pull_request import list_open_pull_requests
4
-
5
- __all__ = [
6
- "list_open_pull_requests",
7
- ]
@@ -1,51 +0,0 @@
1
- """Functions for interacting with GitHub pull requests."""
2
-
3
- from typing import Any
4
-
5
- from github import Auth, Github, PullRequest
6
- from pydash import pick
7
-
8
- from beamlit.common.secrets import Secret
9
-
10
-
11
- def list_open_pull_requests(
12
- repository: str,
13
- ):
14
- """
15
- This function will fetch a list of the repository's Pull Requests (PRs).
16
- It will return the title, and PR number of 5 PRs.
17
- """
18
- auth = Auth.Token(Secret.get("GITHUB_TOKEN"))
19
- gh = Github(auth=auth)
20
- repo = gh.get_repo(repository)
21
- return [_format_pull_request(pr) for pr in repo.get_pulls(state="open")[:5]]
22
-
23
-
24
- def _format_pull_request(pr: PullRequest) -> dict[str, Any]:
25
- raw_data = pr.raw_data
26
- raw_data["reviewers"] = [reviewer["login"] for reviewer in raw_data["requested_reviewers"]]
27
- raw_data["assignees"] = [assignee["login"] for assignee in raw_data["assignees"]]
28
-
29
- return pick(
30
- raw_data,
31
- [
32
- "id",
33
- "title",
34
- "labels",
35
- "number",
36
- "html_url",
37
- "diff_url",
38
- "patch_url",
39
- "commits",
40
- "additions",
41
- "deletions",
42
- "changed_files",
43
- "comments",
44
- "state",
45
- "user.login",
46
- "assignees",
47
- "reviewers",
48
- "created_at",
49
- "updated_at",
50
- ],
51
- )
@@ -1,3 +0,0 @@
1
- from .math import math
2
-
3
- __all__ = ["math"]
@@ -1,40 +0,0 @@
1
- import math as math_operation
2
- import operator
3
-
4
-
5
- def math(query: str):
6
- """A function for performing mathematical calculations.."""
7
- safe_dict = {
8
- "abs": abs,
9
- "round": round,
10
- "min": min,
11
- "max": max,
12
- "pow": math_operation.pow,
13
- "sqrt": math_operation.sqrt,
14
- "sin": math_operation.sin,
15
- "cos": math_operation.cos,
16
- "tan": math_operation.tan,
17
- "pi": math_operation.pi,
18
- "e": math_operation.e,
19
- }
20
-
21
- # Add basic arithmetic operators
22
- safe_dict.update(
23
- {
24
- "+": operator.add,
25
- "-": operator.sub,
26
- "*": operator.mul,
27
- "/": operator.truediv,
28
- "**": operator.pow,
29
- "%": operator.mod,
30
- }
31
- )
32
-
33
- try:
34
- # Replace 'x' with '*'
35
- query = query.replace("x", "*")
36
-
37
- # Evaluate the expression in a restricted environment
38
- return eval(query, {"__builtins__": {}}, safe_dict)
39
- except Exception as e:
40
- raise ValueError(f"Invalid expression: {str(e)}")
@@ -1,3 +0,0 @@
1
- from .search import search
2
-
3
- __all__ = ["search"]
@@ -1,15 +0,0 @@
1
- from langchain_community.tools.tavily_search.tool import TavilySearchResults
2
-
3
- from beamlit.common.secrets import Secret
4
-
5
-
6
- def search(query: str):
7
- """
8
- A search engine optimized for comprehensive, accurate, and trusted results.
9
- Useful for when you need to answer questions about current events.
10
- Input should be a search query.
11
- """
12
- api_key = Secret.get("TAVILY_API_KEY")
13
- tavily = TavilySearchResults(api_key=api_key, max_results=2)
14
- result = tavily.invoke(input=query)
15
- return result