lionagi 0.11.0__py3-none-any.whl → 0.12.1__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 (41) hide show
  1. lionagi/adapters/__init__.py +1 -0
  2. lionagi/fields/file.py +1 -1
  3. lionagi/fields/reason.py +1 -1
  4. lionagi/libs/file/concat.py +6 -1
  5. lionagi/libs/file/concat_files.py +5 -1
  6. lionagi/libs/file/create_path.py +80 -0
  7. lionagi/libs/file/file_util.py +358 -0
  8. lionagi/libs/file/save.py +1 -1
  9. lionagi/libs/package/imports.py +177 -8
  10. lionagi/libs/parse/fuzzy_parse_json.py +117 -0
  11. lionagi/libs/parse/to_dict.py +336 -0
  12. lionagi/libs/parse/to_json.py +61 -0
  13. lionagi/libs/parse/to_num.py +378 -0
  14. lionagi/libs/parse/to_xml.py +57 -0
  15. lionagi/libs/parse/xml_parser.py +148 -0
  16. lionagi/libs/schema/breakdown_pydantic_annotation.py +48 -0
  17. lionagi/protocols/generic/log.py +2 -1
  18. lionagi/service/providers/exa_/models.py +2 -159
  19. lionagi/service/providers/perplexity_/models.py +4 -143
  20. lionagi/utils.py +123 -921
  21. lionagi/version.py +1 -1
  22. {lionagi-0.11.0.dist-info → lionagi-0.12.1.dist-info}/METADATA +8 -11
  23. {lionagi-0.11.0.dist-info → lionagi-0.12.1.dist-info}/RECORD +26 -32
  24. lionagi/libs/parse.py +0 -30
  25. lionagi/tools/browser/__init__.py +0 -0
  26. lionagi/tools/browser/providers/browser_use_.py +0 -3
  27. lionagi/tools/code/__init__.py +0 -3
  28. lionagi/tools/code/coder.py +0 -3
  29. lionagi/tools/code/manager.py +0 -3
  30. lionagi/tools/code/providers/__init__.py +0 -3
  31. lionagi/tools/code/providers/aider_.py +0 -3
  32. lionagi/tools/code/providers/e2b_.py +0 -3
  33. lionagi/tools/code/sandbox.py +0 -3
  34. lionagi/tools/file/manager.py +0 -3
  35. lionagi/tools/file/providers/__init__.py +0 -3
  36. lionagi/tools/file/providers/docling_.py +0 -3
  37. lionagi/tools/file/writer.py +0 -3
  38. lionagi/tools/query/__init__.py +0 -3
  39. /lionagi/{tools/browser/providers → libs/parse}/__init__.py +0 -0
  40. {lionagi-0.11.0.dist-info → lionagi-0.12.1.dist-info}/WHEEL +0 -0
  41. {lionagi-0.11.0.dist-info → lionagi-0.12.1.dist-info}/licenses/LICENSE +0 -0
@@ -1,160 +1,3 @@
1
- from enum import Enum
1
+ from khive.providers.exa_ import ExaSearchRequest
2
2
 
