exa-py 1.8.6__py3-none-any.whl → 1.8.7__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.
Potentially problematic release.
This version of exa-py might be problematic. Click here for more details.
exa_py/api.py
CHANGED
|
@@ -505,7 +505,7 @@ class ResultWithTextAndHighlightsAndSummary(_Result):
|
|
|
505
505
|
|
|
506
506
|
@dataclass
|
|
507
507
|
class AnswerResult:
|
|
508
|
-
"""A class representing a
|
|
508
|
+
"""A class representing a result for an answer.
|
|
509
509
|
|
|
510
510
|
Attributes:
|
|
511
511
|
title (str): The title of the search result.
|
|
@@ -513,21 +513,21 @@ class AnswerResult:
|
|
|
513
513
|
id (str): The temporary ID for the document.
|
|
514
514
|
published_date (str, optional): An estimate of the creation date, from parsing HTML content.
|
|
515
515
|
author (str, optional): If available, the author of the content.
|
|
516
|
+
text (str, optional): The full page text from each search result.
|
|
516
517
|
"""
|
|
517
|
-
|
|
518
|
+
id: str
|
|
518
519
|
url: str
|
|
519
|
-
id: str
|
|
520
520
|
title: Optional[str] = None
|
|
521
|
-
author: Optional[str] = None
|
|
522
521
|
published_date: Optional[str] = None
|
|
522
|
+
author: Optional[str] = None
|
|
523
523
|
text: Optional[str] = None
|
|
524
524
|
|
|
525
525
|
def __init__(self, **kwargs):
|
|
526
|
-
self.url = kwargs['url']
|
|
527
526
|
self.id = kwargs['id']
|
|
528
|
-
self.
|
|
529
|
-
self.
|
|
527
|
+
self.url = kwargs['url']
|
|
528
|
+
self.title = kwargs.get('title')
|
|
530
529
|
self.published_date = kwargs.get('published_date')
|
|
530
|
+
self.author = kwargs.get('author')
|
|
531
531
|
self.text = kwargs.get('text')
|
|
532
532
|
|
|
533
533
|
def __str__(self):
|
|
@@ -546,23 +546,23 @@ class StreamChunk:
|
|
|
546
546
|
|
|
547
547
|
Attributes:
|
|
548
548
|
content (Optional[str]): The partial text content of the answer
|
|
549
|
-
|
|
549
|
+
citations (Optional[List[AnswerResult]]): List of citations if provided in this chunk
|
|
550
550
|
"""
|
|
551
551
|
content: Optional[str] = None
|
|
552
|
-
|
|
552
|
+
citations: Optional[List[AnswerResult]] = None
|
|
553
553
|
|
|
554
554
|
def has_data(self) -> bool:
|
|
555
555
|
"""Check if this chunk contains any data."""
|
|
556
|
-
return self.content is not None or self.
|
|
556
|
+
return self.content is not None or self.citations is not None
|
|
557
557
|
|
|
558
558
|
def __str__(self) -> str:
|
|
559
559
|
"""Format the chunk data as a string."""
|
|
560
560
|
output = ""
|
|
561
561
|
if self.content:
|
|
562
562
|
output += self.content
|
|
563
|
-
if self.
|
|
564
|
-
output += "\
|
|
565
|
-
for source in self.
|
|
563
|
+
if self.citations:
|
|
564
|
+
output += "\nCitations:"
|
|
565
|
+
for source in self.citations:
|
|
566
566
|
output += f"\n{source}"
|
|
567
567
|
return output
|
|
568
568
|
|
|
@@ -573,21 +573,21 @@ class AnswerResponse:
|
|
|
573
573
|
|
|
574
574
|
Attributes:
|
|
575
575
|
answer (str): The generated answer.
|
|
576
|
-
|
|
576
|
+
citations (List[AnswerResult]): A list of citations used to generate the answer.
|
|
577
577
|
"""
|
|
578
578
|
|
|
579
579
|
answer: str
|
|
580
|
-
|
|
580
|
+
citations: List[AnswerResult]
|
|
581
581
|
|
|
582
582
|
def __str__(self):
|
|
583
|
-
output = f"Answer: {self.answer}\n\
|
|
584
|
-
for source in self.
|
|
583
|
+
output = f"Answer: {self.answer}\n\nCitations:"
|
|
584
|
+
for source in self.citations:
|
|
585
585
|
output += f"\nTitle: {source.title}"
|
|
586
|
+
output += f"\nID: {source.id}"
|
|
586
587
|
output += f"\nURL: {source.url}"
|
|
587
|
-
output += f"\nPublished: {source.published_date}"
|
|
588
|
+
output += f"\nPublished Date: {source.published_date}"
|
|
588
589
|
output += f"\nAuthor: {source.author}"
|
|
589
|
-
|
|
590
|
-
output += f"\nText: {source.text}"
|
|
590
|
+
output += f"\nText: {source.text}"
|
|
591
591
|
output += "\n"
|
|
592
592
|
return output
|
|
593
593
|
|
|
@@ -615,16 +615,16 @@ class StreamAnswerResponse:
|
|
|
615
615
|
continue
|
|
616
616
|
|
|
617
617
|
content = None
|
|
618
|
-
|
|
618
|
+
citations = None
|
|
619
619
|
|
|
620
620
|
if "choices" in chunk and chunk["choices"]:
|
|
621
621
|
if "delta" in chunk["choices"][0]:
|
|
622
622
|
content = chunk["choices"][0]["delta"].get("content")
|
|
623
623
|
|
|
624
|
-
if "
|
|
625
|
-
|
|
624
|
+
if "citations" in chunk and chunk["citations"] and chunk["citations"] != "null":
|
|
625
|
+
citations = [AnswerResult(**to_snake_case(s)) for s in chunk["citations"]]
|
|
626
626
|
|
|
627
|
-
stream_chunk = StreamChunk(content=content,
|
|
627
|
+
stream_chunk = StreamChunk(content=content, citations=citations)
|
|
628
628
|
if stream_chunk.has_data():
|
|
629
629
|
yield stream_chunk
|
|
630
630
|
|
|
@@ -686,7 +686,7 @@ class Exa:
|
|
|
686
686
|
self,
|
|
687
687
|
api_key: Optional[str],
|
|
688
688
|
base_url: str = "https://api.exa.ai",
|
|
689
|
-
user_agent: str = "exa-py 1.8.
|
|
689
|
+
user_agent: str = "exa-py 1.8.7",
|
|
690
690
|
):
|
|
691
691
|
"""Initialize the Exa client with the provided API key and optional base URL and user agent.
|
|
692
692
|
|
|
@@ -1673,7 +1673,7 @@ class Exa:
|
|
|
1673
1673
|
text (bool, optional): Whether to include full text in the results. Defaults to False.
|
|
1674
1674
|
|
|
1675
1675
|
Returns:
|
|
1676
|
-
AnswerResponse: An object containing the answer and
|
|
1676
|
+
AnswerResponse: An object containing the answer and citations.
|
|
1677
1677
|
|
|
1678
1678
|
Raises:
|
|
1679
1679
|
ValueError: If stream=True is provided. Use stream_answer() instead for streaming responses.
|
|
@@ -1694,7 +1694,7 @@ class Exa:
|
|
|
1694
1694
|
|
|
1695
1695
|
return AnswerResponse(
|
|
1696
1696
|
response["answer"],
|
|
1697
|
-
[AnswerResult(**to_snake_case(result)) for result in response["
|
|
1697
|
+
[AnswerResult(**to_snake_case(result)) for result in response["citations"]]
|
|
1698
1698
|
)
|
|
1699
1699
|
|
|
1700
1700
|
def stream_answer(
|
|
@@ -1710,7 +1710,7 @@ class Exa:
|
|
|
1710
1710
|
text (bool): Whether to include full text in the results. Defaults to False.
|
|
1711
1711
|
|
|
1712
1712
|
Returns:
|
|
1713
|
-
StreamAnswerResponse: An object that can be iterated over to retrieve (partial text, partial
|
|
1713
|
+
StreamAnswerResponse: An object that can be iterated over to retrieve (partial text, partial citations).
|
|
1714
1714
|
Each iteration yields a tuple of (Optional[str], Optional[List[AnswerResult]]).
|
|
1715
1715
|
"""
|
|
1716
1716
|
options = {
|
exa_py/example.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
exa_py/__init__.py,sha256=1selemczpRm1y8V9cWNm90LARnU1jbtyp-Qpx3c7cTw,28
|
|
2
|
+
exa_py/api.py,sha256=5uuKVZpLtXQvxEi_X7W_x8JYqTQlsO8R2Ln0IRAQCrk,62663
|
|
3
|
+
exa_py/example.py,sha256=V2uZvFTQFLVr61lVQ_HbZz8G8TFT6Ic44-TTE5ixzBk,235
|
|
4
|
+
exa_py/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
exa_py/utils.py,sha256=Rc1FJjoR9LQ7L_OJM91Sd1GNkbHjcLyEvJENhRix6gc,2405
|
|
6
|
+
exa_py-1.8.7.dist-info/METADATA,sha256=xbby0b9LVLEzzBMu1mGivh0ZO0gDm_xjvPoF219riLk,3337
|
|
7
|
+
exa_py-1.8.7.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
8
|
+
exa_py-1.8.7.dist-info/RECORD,,
|
exa_py-1.8.6.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
exa_py/__init__.py,sha256=1selemczpRm1y8V9cWNm90LARnU1jbtyp-Qpx3c7cTw,28
|
|
2
|
-
exa_py/api.py,sha256=MJbdvN1AAVS7GA9IUT56KF8U_R8AT-sIcvCVG0EY6YM,62530
|
|
3
|
-
exa_py/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
exa_py/utils.py,sha256=Rc1FJjoR9LQ7L_OJM91Sd1GNkbHjcLyEvJENhRix6gc,2405
|
|
5
|
-
exa_py-1.8.6.dist-info/METADATA,sha256=jOlJfJYWMCEhoOGW1FY-bDjHLogR5soamiu94sPOuiw,3337
|
|
6
|
-
exa_py-1.8.6.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
7
|
-
exa_py-1.8.6.dist-info/RECORD,,
|
|
File without changes
|