beamlit 0.0.33rc43__py3-none-any.whl → 0.0.33rc45__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.
@@ -1,9 +1,11 @@
1
1
  """Decorators for creating function tools with Beamlit and LangChain integration."""
2
2
 
3
+ import functools
3
4
  import json
4
5
  from collections.abc import Callable
5
6
  from logging import getLogger
6
7
 
8
+ from fastapi import Request
7
9
  from langchain_core.tools import create_schema_from_function
8
10
 
9
11
  from beamlit.authentication import new_client
@@ -77,7 +79,7 @@ def function(*args, function: Function | dict = None, kit=False, **kwargs: dict)
77
79
  )
78
80
  if isinstance(function, dict):
79
81
  function = Function(**function)
80
-
82
+
81
83
  def wrapper(func: Callable) -> Callable:
82
84
  if function and not func.__doc__ and function.spec and function.spec.description:
83
85
  func.__doc__ = function.spec.description
@@ -90,6 +92,13 @@ def function(*args, function: Function | dict = None, kit=False, **kwargs: dict)
90
92
  parse_docstring=func.__doc__,
91
93
  )
92
94
  return remote_func
93
- return func
95
+
96
+ @functools.wraps(func)
97
+ async def wrapped(*args, **kwargs):
98
+ if isinstance(args[0], Request):
99
+ body = await args[0].json()
100
+ args = [body.get(param) for param in func.__code__.co_varnames[:func.__code__.co_argcount]]
101
+ return func(*args, **kwargs)
102
+ return wrapped
94
103
 
95
104
  return wrapper
beamlit/serve/app.py CHANGED
@@ -71,13 +71,11 @@ async def root(request: Request):
71
71
  settings = get_settings()
72
72
  logger = getLogger(__name__)
73
73
  try:
74
- body = await request.json()
75
-
76
74
  original_func = getattr(func, "__wrapped__", func)
77
75
  if asyncio.iscoroutinefunction(func) or asyncio.iscoroutinefunction(original_func):
78
- response = await func(body)
76
+ response = await func(request)
79
77
  else:
80
- response = func(body)
78
+ response = func(request)
81
79
 
82
80
  if isinstance(response, Response):
83
81
  return response
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: beamlit
3
- Version: 0.0.33rc43
3
+ Version: 0.0.33rc45
4
4
  Summary: Add your description here
5
5
  Author-email: cploujoux <ch.ploujoux@gmail.com>
6
6
  Requires-Python: >=3.12
@@ -141,7 +141,7 @@ beamlit/deploy/deploy.py,sha256=MlFRyKtKNB7Tm9Oo0RJbBtOgch4djm6DTon_z2iPo_k,9945
141
141
  beamlit/deploy/format.py,sha256=PJ8kU7Y1pwiS3tqqyvFaag9LO3jju-4ua574163VPk4,1820
142
142
  beamlit/deploy/parser.py,sha256=Ga0poCZkoRnuTw082QnTcNGCBJncoRAnVsn8-1FsaJE,6907
143
143
  beamlit/functions/__init__.py,sha256=_RPG1Bfg54JGdIPnViAU6n9zD7E1cDNsdXi8oYGskzE,138
144
- beamlit/functions/decorator.py,sha256=YNNU8MZXV2C6gIjxaYhp-FSWGLc9I_XLsIE24zQ3fr8,3541
144
+ beamlit/functions/decorator.py,sha256=N8AiR7XGkKzpZnZHrOd9p9udJ0fnfIrqJfpV9vdfgWA,3903
145
145
  beamlit/functions/github/__init__.py,sha256=gYnUkeegukOfbymdabuuJkScvH-_ZJygX05BoqkPn0o,49
146
146
  beamlit/functions/github/github.py,sha256=FajzLCNkpXcwfgnC0l9rOGT2eSPLCz8-qrMzK9N_ZNc,598
147
147
  beamlit/functions/github/kit/__init__.py,sha256=jBwPqZv6C23_utukohxqXZwrlicNlI7PYPUj0Den7Cw,136
@@ -252,10 +252,10 @@ beamlit/models/websocket_channel.py,sha256=jg3vN7yS_oOIwGtndtIUr1LsyEA58RXLXahqS
252
252
  beamlit/models/workspace.py,sha256=l__bIpbA4oJvxXo7UbEoCcqkvu9MiNt5aXXpZ3bgwHg,4309
253
253
  beamlit/models/workspace_labels.py,sha256=WbnUY6eCTkUNdY7hhhSF-KQCl8fWFfkCf7hzCTiNp4A,1246
254
254
  beamlit/models/workspace_user.py,sha256=70CcifQWYbeWG7TDui4pblTzUe5sVK0AS19vNCzKE8g,3423
255
- beamlit/serve/app.py,sha256=QzReZZjGFQWhNA1XBDq81rsn9zpEihtLZLrfZi9ThT0,3554
255
+ beamlit/serve/app.py,sha256=DXWxQoMeuA5FYvBMyLrP94OEWQbwLf4GZk3I9fkwSPA,3523
256
256
  beamlit/serve/middlewares/__init__.py,sha256=1dVmnOmhAQWvWktqHkKSIX-YoF6fmMU8xkUQuhg_rJU,148
257
257
  beamlit/serve/middlewares/accesslog.py,sha256=Mu4T4_9OvHybjA0ApzZFpgi2C8f3X1NbUk-76v634XM,631
258
258
  beamlit/serve/middlewares/processtime.py,sha256=lDAaIasZ4bwvN-HKHvZpaD9r-yrkVNZYx4abvbjbrCg,411
259
- beamlit-0.0.33rc43.dist-info/METADATA,sha256=-1aXmUqclViF_Hh3-DKwoH-jIzyXlfDCsh1zGQZb-wA,2405
260
- beamlit-0.0.33rc43.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
261
- beamlit-0.0.33rc43.dist-info/RECORD,,
259
+ beamlit-0.0.33rc45.dist-info/METADATA,sha256=ZHk3HMzhN_0knJTaG1X6cOsktBQqPL_lU0918iGBOZ8,2405
260
+ beamlit-0.0.33rc45.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
261
+ beamlit-0.0.33rc45.dist-info/RECORD,,