beamlit 0.0.34rc62__py3-none-any.whl → 0.0.34rc64__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.
- beamlit/agents/chat.py +14 -5
- beamlit/agents/decorator.py +21 -8
- beamlit/functions/decorator.py +3 -2
- {beamlit-0.0.34rc62.dist-info → beamlit-0.0.34rc64.dist-info}/METADATA +1 -1
- {beamlit-0.0.34rc62.dist-info → beamlit-0.0.34rc64.dist-info}/RECORD +6 -6
- {beamlit-0.0.34rc62.dist-info → beamlit-0.0.34rc64.dist-info}/WHEEL +0 -0
beamlit/agents/chat.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
from logging import getLogger
|
2
|
-
from typing import Tuple
|
2
|
+
from typing import Tuple, Union
|
3
3
|
|
4
4
|
from langchain_core.language_models import BaseChatModel
|
5
5
|
|
6
6
|
from beamlit.authentication import get_authentication_headers, new_client
|
7
7
|
from beamlit.common.settings import get_settings
|
8
8
|
from beamlit.models import Model
|
9
|
+
from beamlit.api.models import get_model
|
9
10
|
|
10
11
|
logger = getLogger(__name__)
|
11
12
|
|
@@ -42,11 +43,17 @@ def get_cohere_chat_model(**kwargs):
|
|
42
43
|
|
43
44
|
return ChatCohere(**kwargs)
|
44
45
|
|
45
|
-
def get_chat_model(name: str, agent_model: Model) -> Tuple[BaseChatModel, str, str]:
|
46
|
+
def get_chat_model(name: str, agent_model: Union[Model, None] = None) -> Tuple[BaseChatModel, str, str]:
|
46
47
|
settings = get_settings()
|
47
48
|
client = new_client()
|
48
49
|
|
49
|
-
|
50
|
+
if agent_model is None:
|
51
|
+
try:
|
52
|
+
agent_model = get_model.sync(name, client=client, environment=settings.environment)
|
53
|
+
except Exception as e:
|
54
|
+
logger.warning(f"Model {name} not found, defaulting to gpt-4o-mini")
|
55
|
+
|
56
|
+
environment = (agent_model and agent_model.metadata and agent_model.metadata.environment) or settings.environment
|
50
57
|
headers = get_authentication_headers(settings)
|
51
58
|
headers["X-Beamlit-Environment"] = environment
|
52
59
|
|
@@ -87,7 +94,8 @@ def get_chat_model(name: str, agent_model: Model) -> Tuple[BaseChatModel, str, s
|
|
87
94
|
}
|
88
95
|
|
89
96
|
provider = (
|
90
|
-
agent_model
|
97
|
+
agent_model
|
98
|
+
and agent_model.spec
|
91
99
|
and agent_model.spec.runtime
|
92
100
|
and agent_model.spec.runtime.type_
|
93
101
|
)
|
@@ -96,7 +104,8 @@ def get_chat_model(name: str, agent_model: Model) -> Tuple[BaseChatModel, str, s
|
|
96
104
|
provider = "openai"
|
97
105
|
|
98
106
|
model = (
|
99
|
-
agent_model
|
107
|
+
agent_model
|
108
|
+
and agent_model.spec
|
100
109
|
and agent_model.spec.runtime
|
101
110
|
and agent_model.spec.runtime.model
|
102
111
|
)
|
beamlit/agents/decorator.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Import necessary modules
|
2
2
|
import functools
|
3
|
+
import inspect
|
3
4
|
from logging import getLogger
|
4
5
|
|
5
6
|
from langgraph.checkpoint.memory import MemorySaver
|
@@ -34,15 +35,27 @@ def agent(
|
|
34
35
|
settings = init()
|
35
36
|
|
36
37
|
def wrapper(func):
|
38
|
+
agent_kwargs = any(
|
39
|
+
param.name == "agent"
|
40
|
+
for param in inspect.signature(func).parameters.values()
|
41
|
+
)
|
42
|
+
model_kwargs = any(
|
43
|
+
param.name == "model"
|
44
|
+
for param in inspect.signature(func).parameters.values()
|
45
|
+
)
|
46
|
+
functions_kwargs = any(
|
47
|
+
param.name == "functions"
|
48
|
+
for param in inspect.signature(func).parameters.values()
|
49
|
+
)
|
37
50
|
@functools.wraps(func)
|
38
51
|
def wrapped(*args, **kwargs):
|
39
|
-
|
40
|
-
settings.agent.agent
|
41
|
-
|
42
|
-
settings.agent.
|
43
|
-
|
44
|
-
|
45
|
-
)
|
52
|
+
if agent_kwargs:
|
53
|
+
kwargs["agent"] = settings.agent.agent
|
54
|
+
if model_kwargs:
|
55
|
+
kwargs["model"] = settings.agent.chat_model
|
56
|
+
if functions_kwargs:
|
57
|
+
kwargs["functions"] = settings.agent.functions
|
58
|
+
return func(*args, **kwargs)
|
46
59
|
|
47
60
|
return wrapped
|
48
61
|
|
@@ -85,7 +98,7 @@ def agent(
|
|
85
98
|
remote_functions_empty=not remote_functions,
|
86
99
|
)
|
87
100
|
settings.agent.functions = functions
|
88
|
-
|
101
|
+
|
89
102
|
if override_agent is None and len(functions) == 0:
|
90
103
|
raise ValueError(
|
91
104
|
"You must define at least one function, you can define this function in directory "
|
beamlit/functions/decorator.py
CHANGED
@@ -12,7 +12,6 @@ from fastapi import Request
|
|
12
12
|
from langchain_core.tools import StructuredTool
|
13
13
|
from langchain_core.tools.base import create_schema_from_function
|
14
14
|
|
15
|
-
from beamlit.agents.chain import ChainToolkit
|
16
15
|
from beamlit.authentication import new_client
|
17
16
|
from beamlit.client import AuthenticatedClient
|
18
17
|
from beamlit.common import slugify
|
@@ -32,6 +31,8 @@ def get_functions(
|
|
32
31
|
remote_functions_empty:bool=True,
|
33
32
|
from_decorator:str="function",
|
34
33
|
):
|
34
|
+
from beamlit.agents.chain import ChainToolkit
|
35
|
+
|
35
36
|
settings = get_settings()
|
36
37
|
if client is None:
|
37
38
|
client = new_client()
|
@@ -116,7 +117,7 @@ def get_functions(
|
|
116
117
|
)
|
117
118
|
)
|
118
119
|
else:
|
119
|
-
|
120
|
+
|
120
121
|
functions.append(
|
121
122
|
StructuredTool(
|
122
123
|
name=func.__name__,
|
@@ -6,8 +6,8 @@ beamlit/run.py,sha256=HtDYDjD7oVfQ8r3T5_t4qN5UDJOJfsQILi45Z21ArAg,1446
|
|
6
6
|
beamlit/types.py,sha256=E1hhDh_zXfsSQ0NCt9-uw90_Mr5iIlsdfnfvxv5HarU,1005
|
7
7
|
beamlit/agents/__init__.py,sha256=nf1iwQwGtCG6nDqyVhxfWoqR6dv6X3bvSpCeqkTCFaM,101
|
8
8
|
beamlit/agents/chain.py,sha256=vfCjiFHuu02uTTGicxMlFzjyICQkIjpXrBGs-7uJEsg,2826
|
9
|
-
beamlit/agents/chat.py,sha256=
|
10
|
-
beamlit/agents/decorator.py,sha256=
|
9
|
+
beamlit/agents/chat.py,sha256=b7-ZkRqgS7nxFLbh_fOf9riAoPYnlb9_vHxaf2xYuvI,4057
|
10
|
+
beamlit/agents/decorator.py,sha256=JWz74ugL-walNXMths2517CE-LBDoeSf_wQeM8mCPa4,4768
|
11
11
|
beamlit/api/__init__.py,sha256=zTSiG_ujSjAqWPyc435YXaX9XTlpMjiJWBbV-f-YtdA,45
|
12
12
|
beamlit/api/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
13
|
beamlit/api/agents/create_agent.py,sha256=t5Pr62My2EhQlcIY71MrI73-0_q5Djr3a_Ybt9MIiQQ,3587
|
@@ -141,7 +141,7 @@ beamlit/deploy/deploy.py,sha256=h8ugvkSGcMKLqM-_uD5BZUzng5tJRp-Gea1Jup6QzTE,1025
|
|
141
141
|
beamlit/deploy/format.py,sha256=U6UZEFAYLnGJJ7O2YmSdlUUFhnWNGAv6NZ-DW4KTgvI,2049
|
142
142
|
beamlit/deploy/parser.py,sha256=Ga0poCZkoRnuTw082QnTcNGCBJncoRAnVsn8-1FsaJE,6907
|
143
143
|
beamlit/functions/__init__.py,sha256=NcQPZZNfWhAJ1T1F6Xn21LFPMbZ7aMR2Sve3uZOkBCQ,170
|
144
|
-
beamlit/functions/decorator.py,sha256=
|
144
|
+
beamlit/functions/decorator.py,sha256=WkNF4-Y6XC9m-W9LRDJpzQEruQf98FxLpdY-Tc1VCUE,8679
|
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
|
@@ -262,6 +262,6 @@ beamlit/serve/app.py,sha256=_aG2UVQ3Y85rUW3ehu9TlzLnowkfh54IIz558ftqOMw,3638
|
|
262
262
|
beamlit/serve/middlewares/__init__.py,sha256=1dVmnOmhAQWvWktqHkKSIX-YoF6fmMU8xkUQuhg_rJU,148
|
263
263
|
beamlit/serve/middlewares/accesslog.py,sha256=Mu4T4_9OvHybjA0ApzZFpgi2C8f3X1NbUk-76v634XM,631
|
264
264
|
beamlit/serve/middlewares/processtime.py,sha256=lDAaIasZ4bwvN-HKHvZpaD9r-yrkVNZYx4abvbjbrCg,411
|
265
|
-
beamlit-0.0.
|
266
|
-
beamlit-0.0.
|
267
|
-
beamlit-0.0.
|
265
|
+
beamlit-0.0.34rc64.dist-info/METADATA,sha256=Nc9HziVd7JjcSU0GAaVxtvrcmNvJo42lpVAqtjSlXY0,2412
|
266
|
+
beamlit-0.0.34rc64.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
267
|
+
beamlit-0.0.34rc64.dist-info/RECORD,,
|
File without changes
|