3
- from pydantic import BaseModel, Field
4
-
5
-
6
- class CategoryEnum(str, Enum):
7
- company = "company"
8
- research_paper = "research paper"
9
- news = "news"
10
- pdf = "pdf"
11
- github = "github"
12
- tweet = "tweet"
13
- personal_site = "personal site"
14
- linkedin_profile = "linkedin profile"
15
- financial_report = "financial report"
16
-
17
-
18
- class LivecrawlEnum(str, Enum):
19
- never = "never"
20
- fallback = "fallback"
21
- always = "always"
22
-
23
-
24
- class SearchTypeEnum(str, Enum):
25
- keyword = "keyword"
26
- neural = "neural"
27
- auto = "auto"
28
-
29
-
30
- class ContentsText(BaseModel):
31
- includeHtmlTags: bool | None = Field(
32
- default=False,
33
- description="Whether to include HTML tags in the text. Set to True if you want to retain HTML structure for the LLM to interpret.",
34
- )
35
- maxCharacters: int | None = Field(
36
- default=None,
37
- description="The maximum number of characters to return from the webpage text.",
38
- )
39
-
40
-
41
- class ContentsHighlights(BaseModel):
42
- highlightsPerUrl: int | None = Field(
43
- default=1,
44
- description="The number of highlight snippets you want per page.",
45
- )
46
- numSentences: int | None = Field(
47
- default=5,
48
- description="Number of sentences to return in each highlight snippet.",
49
- )
50
- query: None | str = Field(
51
- default=None,
52
- description="A specific query used to generate the highlight snippets.",
53
- )
54
-
55
-
56
- class ContentsSummary(BaseModel):
57
- query: None | str = Field(
58
- default=None,
59
- description="A specific query used to generate a summary of the webpage.",
60
- )
61
-
62
-
63
- class ContentsExtras(BaseModel):
64
- links: int | None = Field(
65
- default=None, description="Number of links to return from each page."
66
- )
67
- imageLinks: int | None = Field(
68
- default=None, description="Number of images to return for each result."
69
- )
70
-
71
-
72
- class Contents(BaseModel):
73
- text: None | ContentsText = Field(
74
- default=None,
75
- description="Return full or partial text for each page, with optional HTML structure or size limit.",
76
- )
77
- highlights: None | ContentsHighlights = Field(
78
- default=None, description="Return snippet highlights for each page."
79
- )
80
- summary: None | ContentsSummary = Field(
81
- default=None, description="Return a short summary of each page."
82
- )
83
- livecrawl: None | LivecrawlEnum = Field(
84
- default=LivecrawlEnum.never,
85
- description="Livecrawling setting for each page. Options: never, fallback, always.",
86
- )
87
- livecrawlTimeout: int | None = Field(
88
- default=10000,
89
- description="Timeout in milliseconds for livecrawling. Default 10000.",
90
- )
91
- subpages: int | None = Field(
92
- default=None,
93
- description="Number of subpages to crawl within each URL.",
94
- )
95
- subpageTarget: None | str | list[str] = Field(
96
- default=None,
97
- description="A target subpage or multiple subpages (list) to crawl, e.g. 'cited papers'.",
98
- )
99
- extras: None | ContentsExtras = Field(
100
- default=None,
101
- description="Additional extras like links or images to return for each page.",
102
- )
103
-
104
-
105
- class ExaSearchRequest(BaseModel):
106
- query: str = Field(
107
- ...,
108
- description="The main query string describing what you're looking for.",
109
- )
110
- category: None | CategoryEnum = Field(
111
- default=None,
112
- description="A data category to focus on, such as 'company', 'research paper', 'news', etc.",
113
- )
114
- type: None | SearchTypeEnum = Field(
115
- default=None,
116
- description="The type of search to run. Can be 'auto', 'keyword', or 'neural'.",
117
- )
118
- useAutoprompt: None | bool = Field(
119
- default=False,
120
- description="If True, Exa auto-optimizes your query for best results (neural or auto search only).",
121
- )
122
- numResults: int | None = Field(
123
- default=10, description="Number of results to return. Default is 10."
124
- )
125
- includeDomains: None | list[str] = Field(
126
- default=None,
127
- description="List of domains you want to include exclusively.",
128
- )
129
- excludeDomains: None | list[str] = Field(
130
- default=None,
131
- description="List of domains you do NOT want to see in the results.",
132
- )
133
- startCrawlDate: None | str = Field(
134
- default=None,
135
- description="Include results crawled after this ISO date (e.g., '2023-01-01T00:00:00.000Z').",
136
- )
137
- endCrawlDate: None | str = Field(
138
- default=None,
139
- description="Include results crawled before this ISO date.",
140
- )
141
- startPublishedDate: None | str = Field(
142
- default=None,
143
- description="Only return results published after this ISO date.",
144
- )
145
- endPublishedDate: None | str = Field(
146
- default=None,
147
- description="Only return results published before this ISO date.",
148
- )
149
- includeText: None | list[str] = Field(
150
- default=None,
151
- description="Strings that must appear in the webpage text. Only a single string up to 5 words is currently supported.",
152
- )
153
- excludeText: None | list[str] = Field(
154
- default=None,
155
- description="Strings that must NOT appear in the webpage text. Only a single string up to 5 words is currently supported.",
156
- )
157
- contents: None | Contents = Field(
158
- default=None,
159
- description="Dict defining the different ways you want to retrieve webpage contents, including text, highlights, or summaries.",
160
- )
3
+ __all__ = ("ExaSearchRequest",)
@@ -1,144 +1,5 @@
1
- from enum import Enum
2
- from typing import Any
1
+ from khive.providers.perplexity_ import (
2
+ PerplexityChatRequest as PerplexityChatCompletionRequest,
3
+ )
3
4
 
