langroid 0.41.3__py3-none-any.whl → 0.41.4__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.
@@ -450,9 +450,9 @@ class LlamaCppServerEmbeddings(EmbeddingModel):
450
450
  class GeminiEmbeddings(EmbeddingModel):
451
451
  def __init__(self, config: GeminiEmbeddingsConfig = GeminiEmbeddingsConfig()):
452
452
  try:
453
- import google.generativeai as genai
453
+ from google import genai
454
454
  except ImportError as e:
455
- raise LangroidImportError(extra="google-generativeai", error=str(e))
455
+ raise LangroidImportError(extra="google-genai", error=str(e))
456
456
  super().__init__()
457
457
  self.config = config
458
458
  load_dotenv()
@@ -464,29 +464,30 @@ class GeminiEmbeddings(EmbeddingModel):
464
464
  GEMINI_API_KEY env variable must be set to use GeminiEmbeddings.
465
465
  """
466
466
  )
467
- genai.configure(api_key=self.config.api_key) # type: ignore[attr-defined]
468
- self.client = genai
467
+ self.client = genai.Client(api_key=self.config.api_key)
469
468
 
470
469
  def embedding_fn(self) -> Callable[[List[str]], Embeddings]:
471
470
  return EmbeddingFunctionCallable(self, self.config.batch_size)
472
471
 
473
- def generate_embeddings(self, texts: List[str]) -> Embeddings:
474
- all_embeddings = [] # More precise type hint
472
+ def generate_embeddings(self, texts: List[str]) -> List[List[float]]:
473
+ """Generates embeddings for a list of input texts."""
474
+ all_embeddings: List[List[float]] = []
475
+
475
476
  for batch in batched(texts, self.config.batch_size):
476
- result = self.client.embed_content( # type: ignore[attr-defined]
477
+ result = self.client.models.embed_content( # type: ignore[attr-defined]
477
478
  model=self.config.model_name,
478
- content=batch,
479
- task_type="RETRIEVAL_DOCUMENT",
479
+ contents=batch,
480
480
  )
481
481
 
482
- embeddings = result["embedding"]
483
- if not isinstance(embeddings, list):
484
- raise ValueError("Unexpected format for embeddings: not a list")
482
+ if not hasattr(result, "embeddings") or not isinstance(
483
+ result.embeddings, list
484
+ ):
485
+ raise ValueError(
486
+ "Unexpected format for embeddings: missing or incorrect type"
487
+ )
485
488
 
486
- if embeddings and isinstance(embeddings[0], list):
487
- all_embeddings.extend(embeddings)
488
- else:
489
- all_embeddings.append(embeddings)
489
+ # Extract .values from ContentEmbedding objects
490
+ all_embeddings.extend([emb.values for emb in result.embeddings])
490
491
 
491
492
  return all_embeddings
492
493
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langroid
3
- Version: 0.41.3
3
+ Version: 0.41.4
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  Author-email: Prasad Chalasani <pchalasani@gmail.com>
6
6
  License: MIT
@@ -21,7 +21,7 @@ Requires-Dist: fakeredis<3.0.0,>=2.12.1
21
21
  Requires-Dist: fire<1.0.0,>=0.5.0
22
22
  Requires-Dist: gitpython<4.0.0,>=3.1.43
23
23
  Requires-Dist: google-api-python-client<3.0.0,>=2.95.0
24
- Requires-Dist: google-generativeai<1.0.0,>=0.5.2
24
+ Requires-Dist: google-genai>=1.0.0
25
25
  Requires-Dist: groq<1.0.0,>=0.13.0
26
26
  Requires-Dist: grpcio<2.0.0,>=1.62.1
27
27
  Requires-Dist: halo<1.0.0,>=0.0.31
@@ -112,8 +112,10 @@ Provides-Extra: exa
112
112
  Requires-Dist: exa-py>=1.8.7; extra == 'exa'
113
113
  Provides-Extra: fastembed
114
114
  Requires-Dist: fastembed<0.4.0,>=0.3.1; extra == 'fastembed'
115
+ Provides-Extra: google-genai
116
+ Requires-Dist: google-genai>=1.0.0; extra == 'google-genai'
115
117
  Provides-Extra: google-generativeai
116
- Requires-Dist: google-generativeai>=0.8.4; extra == 'google-generativeai'
118
+ Requires-Dist: google-genai>=1.0.0; extra == 'google-generativeai'
117
119
  Provides-Extra: hf-embeddings
118
120
  Requires-Dist: sentence-transformers<3.0.0,>=2.2.2; extra == 'hf-embeddings'
119
121
  Requires-Dist: torch<3.0.0,>=2.0.0; extra == 'hf-embeddings'
@@ -319,7 +321,7 @@ teacher_task.run()
319
321
  - **Jan 2025:**
320
322
  - [0.36.0](https://github.com/langroid/langroid/releases/tag/0.36.0): Weaviate vector-db support (thanks @abab-dev).
321
323
  - [0.35.0](https://github.com/langroid/langroid/releases/tag/0.35.0): Capture/Stream reasoning content from
322
- Reasoning LLMs (e.g. DeepSeek, OpenAI o1) in addition to final answer.
324
+ Reasoning LLMs (e.g. DeepSeek-R1, OpenAI o1) in addition to final answer.
323
325
  - [0.34.0](https://github.com/langroid/langroid/releases/tag/0.34.0): DocChatAgent
324
326
  chunk enrichment to improve retrieval. (collaboration with @dfm88).
325
327
  - [0.33.0](https://github.com/langroid/langroid/releases/tag/0.33.3) Move from Poetry to uv! (thanks @abab-dev).
@@ -627,7 +629,7 @@ For many practical scenarios, you may need additional optional dependencies:
627
629
  - For "chat with databases", use the `db` extra:
628
630
  ```bash
629
631
  pip install "langroid[db]"
630
- ``
632
+ ```
631
633
  - You can specify multiple extras by separating them with commas, e.g.:
632
634
  ```bash
633
635
  pip install "langroid[doc-chat,db]"
@@ -59,7 +59,7 @@ langroid/cachedb/momento_cachedb.py,sha256=YEOJ62hEcV6iIeMr5aGgRYgWQqFYaej9gEDEc
59
59
  langroid/cachedb/redis_cachedb.py,sha256=7kgnbf4b5CKsCrlL97mHWKvdvlLt8zgn7lc528jEpiE,5141
60
60
  langroid/embedding_models/__init__.py,sha256=KyYxR3jDFUCfYjSuCL86qjAmrq6mXXjOT4lFNOKVj6Y,955
61
61
  langroid/embedding_models/base.py,sha256=Ml7oA6PzQm0wZmIYn3fhF7dvZCi-amviWUwOeBegH3A,2562
62
- langroid/embedding_models/models.py,sha256=fKQBiaaG7uYoeELDbAiNxwLdn-CWN8dyiVEZcdk_bjI,18959
62
+ langroid/embedding_models/models.py,sha256=93rQjvcltGLDYbgT1TIW8PZiAbNPAvPAqxCLlLS9GAo,18955
63
63
  langroid/embedding_models/remote_embeds.py,sha256=6_kjXByVbqhY9cGwl9R83ZcYC2km-nGieNNAo1McHaY,5151
64
64
  langroid/embedding_models/protoc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
65
  langroid/embedding_models/protoc/embeddings.proto,sha256=_O-SgFpTaylQeOTgSpxhEJ7CUw7PeCQQJLaPqpPYKJg,321
@@ -128,7 +128,7 @@ langroid/vector_store/pineconedb.py,sha256=otxXZNaBKb9f_H75HTaU3lMHiaR2NUp5MqwLZ
128
128
  langroid/vector_store/postgres.py,sha256=DQHd6dt-OcV_QVNm-ymn28rlTfhI6hqgcpLTPCsm0jI,15990
129
129
  langroid/vector_store/qdrantdb.py,sha256=v7TAsIoj_vxeKDYS9tpwJLBZA8fuTweTYxHo0X_uawM,17949
130
130
  langroid/vector_store/weaviatedb.py,sha256=ONEr2iGS0Ii73oMe7tRk6bB-BEXQUa70fYSrdI8d3yo,11481
131
- langroid-0.41.3.dist-info/METADATA,sha256=hQDjq_z2rXui7guy7-_TweJvkSkGWhQ-iQZb5i0vyIk,61259
132
- langroid-0.41.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
133
- langroid-0.41.3.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
134
- langroid-0.41.3.dist-info/RECORD,,
131
+ langroid-0.41.4.dist-info/METADATA,sha256=hU062qh537keZYiNQZhdKWffOldsn_lz5BWYew1TQbg,61331
132
+ langroid-0.41.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
133
+ langroid-0.41.4.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
134
+ langroid-0.41.4.dist-info/RECORD,,