lionagi 0.8.7__py3-none-any.whl → 0.9.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.
- lionagi/__init__.py +1 -1
- lionagi/_class_registry.py +1 -1
- lionagi/_errors.py +1 -1
- lionagi/libs/__init__.py +1 -1
- lionagi/libs/file/__init__.py +1 -1
- lionagi/libs/file/chunk.py +1 -1
- lionagi/libs/file/file_ops.py +1 -1
- lionagi/libs/file/params.py +1 -1
- lionagi/libs/file/process.py +1 -1
- lionagi/libs/file/save.py +1 -1
- lionagi/libs/nested/__init__.py +1 -1
- lionagi/libs/nested/flatten.py +1 -1
- lionagi/libs/nested/nfilter.py +1 -1
- lionagi/libs/nested/nget.py +1 -1
- lionagi/libs/nested/ninsert.py +1 -1
- lionagi/libs/nested/nmerge.py +1 -1
- lionagi/libs/nested/npop.py +1 -1
- lionagi/libs/nested/nset.py +1 -1
- lionagi/libs/nested/unflatten.py +1 -1
- lionagi/libs/nested/utils.py +1 -1
- lionagi/libs/package/__init__.py +1 -1
- lionagi/libs/package/imports.py +1 -1
- lionagi/libs/package/management.py +1 -1
- lionagi/libs/package/params.py +1 -1
- lionagi/libs/package/system.py +1 -1
- lionagi/libs/parse.py +1 -1
- lionagi/libs/schema/__init__.py +1 -1
- lionagi/libs/schema/as_readable.py +151 -87
- lionagi/libs/schema/extract_code_block.py +1 -1
- lionagi/libs/schema/extract_docstring.py +1 -1
- lionagi/libs/schema/function_to_schema.py +1 -1
- lionagi/libs/schema/json_schema.py +1 -1
- lionagi/libs/validate/__init__.py +1 -1
- lionagi/libs/validate/common_field_validators.py +1 -1
- lionagi/libs/validate/fuzzy_match_keys.py +1 -1
- lionagi/libs/validate/fuzzy_validate_mapping.py +1 -1
- lionagi/libs/validate/string_similarity.py +1 -1
- lionagi/libs/validate/validate_boolean.py +1 -1
- lionagi/operations/ReAct/ReAct.py +54 -8
- lionagi/operations/ReAct/__init__.py +1 -1
- lionagi/operations/ReAct/utils.py +6 -1
- lionagi/operations/__init__.py +1 -1
- lionagi/operations/_act/__init__.py +1 -1
- lionagi/operations/_act/act.py +6 -1
- lionagi/operations/brainstorm/__init__.py +1 -1
- lionagi/operations/brainstorm/brainstorm.py +1 -1
- lionagi/operations/brainstorm/prompt.py +1 -1
- lionagi/operations/chat/__init__.py +1 -1
- lionagi/operations/chat/chat.py +1 -1
- lionagi/operations/communicate/communicate.py +1 -1
- lionagi/operations/instruct/__init__.py +1 -1
- lionagi/operations/instruct/instruct.py +1 -1
- lionagi/operations/interpret/__init__.py +1 -1
- lionagi/operations/interpret/interpret.py +9 -38
- lionagi/operations/operate/__init__.py +1 -1
- lionagi/operations/operate/operate.py +1 -1
- lionagi/operations/parse/__init__.py +1 -1
- lionagi/operations/parse/parse.py +12 -2
- lionagi/operations/plan/__init__.py +1 -1
- lionagi/operations/plan/plan.py +1 -1
- lionagi/operations/plan/prompt.py +1 -1
- lionagi/operations/select/__init__.py +1 -1
- lionagi/operations/select/select.py +1 -1
- lionagi/operations/select/utils.py +1 -1
- lionagi/operations/types.py +1 -1
- lionagi/operations/utils.py +1 -1
- lionagi/operatives/__init__.py +1 -1
- lionagi/operatives/action/__init__.py +1 -1
- lionagi/operatives/action/function_calling.py +1 -1
- lionagi/operatives/action/manager.py +1 -1
- lionagi/operatives/action/request_response_model.py +1 -1
- lionagi/operatives/action/tool.py +1 -1
- lionagi/operatives/action/utils.py +1 -1
- lionagi/operatives/forms/__init__.py +1 -1
- lionagi/operatives/instruct/__init__.py +1 -1
- lionagi/operatives/instruct/base.py +1 -1
- lionagi/operatives/instruct/instruct.py +1 -1
- lionagi/operatives/instruct/instruct_collection.py +1 -1
- lionagi/operatives/instruct/node.py +1 -1
- lionagi/operatives/instruct/prompts.py +1 -1
- lionagi/operatives/instruct/reason.py +1 -1
- lionagi/operatives/manager.py +1 -1
- lionagi/operatives/models/__init__.py +1 -1
- lionagi/operatives/models/field_model.py +1 -1
- lionagi/operatives/models/model_params.py +1 -1
- lionagi/operatives/models/note.py +1 -1
- lionagi/operatives/models/operable_model.py +1 -1
- lionagi/operatives/models/schema_model.py +1 -1
- lionagi/operatives/operative.py +1 -1
- lionagi/operatives/step.py +1 -1
- lionagi/operatives/strategies/__init__.py +1 -1
- lionagi/operatives/strategies/base.py +1 -1
- lionagi/operatives/strategies/concurrent.py +1 -1
- lionagi/operatives/strategies/concurrent_chunk.py +1 -1
- lionagi/operatives/strategies/concurrent_sequential_chunk.py +1 -1
- lionagi/operatives/strategies/params.py +1 -1
- lionagi/operatives/strategies/sequential.py +1 -1
- lionagi/operatives/strategies/sequential_chunk.py +1 -1
- lionagi/operatives/strategies/sequential_concurrent_chunk.py +1 -1
- lionagi/operatives/strategies/utils.py +1 -1
- lionagi/operatives/types.py +1 -1
- lionagi/protocols/__init__.py +1 -1
- lionagi/protocols/_concepts.py +1 -1
- lionagi/protocols/adapters/adapter.py +1 -1
- lionagi/protocols/generic/__init__.py +1 -1
- lionagi/protocols/generic/element.py +1 -1
- lionagi/protocols/generic/event.py +11 -1
- lionagi/protocols/generic/log.py +1 -1
- lionagi/protocols/generic/pile.py +1 -1
- lionagi/protocols/generic/processor.py +11 -3
- lionagi/protocols/generic/progression.py +1 -1
- lionagi/protocols/graph/__init__.py +1 -1
- lionagi/protocols/graph/edge.py +1 -1
- lionagi/protocols/graph/graph.py +1 -1
- lionagi/protocols/graph/node.py +1 -1
- lionagi/protocols/mail/__init__.py +1 -1
- lionagi/protocols/mail/exchange.py +1 -1
- lionagi/protocols/mail/mail.py +1 -1
- lionagi/protocols/mail/mailbox.py +1 -1
- lionagi/protocols/mail/manager.py +1 -1
- lionagi/protocols/mail/package.py +1 -1
- lionagi/protocols/messages/__init__.py +1 -1
- lionagi/protocols/messages/action_request.py +1 -1
- lionagi/protocols/messages/action_response.py +1 -1
- lionagi/protocols/messages/assistant_response.py +1 -1
- lionagi/protocols/messages/base.py +1 -1
- lionagi/protocols/messages/instruction.py +2 -1
- lionagi/protocols/messages/manager.py +1 -1
- lionagi/protocols/messages/message.py +1 -1
- lionagi/protocols/messages/system.py +1 -1
- lionagi/protocols/types.py +1 -1
- lionagi/service/endpoints/__init__.py +1 -1
- lionagi/service/endpoints/base.py +192 -74
- lionagi/service/endpoints/chat_completion.py +11 -5
- lionagi/service/endpoints/match_endpoint.py +1 -1
- lionagi/service/endpoints/rate_limited_processor.py +18 -7
- lionagi/service/endpoints/token_calculator.py +1 -1
- lionagi/service/imodel.py +65 -12
- lionagi/service/manager.py +1 -1
- lionagi/service/providers/__init__.py +1 -1
- lionagi/service/providers/anthropic_/__init__.py +1 -1
- lionagi/service/providers/anthropic_/messages.py +1 -1
- lionagi/service/providers/groq_/__init__.py +1 -1
- lionagi/service/providers/groq_/chat_completions.py +1 -1
- lionagi/service/providers/openai_/__init__.py +1 -1
- lionagi/service/providers/openai_/chat_completions.py +37 -2
- lionagi/service/providers/openrouter_/__init__.py +1 -1
- lionagi/service/providers/openrouter_/chat_completions.py +1 -1
- lionagi/service/providers/perplexity_/__init__.py +1 -1
- lionagi/service/providers/perplexity_/chat_completions.py +1 -1
- lionagi/service/types.py +1 -1
- lionagi/session/__init__.py +1 -1
- lionagi/session/branch.py +35 -8
- lionagi/session/prompts.py +61 -0
- lionagi/session/session.py +1 -1
- lionagi/settings.py +1 -1
- lionagi/tools/file/__init__.py +0 -0
- lionagi/tools/{reader.py → file/reader.py} +13 -8
- lionagi/tools/types.py +1 -1
- lionagi/utils.py +1 -1
- lionagi/version.py +1 -1
- {lionagi-0.8.7.dist-info → lionagi-0.9.0.dist-info}/METADATA +6 -3
- lionagi-0.9.0.dist-info/RECORD +202 -0
- lionagi-0.8.7.dist-info/RECORD +0 -200
- {lionagi-0.8.7.dist-info → lionagi-0.9.0.dist-info}/WHEEL +0 -0
- {lionagi-0.8.7.dist-info → lionagi-0.9.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2023 -
|
1
|
+
# Copyright (c) 2023 - 2025, HaiyangLi <quantocean.li at gmail dot com>
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
4
4
|
|
@@ -90,3 +90,8 @@ class ReActAnalysis(BaseModel):
|
|
90
90
|
"provide if and only if action_strategy is 'batch', this specifies the number of actions to run in parallel per batch."
|
91
91
|
),
|
92
92
|
)
|
93
|
+
|
94
|
+
|
95
|
+
class Analysis(BaseModel):
|
96
|
+
|
97
|
+
answer: str
|
lionagi/operations/__init__.py
CHANGED
lionagi/operations/_act/act.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2023 -
|
1
|
+
# Copyright (c) 2023 - 2025, HaiyangLi <quantocean.li at gmail dot com>
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
4
4
|
|
@@ -35,6 +35,11 @@ async def _act(
|
|
35
35
|
_request["arguments"] = action_request["arguments"]
|
36
36
|
|
37
37
|
try:
|
38
|
+
if verbose_action:
|
39
|
+
args_ = str(_request["arguments"])
|
40
|
+
args_ = args_[:50] + "..." if len(args_) > 50 else args_
|
41
|
+
print(f"Invoking action {_request['function']} with {args_}.")
|
42
|
+
|
38
43
|
func_call = await branch._action_manager.invoke(_request)
|
39
44
|
if verbose_action:
|
40
45
|
print(
|
lionagi/operations/chat/chat.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2023 -
|
1
|
+
# Copyright (c) 2023 - 2025, HaiyangLi <quantocean.li at gmail dot com>
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
4
4
|
|
@@ -14,45 +14,14 @@ async def interpret(
|
|
14
14
|
domain: str | None = None,
|
15
15
|
style: str | None = None,
|
16
16
|
sample_writing: str | None = None,
|
17
|
+
interpret_model: str | None = None,
|
17
18
|
**kwargs,
|
18
19
|
) -> str:
|
19
|
-
instruction =
|
20
|
-
You are given a user's raw instruction or question. Your task is to rewrite it into a clearer,
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
1. **Dissect the user's request**:
|
25
|
-
- If the user references a local file, note it clearly (e.g., "paper_file_path": "…").
|
26
|
-
- If the user might need external references or up-to-date data, mention that possibility.
|
27
|
-
- If the user's question is ambiguous, propose clarifications.
|
28
|
-
|
29
|
-
2. **Be explicit about the user's final objective**:
|
30
|
-
- For example, if the user wants a comparison with other works, add that as a bullet point or sub-question.
|
31
|
-
- If the user wants a summary plus code snippet, highlight that in your structured prompt.
|
32
|
-
|
33
|
-
3. **Do NOT produce final system actions**:
|
34
|
-
- You're not calling any tools directly here; only rewriting the user query to reflect potential next steps.
|
35
|
-
- If the user's request might require searching or doc reading, note it as an *option*, e.g. "Potential tool usage: {search, partial doc read}."
|
36
|
-
|
37
|
-
4. **Return only the improved user prompt**:
|
38
|
-
- The final output should be a single text block or short JSON specifying the clarified user request.
|
39
|
-
- Keep it concise yet thorough.
|
40
|
-
|
41
|
-
For instance, if the user's original text is:
|
42
|
-
"Please read my local PDF on RL and compare it to the newest research methods from exa or perplexity."
|
43
|
-
|
44
|
-
A re-written version might be:
|
45
|
-
"**Task**:
|
46
|
-
- Summarize the local PDF (paper_file_path: 'myRLpaper.pdf').
|
47
|
-
- Compare its approach with recent reinforcement learning research found via exa/perplexity searches.
|
48
|
-
**Potential Tool Usage**:
|
49
|
-
- Doc reading (reader_tool)
|
50
|
-
- External search (search_exa, search_perplexity)
|
51
|
-
**Output**:
|
52
|
-
- A structured summary + comparative analysis."
|
53
|
-
|
54
|
-
Now, apply this rewriting to the input below. Return only the re-written prompt.
|
55
|
-
"""
|
20
|
+
instruction = (
|
21
|
+
"You are given a user's raw instruction or question. Your task is to rewrite it into a clearer,"
|
22
|
+
"more structured prompt for an LLM or system, making any implicit or missing details explicit. "
|
23
|
+
"Return only the re-written prompt."
|
24
|
+
)
|
56
25
|
guidance = (
|
57
26
|
f"Domain hint: {domain or 'general'}. "
|
58
27
|
f"Desired style: {style or 'concise'}. "
|
@@ -66,6 +35,8 @@ Now, apply this rewriting to the input below. Return only the re-written prompt.
|
|
66
35
|
kwargs["guidance"] = guidance + "\n" + kwargs.get("guidance", "")
|
67
36
|
kwargs["instruction"] = instruction + "\n" + kwargs.get("instruction", "")
|
68
37
|
kwargs["temperature"] = kwargs.get("temperature", 0.1)
|
38
|
+
if interpret_model:
|
39
|
+
kwargs["chat_model"] = interpret_model
|
69
40
|
|
70
41
|
refined_prompt = await branch.chat(
|
71
42
|
context=context,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2023 -
|
1
|
+
# Copyright (c) 2023 - 2025, HaiyangLi <quantocean.li at gmail dot com>
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
4
4
|
|
@@ -48,6 +48,8 @@ async def parse(
|
|
48
48
|
and not isinstance(response_model, BaseModel)
|
49
49
|
):
|
50
50
|
num_try += 1
|
51
|
+
if num_try == max_retries:
|
52
|
+
_should_try = False
|
51
53
|
_, res = await branch.chat(
|
52
54
|
instruction="reformat text into specified model",
|
53
55
|
guidane="follow the required response format, using the model schema as a guide",
|
@@ -73,7 +75,15 @@ async def parse(
|
|
73
75
|
strict=strict,
|
74
76
|
suppress_conversion_errors=suppress_conversion_errors,
|
75
77
|
)
|
76
|
-
|
78
|
+
try:
|
79
|
+
response_model = request_type.model_validate(response_model)
|
80
|
+
except InterruptedError as e:
|
81
|
+
raise e
|
82
|
+
except Exception:
|
83
|
+
if _should_try:
|
84
|
+
continue
|
85
|
+
else:
|
86
|
+
break
|
77
87
|
|
78
88
|
if not isinstance(response_model, BaseModel):
|
79
89
|
match handle_validation:
|
lionagi/operations/plan/plan.py
CHANGED
lionagi/operations/types.py
CHANGED
lionagi/operations/utils.py
CHANGED
lionagi/operatives/__init__.py
CHANGED
lionagi/operatives/manager.py
CHANGED
lionagi/operatives/operative.py
CHANGED
lionagi/operatives/step.py
CHANGED
lionagi/operatives/types.py
CHANGED
lionagi/protocols/__init__.py
CHANGED
lionagi/protocols/_concepts.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2023 -
|
1
|
+
# Copyright (c) 2023 - 2025, HaiyangLi <quantocean.li at gmail dot com>
|
2
2
|
#
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
4
4
|
|
@@ -86,6 +86,7 @@ class Event(Element):
|
|
86
86
|
"""
|
87
87
|
|
88
88
|
execution: Execution = Field(default_factory=Execution)
|
89
|
+
streaming: bool = False
|
89
90
|
|
90
91
|
@field_serializer("execution")
|
91
92
|
def _serialize_execution(self, val: Execution) -> dict:
|
@@ -160,6 +161,15 @@ class Event(Element):
|
|
160
161
|
"""
|
161
162
|
raise NotImplementedError("Override in subclass.")
|
162
163
|
|
164
|
+
async def stream(self) -> None:
|
165
|
+
"""Performs the event action asynchronously, streaming results.
|
166
|
+
|
167
|
+
Raises:
|
168
|
+
NotImplementedError: This base method must be overridden by
|
169
|
+
subclasses.
|
170
|
+
"""
|
171
|
+
raise NotImplementedError("Override in subclass.")
|
172
|
+
|
163
173
|
@classmethod
|
164
174
|
def from_dict(cls, data: dict) -> "Event":
|
165
175
|
"""Not implemented. Events cannot be fully recreated once done.
|
lionagi/protocols/generic/log.py
CHANGED