4
- from pydantic import BaseModel, Field, model_validator
5
-
6
-
7
- class PerplexityRole(str, Enum):
8
- """Roles allowed in Perplexity's messages."""
9
-
10
- system = "system"
11
- user = "user"
12
- assistant = "assistant"
13
-
14
-
15
- class PerplexityMessage(BaseModel):
16
- """
17
- A single message in the conversation.
18
- `role` can be 'system', 'user', or 'assistant'.
19
- `content` is the text for that conversation turn.
20
- """
21
-
22
- role: PerplexityRole = Field(
23
- ...,
24
- description="The role of the speaker. Must be system, user, or assistant.",
25
- )
26
- content: str = Field(..., description="The text content of this message.")
27
-
28
-
29
- class PerplexityChatCompletionRequest(BaseModel):
30
- """
31
- Represents the request body for Perplexity's Chat Completions endpoint.
32
- Endpoint: POST https://api.perplexity.ai/chat/completions
33
- """
34
-
35
- model: str = Field(
36
- "sonar",
37
- description="The model name, e.g. 'sonar', (the only model available at the time when this request model was updated, check doc for latest info).",
38
- )
39
- messages: list[PerplexityMessage] = Field(
40
- ..., description="A list of messages forming the conversation so far."
41
- )
42
-
43
- # Optional parameters
44
- frequency_penalty: float | None = Field(
45
- default=None,
46
- gt=0,
47
- description=(
48
- "Multiplicative penalty > 0. Values > 1.0 penalize repeated tokens more strongly. "
49
- "Value=1.0 means no penalty. Incompatible with presence_penalty."
50
- ),
51
- )
52
- presence_penalty: float | None = Field(
53
- default=None,
54
- ge=-2.0,
55
- le=2.0,
56
- description=(
57
- "Penalizes tokens that have appeared so far (range -2 to 2). "
58
- "Positive values encourage talking about new topics. Incompatible with frequency_penalty."
59
- ),
60
- )
61
- max_tokens: int | None = Field(
62
- default=None,
63
- description=(
64
- "Maximum number of completion tokens. If omitted, model generates tokens until it "
65
- "hits stop or context limit."
66
- ),
67
- )
68
- return_images: bool | None = Field(
69
- default=None,
70
- description="If True, attempt to return images (closed beta feature).",
71
- )
72
- return_related_questions: bool | None = Field(
73
- default=None,
74
- description="If True, attempt to return related questions (closed beta feature).",
75
- )
76
- search_domain_filter: list[Any] | None = Field(
77
- default=None,
78
- description=(
79
- "List of domains to limit or exclude in the online search. Example: ['example.com', '-twitter.com']. "
80
- "Supports up to 3 entries. (Closed beta feature.)"
81
- ),
82
- )
83
- search_recency_filter: str | None = Field(
84
- default=None,
85
- description=(
86
- "Returns search results within a specified time interval: 'month', 'week', 'day', or 'hour'."
87
- ),
88
- )
89
- stream: bool | None = Field(
90
- default=None,
91
- description=(
92
- "If True, response is returned incrementally via Server-Sent Events (SSE)."
93
- ),
94
- )
95
- temperature: float | None = Field(
96
- default=None,
97
- ge=0.0,
98
- lt=2.0,
99
- description=(
100
- "Controls randomness of sampling, range [0, 2). Higher => more random. "
101
- "Defaults to 0.2."
102
- ),
103
- )
104
- top_k: int | None = Field(
105
- default=None,
106
- ge=0,
107
- le=2048,
108
- description=(
109
- "Top-K filtering. 0 disables top-k filtering. If set, only the top K tokens are considered. "
110
- "We recommend altering either top_k or top_p, but not both."
111
- ),
112
- )
113
- top_p: float | None = Field(
114
- default=None,
115
- ge=0.0,
116
- le=1.0,
117
- description=(
118
- "Nucleus sampling threshold. We recommend altering either top_k or top_p, but not both."
119
- ),
120
- )
121
-
122
- @model_validator(mode="before")
123
- def validate_penalties(cls, values):
124
- """
125
- Disallow using both frequency_penalty != 1.0 and presence_penalty != 0.0 at once,
126
- since the docs say they're incompatible.
127
- """
128
- freq_pen = values.get("frequency_penalty", 1.0)
129
- pres_pen = values.get("presence_penalty", 0.0)
130
-
131
- # The doc states frequency_penalty is incompatible with presence_penalty.
132
- # We'll enforce that if presence_penalty != 0, frequency_penalty must be 1.0
133
- # or vice versa. Adjust logic as needed.
134
- if pres_pen != 0.0 and freq_pen != 1.0:
135
- raise ValueError(
136
- "presence_penalty is incompatible with frequency_penalty. "
137
- "Please use only one: either presence_penalty=0 with freq_pen !=1, "
138
- "or presence_penalty!=0 with freq_pen=1."
139
- )
140
- return values
141
-
142
- def to_dict(self) -> dict:
143
- """Return a dict suitable for JSON serialization and sending to Perplexity API."""
144
- return self.model_dump(exclude_none=True)
5
+ __all__ = ("PerplexityChatCompletionRequest",)