camel-ai 0.1.5.5__py3-none-any.whl → 0.1.5.9__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 camel-ai might be problematic. Click here for more details.

Files changed (97) hide show
  1. camel/__init__.py +1 -1
  2. camel/agents/chat_agent.py +3 -3
  3. camel/agents/critic_agent.py +1 -1
  4. camel/agents/deductive_reasoner_agent.py +4 -4
  5. camel/agents/embodied_agent.py +1 -1
  6. camel/agents/knowledge_graph_agent.py +13 -17
  7. camel/agents/role_assignment_agent.py +1 -1
  8. camel/agents/search_agent.py +4 -5
  9. camel/agents/task_agent.py +5 -6
  10. camel/configs/__init__.py +15 -0
  11. camel/configs/gemini_config.py +98 -0
  12. camel/configs/groq_config.py +119 -0
  13. camel/configs/litellm_config.py +1 -1
  14. camel/configs/mistral_config.py +81 -0
  15. camel/configs/ollama_config.py +1 -1
  16. camel/configs/openai_config.py +1 -1
  17. camel/configs/vllm_config.py +103 -0
  18. camel/configs/zhipuai_config.py +1 -1
  19. camel/embeddings/__init__.py +2 -0
  20. camel/embeddings/mistral_embedding.py +89 -0
  21. camel/interpreters/__init__.py +2 -0
  22. camel/interpreters/ipython_interpreter.py +167 -0
  23. camel/models/__init__.py +10 -0
  24. camel/models/anthropic_model.py +7 -2
  25. camel/models/azure_openai_model.py +152 -0
  26. camel/models/base_model.py +9 -2
  27. camel/models/gemini_model.py +215 -0
  28. camel/models/groq_model.py +131 -0
  29. camel/models/litellm_model.py +26 -4
  30. camel/models/mistral_model.py +169 -0
  31. camel/models/model_factory.py +33 -5
  32. camel/models/ollama_model.py +21 -2
  33. camel/models/open_source_model.py +11 -3
  34. camel/models/openai_model.py +7 -2
  35. camel/models/stub_model.py +4 -4
  36. camel/models/vllm_model.py +138 -0
  37. camel/models/zhipuai_model.py +7 -4
  38. camel/prompts/__init__.py +2 -2
  39. camel/prompts/task_prompt_template.py +4 -4
  40. camel/prompts/{descripte_video_prompt.py → video_description_prompt.py} +1 -1
  41. camel/retrievers/auto_retriever.py +2 -0
  42. camel/storages/graph_storages/neo4j_graph.py +5 -0
  43. camel/toolkits/__init__.py +36 -0
  44. camel/toolkits/base.py +1 -1
  45. camel/toolkits/code_execution.py +1 -1
  46. camel/toolkits/github_toolkit.py +3 -2
  47. camel/toolkits/google_maps_toolkit.py +367 -0
  48. camel/toolkits/math_toolkit.py +79 -0
  49. camel/toolkits/open_api_toolkit.py +548 -0
  50. camel/toolkits/retrieval_toolkit.py +76 -0
  51. camel/toolkits/search_toolkit.py +326 -0
  52. camel/toolkits/slack_toolkit.py +308 -0
  53. camel/toolkits/twitter_toolkit.py +522 -0
  54. camel/toolkits/weather_toolkit.py +173 -0
  55. camel/types/enums.py +163 -30
  56. camel/utils/__init__.py +4 -0
  57. camel/utils/async_func.py +1 -1
  58. camel/utils/token_counting.py +182 -40
  59. {camel_ai-0.1.5.5.dist-info → camel_ai-0.1.5.9.dist-info}/METADATA +43 -3
  60. camel_ai-0.1.5.9.dist-info/RECORD +165 -0
  61. camel/functions/__init__.py +0 -51
  62. camel/functions/google_maps_function.py +0 -335
  63. camel/functions/math_functions.py +0 -61
  64. camel/functions/open_api_function.py +0 -508
  65. camel/functions/retrieval_functions.py +0 -61
  66. camel/functions/search_functions.py +0 -298
  67. camel/functions/slack_functions.py +0 -286
  68. camel/functions/twitter_function.py +0 -479
  69. camel/functions/weather_functions.py +0 -144
  70. camel_ai-0.1.5.5.dist-info/RECORD +0 -155
  71. /camel/{functions → toolkits}/open_api_specs/biztoc/__init__.py +0 -0
  72. /camel/{functions → toolkits}/open_api_specs/biztoc/ai-plugin.json +0 -0
  73. /camel/{functions → toolkits}/open_api_specs/biztoc/openapi.yaml +0 -0
  74. /camel/{functions → toolkits}/open_api_specs/coursera/__init__.py +0 -0
  75. /camel/{functions → toolkits}/open_api_specs/coursera/openapi.yaml +0 -0
  76. /camel/{functions → toolkits}/open_api_specs/create_qr_code/__init__.py +0 -0
  77. /camel/{functions → toolkits}/open_api_specs/create_qr_code/openapi.yaml +0 -0
  78. /camel/{functions → toolkits}/open_api_specs/klarna/__init__.py +0 -0
  79. /camel/{functions → toolkits}/open_api_specs/klarna/openapi.yaml +0 -0
  80. /camel/{functions → toolkits}/open_api_specs/nasa_apod/__init__.py +0 -0
  81. /camel/{functions → toolkits}/open_api_specs/nasa_apod/openapi.yaml +0 -0
  82. /camel/{functions → toolkits}/open_api_specs/outschool/__init__.py +0 -0
  83. /camel/{functions → toolkits}/open_api_specs/outschool/ai-plugin.json +0 -0
  84. /camel/{functions → toolkits}/open_api_specs/outschool/openapi.yaml +0 -0
  85. /camel/{functions → toolkits}/open_api_specs/outschool/paths/__init__.py +0 -0
  86. /camel/{functions → toolkits}/open_api_specs/outschool/paths/get_classes.py +0 -0
  87. /camel/{functions → toolkits}/open_api_specs/outschool/paths/search_teachers.py +0 -0
  88. /camel/{functions → toolkits}/open_api_specs/security_config.py +0 -0
  89. /camel/{functions → toolkits}/open_api_specs/speak/__init__.py +0 -0
  90. /camel/{functions → toolkits}/open_api_specs/speak/openapi.yaml +0 -0
  91. /camel/{functions → toolkits}/open_api_specs/web_scraper/__init__.py +0 -0
  92. /camel/{functions → toolkits}/open_api_specs/web_scraper/ai-plugin.json +0 -0
  93. /camel/{functions → toolkits}/open_api_specs/web_scraper/openapi.yaml +0 -0
  94. /camel/{functions → toolkits}/open_api_specs/web_scraper/paths/__init__.py +0 -0
  95. /camel/{functions → toolkits}/open_api_specs/web_scraper/paths/scraper.py +0 -0
  96. /camel/{functions → toolkits}/openai_function.py +0 -0
  97. {camel_ai-0.1.5.5.dist-info → camel_ai-0.1.5.9.dist-info}/WHEEL +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: camel-ai
3
- Version: 0.1.5.5
3
+ Version: 0.1.5.9
4
4
  Summary: Communicative Agents for AI Society Study
5
5
  Home-page: https://www.camel-ai.org/
6
6
  License: Apache-2.0
@@ -36,11 +36,16 @@ Requires-Dist: docker (>=7.1.0,<8.0.0) ; extra == "tools" or extra == "all"
36
36
  Requires-Dist: docstring-parser (>=0.15,<0.16)
37
37
  Requires-Dist: docx2txt (>=0.8,<0.9) ; extra == "tools" or extra == "all"
38
38
  Requires-Dist: duckduckgo-search (>=6.1.0,<7.0.0) ; extra == "tools" or extra == "all"
39
+ Requires-Dist: google-generativeai (>=0.6.0,<0.7.0) ; extra == "model-platforms" or extra == "all"
39
40
  Requires-Dist: googlemaps (>=4.10.0,<5.0.0) ; extra == "tools" or extra == "all"
41
+ Requires-Dist: groq (>=0.5.0,<0.6.0)
40
42
  Requires-Dist: imageio[pyav] (>=2.34.2,<3.0.0) ; extra == "tools" or extra == "all"
43
+ Requires-Dist: ipykernel (>=6.0.0,<7.0.0)
41
44
  Requires-Dist: jsonschema (>=4,<5)
45
+ Requires-Dist: jupyter_client (>=8.6.2,<9.0.0) ; extra == "tools" or extra == "all"
42
46
  Requires-Dist: litellm (>=1.38.1,<2.0.0) ; extra == "model-platforms" or extra == "all"
43
- Requires-Dist: milvus-lite (>=2.4.0,<=2.4.7)
47
+ Requires-Dist: mistral-common (>=1.3.3,<2.0.0) ; extra == "model-platforms" or extra == "all"
48
+ Requires-Dist: mistralai (>=0.4.2,<0.5.0) ; extra == "model-platforms" or extra == "all"
44
49
  Requires-Dist: mock (>=5,<6) ; extra == "test"
45
50
  Requires-Dist: neo4j (>=5.18.0,<6.0.0) ; extra == "graph-storages" or extra == "all"
46
51
  Requires-Dist: newspaper3k (>=0.2.8,<0.3.0) ; extra == "tools" or extra == "all"
@@ -190,7 +195,7 @@ conda create --name camel python=3.9
190
195
  conda activate camel
191
196
 
192
197
  # Clone github repo
193
- git clone -b v0.1.5.5 https://github.com/camel-ai/camel.git
198
+ git clone -b v0.1.5.9 https://github.com/camel-ai/camel.git
194
199
 
195
200
  # Change directory into project directory
196
201
  cd camel
@@ -316,6 +321,41 @@ Please note that the environment variable is session-specific. If you open a new
316
321
  print(assistant_response.msg.content)
317
322
  ```
318
323
 
324
+ ## Use Open-Source Models as Backends (ex. using vLLM to set Phi-3 locally)
325
+ - [Install vLLM](https://docs.vllm.ai/en/latest/getting_started/installation.html)
326
+ - After setting up vLLM, start an OpenAI compatible server for example by
327
+ ```bash
328
+ python -m vllm.entrypoints.openai.api_server --model microsoft/Phi-3-mini-4k-instruct --api-key vllm --dtype bfloat16
329
+ ```
330
+ - Create and run following script (more details please refer to this [example](https://github.com/camel-ai/camel/blob/master/examples/models/vllm_model_example.py))
331
+ ```python
332
+ from camel.agents import ChatAgent
333
+ from camel.messages import BaseMessage
334
+ from camel.models import ModelFactory
335
+ from camel.types import ModelPlatformType
336
+
337
+ vllm_model = ModelFactory.create(
338
+ model_platform=ModelPlatformType.VLLM,
339
+ model_type="microsoft/Phi-3-mini-4k-instruct",
340
+ url="http://localhost:8000/v1",
341
+ model_config_dict={"temperature": 0.0},
342
+ api_key="vllm",
343
+ )
344
+
345
+ assistant_sys_msg = BaseMessage.make_assistant_message(
346
+ role_name="Assistant",
347
+ content="You are a helpful assistant.",
348
+ )
349
+ agent = ChatAgent(assistant_sys_msg, model=vllm_model, token_limit=4096)
350
+
351
+ user_msg = BaseMessage.make_user_message(
352
+ role_name="User",
353
+ content="Say hi to CAMEL AI",
354
+ )
355
+ assistant_response = agent.step(user_msg)
356
+ print(assistant_response.msg.content)
357
+ ```
358
+
319
359
  ## Data (Hosted on Hugging Face)
320
360
  | Dataset | Chat format | Instruction format | Chat format (translated) |
321
361
  |----------------|-----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|
@@ -0,0 +1,165 @@
1
+ camel/__init__.py,sha256=kB5ZXhod3rtwh0XZx7na1pO69cLUZYByBARqoJJpFww,780
2
+ camel/agents/__init__.py,sha256=SSU1wbhZXWwQnE0rRxkpyN57kEu72KklsZNcdLkXfTs,1551
3
+ camel/agents/base.py,sha256=X39qWSiT1WnDqaJ9k3gQrTpOQSwUKzNEVpp5AY6fDH8,1130
4
+ camel/agents/chat_agent.py,sha256=zGUX7hxeqMe4-6DEPS8XZXNCqZKDN3SNKiMNM_oeSTU,27682
5
+ camel/agents/critic_agent.py,sha256=W2F9NuZretkK9vx07NpGC6kinKdZjahRgV0OtZKyrno,7197
6
+ camel/agents/deductive_reasoner_agent.py,sha256=TB-RF2XGo1CFPvdUB5MrysORD8KZMk2n813aabmc94Y,13174
7
+ camel/agents/embodied_agent.py,sha256=nUZ8-DoV1q0HDL0AfiNe8W7nyQRs1aBdfYHGpF09o4M,7158
8
+ camel/agents/knowledge_graph_agent.py,sha256=kmPEyJBud2mHkmpR0ors8n6i7luUSd0FJ2mHNSizDX4,8558
9
+ camel/agents/role_assignment_agent.py,sha256=TBbso5tZuEChRoZTAWkbPSHo3HbEtJFe2snc_cDu_DQ,4798
10
+ camel/agents/search_agent.py,sha256=e5WLi9ZWLKwbxROZleBHH49COwVoUGEhN5Ga2J2wMUE,4334
11
+ camel/agents/task_agent.py,sha256=YENI_y2pugMDqQRRZ2CZFxVIvCJEjzvUOv8kShiOO5M,14245
12
+ camel/agents/tool_agents/__init__.py,sha256=ulTNWU2qoFGe3pvVmCq_sdfeSX3NKZ0due66TYvsL-M,862
13
+ camel/agents/tool_agents/base.py,sha256=nQAhfWi8a_bCgzlf5-G-tmj1fKm6AjpRc89NQkWwpnc,1399
14
+ camel/agents/tool_agents/hugging_face_tool_agent.py,sha256=1Z5tG6f_86eL0vmtRZ-BJvoLDFFLhoHt8JtDvgat1xU,8723
15
+ camel/configs/__init__.py,sha256=nHeymsBcQ7c2Tb0Gn2Ykw70ZswTx3P7baEZRDD9P1SI,1797
16
+ camel/configs/anthropic_config.py,sha256=zD7VMFUw4s7wmBlr64oSXxpEUkhp7wj9mvAd0WK2zFc,3308
17
+ camel/configs/base_config.py,sha256=CEF8ryl_dkH6LgOhwuP5_EgjaWCUCB-E3GcMWR-2YFE,870
18
+ camel/configs/gemini_config.py,sha256=JAxd7Xx98VAlTz6l7CAPaZDS4OKz6e-daPJ_joUx96Q,4965
19
+ camel/configs/groq_config.py,sha256=7Iu0l3vIhI3-DvjcDv4Ddi-hGRpnt5popfcGmf2-DlM,6147
20
+ camel/configs/litellm_config.py,sha256=WU6D53Th7-BC6idoJZjiYZuHjkSHFVc1NEFyK-jJGrI,4884
21
+ camel/configs/mistral_config.py,sha256=lyhGZTFvYj9VcipXPtWWeMrWBbzq7XixAORpKEw3zII,3370
22
+ camel/configs/ollama_config.py,sha256=vQbSTaOFiBX1XMOjdSDTIwsZg8KNPv4dmnaJ_I7DYSw,4397
23
+ camel/configs/openai_config.py,sha256=-CkNfWoOFhFTyQ7Zy61C3iI8LaalLSBv_aE7mFmEmXg,7592
24
+ camel/configs/vllm_config.py,sha256=Fmi_RyjQ5CdAiVxqrbAolTunmziqUvvMaiRcJWbSdeo,5535
25
+ camel/configs/zhipuai_config.py,sha256=pjfMUn-dFy9BZSTlAXxyxQIIIjYmdlq_K4j6Rl78-_I,3768
26
+ camel/embeddings/__init__.py,sha256=KTX6IC9b2ifKde-Yh7srSp_gNopvBwtDy8kEzazn5lE,1106
27
+ camel/embeddings/base.py,sha256=deX70VXGmWGRAPal3HheXvMaarymRR5I1i90KPWGWXs,2196
28
+ camel/embeddings/mistral_embedding.py,sha256=eXes7Tebjfm52YwuSI6ihCnZB40oJ3AxNb6SPVedRic,3219
29
+ camel/embeddings/openai_embedding.py,sha256=Eh7Hbj6bWMTrX0Tze2IgPdD3-v9aRoBeE8AifG3jF8A,3332
30
+ camel/embeddings/sentence_transformers_embeddings.py,sha256=ayYIBOADdmmhlmo1iZS8tI_mZ-rX0sxjljyQpkuftcw,2730
31
+ camel/embeddings/vlm_embedding.py,sha256=VvD_b737snNrZTRE4ejFvWLjd_YT1DCTKl8yKIgRM-g,5436
32
+ camel/generators.py,sha256=tcYDoHwSKN0rBiu7u4rWN9pb61O8OaclrNaasCqHSJM,10437
33
+ camel/human.py,sha256=W_T7PSO-ReiJbC5JMX1wPrpt6LVFBqoNEwUdjDScG1M,4963
34
+ camel/interpreters/__init__.py,sha256=HXspVCRZSFAXIJxhxrnr_RpZqZSWqgLOZ2KdQDlTn9s,1205
35
+ camel/interpreters/base.py,sha256=JZpQmxYBflPcDerj-R6TB6nnKvhnZR3Drraxo84JuxE,1904
36
+ camel/interpreters/docker_interpreter.py,sha256=Lsq5XxcDCAvxoDcVnog8tyvKIervI5aEkPXLTLQqeh4,8441
37
+ camel/interpreters/internal_python_interpreter.py,sha256=ZbVmSB2zvWbvvTOL0xpDlJel-I9rv13w1rP4RvtpNiE,21866
38
+ camel/interpreters/interpreter_error.py,sha256=4pI_dKohUKcQOrqJafolyjRfOHwBUuUBXCwwD46P4wE,886
39
+ camel/interpreters/ipython_interpreter.py,sha256=B0v1DCiq6PmOYQXXQAQBX1oOYjgJ0geLwUG9UxPR4TM,5950
40
+ camel/interpreters/subprocess_interpreter.py,sha256=nKxFXZJ9zGYlKdNlz6Ln7bvg65ejKZ8yAHgIFuR2WzM,6835
41
+ camel/loaders/__init__.py,sha256=IeNDC84goWnYHFyuImIkwe-9nbnuFfTySXz8ghloEp0,920
42
+ camel/loaders/base_io.py,sha256=LSke5Pje3GyA9JJJMAo1Ib9P07FtTYUr3a9RG9Mzr7c,8487
43
+ camel/loaders/jina_url_reader.py,sha256=PNl3fuU_7TkmuxaDnoW5pLnOi8XRnb7wlXA4FudWIbE,3620
44
+ camel/loaders/unstructured_io.py,sha256=Y4epnItSnd7BXMdt3b9L7Q3PRTKBldX6nzgAJTG6Z5A,25363
45
+ camel/memories/__init__.py,sha256=ml1Uj4Y_1Q2LfrTXOY38niF0x1H-N-u_zoN_VvR939U,1364
46
+ camel/memories/agent_memories.py,sha256=XxZCNSqMy2zME-vYjy9EBpQc9WzW1vOIFwdAoxImvtY,6110
47
+ camel/memories/base.py,sha256=kbyAmKkOfFdOKfHxwao8bIAbRSuOEXyzxPFd0NlvUCE,5003
48
+ camel/memories/blocks/__init__.py,sha256=5oPXhzoZke5d-4R8jmP54o8O2mmBvJB30oukRNrRX50,860
49
+ camel/memories/blocks/chat_history_block.py,sha256=USDGp5pDlp6PrClmAVi3WqwAjE6wrWwpJBoqG_yvX9A,4609
50
+ camel/memories/blocks/vectordb_block.py,sha256=qgW-hr-TptXwirrtO5RrFlvD6r3BPFXvvz3hJzs4Zjg,3850
51
+ camel/memories/context_creators/__init__.py,sha256=0uLLP3YD46gOOh39her_weJo3viHmE4IWyWBLlutnqs,806
52
+ camel/memories/context_creators/score_based.py,sha256=o3h4Rst9vzdgMg8-MbUMDLVaMBMqy4ZeFgHejyGQTJY,5378
53
+ camel/memories/records.py,sha256=zmZsYHVuq6fYqJDkzhNXF02uWLzdBemaEZeG0Ls90pU,3618
54
+ camel/messages/__init__.py,sha256=djLvpz6AmjeLzuUSQl7J6T2O4x8MwSdcH0l9fbj_3yg,1468
55
+ camel/messages/base.py,sha256=1cyYITXxBsp2UCdOjF1Ky4W_PgRegEfitqbrF9PjUPs,13721
56
+ camel/messages/func_message.py,sha256=CCVkbz-2pdxXV0vBETI0xt7d7uiN8zACpRI7lCnfTFQ,3841
57
+ camel/models/__init__.py,sha256=lKQnkyKST84D9h54_-mylLfVXON8AIT400jBlv01X3w,1700
58
+ camel/models/anthropic_model.py,sha256=_xhnbrMsuumB2jkuv2pVv3MFYxNE5EL5kVlZbYYBo5E,5751
59
+ camel/models/azure_openai_model.py,sha256=r5diPZp4XmCcZClkCqvTHB8frzRNou559j89dryKLKw,6078
60
+ camel/models/base_model.py,sha256=UHyAgo6GzYZNLTZD1T0C3_WmHUPoh9Qoe_SfvdI7HrU,4387
61
+ camel/models/gemini_model.py,sha256=h_kyD8LSpXCn2dQ4OEer5HwwEUwuTD65yRIRV4LD3Vs,7700
62
+ camel/models/groq_model.py,sha256=47Srfh6rvyExT9qWvIPUgJs_Vd11k88pYWJv3zefEmY,4690
63
+ camel/models/litellm_model.py,sha256=HSFDeBG8DeU-bz4e3QOtfpBkUmGyacM_zUce4Ban6qE,5747
64
+ camel/models/mistral_model.py,sha256=nKJOTjaDXSJ-9vD2sJqXpubDHBJHt2hVBdCYzFftg8M,5969
65
+ camel/models/model_factory.py,sha256=EoYKP6mZ5LFaAq_HIhzQc4Jfly7Gp91ihobvJDJNOOg,5354
66
+ camel/models/nemotron_model.py,sha256=2Idf4wrZervxvfu6av42EKjefFtDnBb6cKnWCJUkqI4,2682
67
+ camel/models/ollama_model.py,sha256=VG5i3D3P9mHeRb9hJiIPFe3F5puFamXMg66UXiHw6Q8,4867
68
+ camel/models/open_source_model.py,sha256=BgWfzmZGGclxWWHNn9o5nnyjx9zwMDd47eJ8VWU8e1I,6381
69
+ camel/models/openai_audio_models.py,sha256=_ddOxqzFZCVZaK6h33Z0THU6HXk2XlJTxVWquZ3oOaQ,10042
70
+ camel/models/openai_model.py,sha256=uOtiLmbdH7sDKqk9oV0i1HEVni_4ApPXCukShZwQDKA,4611
71
+ camel/models/stub_model.py,sha256=DuqaBsS55STSbcLJsk025Uwo_u4ixrSSKqKEoZj2ihY,3680
72
+ camel/models/vllm_model.py,sha256=i8zOK4XvVx0ietQLT74MgkcjMXYc2CMmsYS4EeT0N-w,5005
73
+ camel/models/zhipuai_model.py,sha256=O-KMk0_0KpKIwd-5tsnPxTWGoL89gPLTUPLB0qxmyIg,4943
74
+ camel/prompts/__init__.py,sha256=6tdFsIjMg8_gC7Hp6fLZ4_J_BnPESv4RQNFrUgWqlGg,2051
75
+ camel/prompts/ai_society.py,sha256=ApgvIED1Z_mdsWDNc2_u35Ktp7pEKksMrOIQKo_q5cI,6306
76
+ camel/prompts/base.py,sha256=VMde6w97zHPP03OA628wGwXhtJweoccOK1B1f3aESDo,8464
77
+ camel/prompts/code.py,sha256=vrv2mPjlakPlqVLQt_rA1veP79EN1t3iM41bkACrc9I,5865
78
+ camel/prompts/evaluation.py,sha256=4zm5ZVy3CSb2NdFWnS43ejK8Cu_pU8iUIj06ofpuZpg,1596
79
+ camel/prompts/generate_text_embedding_data.py,sha256=S0D0S99OAixDh_jp3sfFbeRJjffLutmyUd-vryqV7ho,4246
80
+ camel/prompts/misalignment.py,sha256=aL3W5WvTJBfF-1vWQse_tn3zAOaezHGU510HLs0AlQo,4537
81
+ camel/prompts/object_recognition.py,sha256=L_YM_c8AxwO6MvwuUdeuluwhBPXedNxNIzOv5yF9Dag,1422
82
+ camel/prompts/prompt_templates.py,sha256=PeOp_eUgyZyJ7BCwA2cvSx8O3QPu9ftjgaZ6Al8zlJQ,4134
83
+ camel/prompts/role_description_prompt_template.py,sha256=k9p3NlxY1MWKzhoRpeQeuz0oHDQYo63WoPdWcUmHr_A,2544
84
+ camel/prompts/solution_extraction.py,sha256=5vTSaeQoBSvaur3cKgqQ9kLxSA5QIOBI4OPQzXWbQFg,2109
85
+ camel/prompts/task_prompt_template.py,sha256=UByOz6-7i2o5u2X5e_bIU1IdVTe7tAYHjoUIGFliNmU,3042
86
+ camel/prompts/translation.py,sha256=V_40Ko2is5dAOCZ8DzsHo6DO7l8_jnEV9KjCKH7GxtY,1902
87
+ camel/prompts/video_description_prompt.py,sha256=HRd3fHXftKwBm5QH7Tvm3FabgZPCoAvfJfPCo-Cbr4k,1295
88
+ camel/responses/__init__.py,sha256=edtTQskOgq5obyITziRFL62HTJP9sAikAtP9vrFacEQ,795
89
+ camel/responses/agent_responses.py,sha256=UsTZHi4jPs2wfChPQWttVNyHneoGdQtdrRouatywE4w,1714
90
+ camel/retrievers/__init__.py,sha256=CuP3B77zl2PoF-W2y9xSkTGRzoK2J4TlUHdCtuJD8dg,1059
91
+ camel/retrievers/auto_retriever.py,sha256=WpvDflxR0HGSA0FPxOgvpxgYyq7pHnzUltmfTEkr2Bc,13591
92
+ camel/retrievers/base.py,sha256=sgqaJDwIkWluEgPBlukFN7RYZJnrp0imCAOEWm6bZ40,2646
93
+ camel/retrievers/bm25_retriever.py,sha256=qM1oCQ-fak3izEjQVn18t0aceW-W8cRKbaYPwcHrEjI,5067
94
+ camel/retrievers/cohere_rerank_retriever.py,sha256=HvnFqXpsX9EdBOab0kFLDyxxJnknPFMVxyQJQDlHbOA,4100
95
+ camel/retrievers/vector_retriever.py,sha256=PhPIUyjffOojwYiATEY1lsCQO9yDmpc8k-R4sAt5IvY,7316
96
+ camel/societies/__init__.py,sha256=JhGwUHjht4CewzC3shKuxmgB3oS7FIxIxmiKyhNsfIs,832
97
+ camel/societies/babyagi_playing.py,sha256=0sDe65XbGGWQOe4I758sH-sAk1Hf82Y_qawjaEbbBXE,11791
98
+ camel/societies/role_playing.py,sha256=C5hQIPH8gwP7_dkh65nOPplsw50lYQiYXk-aapODqMY,21983
99
+ camel/storages/__init__.py,sha256=ghlDZ1cF3O_QxwX9xIIZ__bnHcUjh7dbAF1X_ivkofc,1551
100
+ camel/storages/graph_storages/__init__.py,sha256=vsJZkedaCS-cLQ-KgMqio8cxXvbousBWVqzZJvlimT8,897
101
+ camel/storages/graph_storages/base.py,sha256=-Ys1BIuz4H5FvYMZTBIjg8Cfv40CPQ-OsovwMzygEgU,2858
102
+ camel/storages/graph_storages/graph_element.py,sha256=cz3eQdSockPsJwEVo6R_X_QeuS81_x5XrZjpzK1Q7cw,2599
103
+ camel/storages/graph_storages/neo4j_graph.py,sha256=YAT7u2jPs5pNSO_tSwARHJyt3HqYXpbpE4ZBtv935Kg,22138
104
+ camel/storages/key_value_storages/__init__.py,sha256=v3Wy3CAJNgrPyBV4miOC6TxQDL-PYdGW8HbqiYl7k00,968
105
+ camel/storages/key_value_storages/base.py,sha256=knxni8WiyTXJ2emZQO-JIsbxw6Ei7EO6dj-bU2YCoSY,2183
106
+ camel/storages/key_value_storages/in_memory.py,sha256=pAcKkVd7jlPS6seR31agdyjx9TNIIRMIyx497XWXwbs,1955
107
+ camel/storages/key_value_storages/json.py,sha256=BlOhuyWbSjzKixtA5e9O0z8BFK4pi96OcPNxnFfDPQw,3471
108
+ camel/storages/key_value_storages/redis.py,sha256=nQmdVUTLL0bW3hDeX5k-V2XKv0n6wuvbBxlrBmWVbpw,5706
109
+ camel/storages/vectordb_storages/__init__.py,sha256=hEhPyCPlzyXUsDFDzKRdLBj09rO1b5bsn76AJrDcaG4,1076
110
+ camel/storages/vectordb_storages/base.py,sha256=BS1QPz11ZUBVtn_M7j1Q0GW0Ya_ILai4Y2o1UPW9bAM,6009
111
+ camel/storages/vectordb_storages/milvus.py,sha256=F3wBsvERSHaYpa3FaBkiKkdi6jxcrH7wDRlSQP6DXx0,13492
112
+ camel/storages/vectordb_storages/qdrant.py,sha256=k2aCM1goLS9vllcgvk8bBQJ_sHf81G0C5UcyURTDCmo,13468
113
+ camel/terminators/__init__.py,sha256=pE7fcfDUNngdbm1BhzSQPRMXNbdd28rl9YbF4gKWwXE,997
114
+ camel/terminators/base.py,sha256=TSkl3maNEsdjyAniJaSgFfD4UF8RQ1LwNIiGw0dN8Gg,1396
115
+ camel/terminators/response_terminator.py,sha256=zcXuigbvlclUoBv4xcVbfU36ZohUT1RhI-rSnukloUY,4951
116
+ camel/terminators/token_limit_terminator.py,sha256=mK30wVUnoqNAvIo-wxkqY5gUSNay2M04rsAktKqoiOI,2087
117
+ camel/toolkits/__init__.py,sha256=nhlmtjrM4u8Mb-3biLLBUhwrMuZgAHF7cTgomhSoX3I,2030
118
+ camel/toolkits/base.py,sha256=Z3imvmBrzheGtn-5pcmCxi8WI8pcSPiIGR4L18nLy4Y,924
119
+ camel/toolkits/code_execution.py,sha256=fWBhn1_3adiv7YYuA0gJzEBlc_dYNS6_hVtDbgB-zX0,2425
120
+ camel/toolkits/github_toolkit.py,sha256=6SxHc63wzoBm_5vLSbZgMmaXwKwgX-B1CDMK7fjkErM,11504
121
+ camel/toolkits/google_maps_toolkit.py,sha256=g5PNhrc-ipQ-Vx_O7eilTy3LtYyp-vcErKYOk0OJw5I,14335
122
+ camel/toolkits/math_toolkit.py,sha256=r-85DHvihR87DU6n_W75pecV1P9xV3Hylfp6u-ue7T4,2521
123
+ camel/toolkits/open_api_specs/biztoc/__init__.py,sha256=f3LXNDzN2XWWoF2D0nesG8VuEA6Zd14i2aiTDbCm5bA,708
124
+ camel/toolkits/open_api_specs/biztoc/ai-plugin.json,sha256=IJinQbLv5MFPGFwdN7PbOhwArFVExSEZdJspe-mOBIo,866
125
+ camel/toolkits/open_api_specs/biztoc/openapi.yaml,sha256=SQ2bYIWb1nVBtkBeFaOihiWQ71oZ2bzz0fCgu6igM8A,610
126
+ camel/toolkits/open_api_specs/coursera/__init__.py,sha256=f3LXNDzN2XWWoF2D0nesG8VuEA6Zd14i2aiTDbCm5bA,708
127
+ camel/toolkits/open_api_specs/coursera/openapi.yaml,sha256=iouLcNNpVvXLfmkyKrbJlS3MEjBJ7TgVR48UID8dwfE,1981
128
+ camel/toolkits/open_api_specs/create_qr_code/__init__.py,sha256=f3LXNDzN2XWWoF2D0nesG8VuEA6Zd14i2aiTDbCm5bA,708
129
+ camel/toolkits/open_api_specs/create_qr_code/openapi.yaml,sha256=d6ZNFmhCwlqZj8Rp9lmdU1dYPyh3-GnadbEUKHqjBfc,1158
130
+ camel/toolkits/open_api_specs/klarna/__init__.py,sha256=f3LXNDzN2XWWoF2D0nesG8VuEA6Zd14i2aiTDbCm5bA,708
131
+ camel/toolkits/open_api_specs/klarna/openapi.yaml,sha256=9wpwRn8NLZL1reN6YUPsZP24hbDJJYvOJeeoWTk7ojQ,2887
132
+ camel/toolkits/open_api_specs/nasa_apod/__init__.py,sha256=f3LXNDzN2XWWoF2D0nesG8VuEA6Zd14i2aiTDbCm5bA,708
133
+ camel/toolkits/open_api_specs/nasa_apod/openapi.yaml,sha256=4NPWtk9k7UwNpUihkrbCXzzs4zls-YnEYKe6qmtO8FU,2044
134
+ camel/toolkits/open_api_specs/outschool/__init__.py,sha256=f3LXNDzN2XWWoF2D0nesG8VuEA6Zd14i2aiTDbCm5bA,708
135
+ camel/toolkits/open_api_specs/outschool/ai-plugin.json,sha256=QohJo8Ya0RGBvs9cBQR-UgSMl0gXJdNlWO8d2FyqdE8,1089
136
+ camel/toolkits/open_api_specs/outschool/openapi.yaml,sha256=t9gHdt09CQ8QMVnzEBxkcgH9eG720IsnVwB_6QxzSC4,8700
137
+ camel/toolkits/open_api_specs/outschool/paths/__init__.py,sha256=2XEfkKfyijEhzTodYGGoD5qvCQLYYlcxboQuNfLGBJs,780
138
+ camel/toolkits/open_api_specs/outschool/paths/get_classes.py,sha256=1skqdvrOjI_oywSe3KBV4zuqDg_EOpftpA3G6gXCZ8c,1122
139
+ camel/toolkits/open_api_specs/outschool/paths/search_teachers.py,sha256=p6J9jTxbBNVJTa3M1qaJu3VKtIZEZFX0etxw7a3pdFk,1125
140
+ camel/toolkits/open_api_specs/security_config.py,sha256=uxdd-Uh1hyHd3wvXdVahBH0hDdf0-IEoVk9Rh2vpAh0,904
141
+ camel/toolkits/open_api_specs/speak/__init__.py,sha256=f3LXNDzN2XWWoF2D0nesG8VuEA6Zd14i2aiTDbCm5bA,708
142
+ camel/toolkits/open_api_specs/speak/openapi.yaml,sha256=rmM_-E4tYJ2LOpUlcQxfQtcQSRkVnsBkQWMmKdW2QqQ,6557
143
+ camel/toolkits/open_api_specs/web_scraper/__init__.py,sha256=f3LXNDzN2XWWoF2D0nesG8VuEA6Zd14i2aiTDbCm5bA,708
144
+ camel/toolkits/open_api_specs/web_scraper/ai-plugin.json,sha256=jjHvbj0DQ4AYcL9JlSWhyJZ3mFj4eC33E4t6Ci54p3s,1028
145
+ camel/toolkits/open_api_specs/web_scraper/openapi.yaml,sha256=u_WalQ01e8W1D27VnZviOylpGmJ-zssYrfAgkzqdoyk,2191
146
+ camel/toolkits/open_api_specs/web_scraper/paths/__init__.py,sha256=f3LXNDzN2XWWoF2D0nesG8VuEA6Zd14i2aiTDbCm5bA,708
147
+ camel/toolkits/open_api_specs/web_scraper/paths/scraper.py,sha256=SQGbFkshLN4xm-Ya49ssbSvaU1nFVNFYhWsEPYVeFe0,1123
148
+ camel/toolkits/open_api_toolkit.py,sha256=dFPKPaMSaUmHx6BQQ2aQ3pPO6ZleURaIoMnLgUl6evs,23460
149
+ camel/toolkits/openai_function.py,sha256=NyN8LBKdNeWizR7SnOp6VwEQhq29OJgskFfXq8EzIFg,14948
150
+ camel/toolkits/retrieval_toolkit.py,sha256=XVBKCuGp_RjOaiJQ6dTwKlsQVg6X1JoROiwPyDw1tkE,3021
151
+ camel/toolkits/search_toolkit.py,sha256=05fKN9LYSvu70iXO4Vziv4QOU3WFbVnIW-8sTeilkLY,12932
152
+ camel/toolkits/slack_toolkit.py,sha256=JdgDJe7iExTmG7dDXOG6v5KpVjZ6_My_d_WFTYSxkw4,10839
153
+ camel/toolkits/twitter_toolkit.py,sha256=oQw8wRkU7iDxaocsmWvio4pU75pmq6FJAorPdQ2xEAE,19810
154
+ camel/toolkits/weather_toolkit.py,sha256=n4YrUI_jTIH7oqH918IdHbXLgfQ2BPGIWWK8Jp8G1Uw,7054
155
+ camel/types/__init__.py,sha256=ArKXATj3z_Vv4ISmROVeo6Mv3tj5kE1dTkqfgwyxVY4,1975
156
+ camel/types/enums.py,sha256=RJQrLghX-m06raBcWwdPBLpBg9rwufCuZnX59k4c85g,15898
157
+ camel/types/openai_types.py,sha256=BNQ6iCzKTjSvgcXFsAFIgrUS_YUFZBU6bDoyAp387hI,2045
158
+ camel/utils/__init__.py,sha256=0kQjKkt_I1juOkNAKx_haXvuJ7xiyWfZTD5uHLJdnRk,1919
159
+ camel/utils/async_func.py,sha256=SLo8KPkrNKdsONvFf3KBb33EgFn4gH2EKSX1aI_LKes,1578
160
+ camel/utils/commons.py,sha256=J7AOOh5huQkwTvjDt_gpiXNTXnuk0yM_hdtRU8clpNE,11298
161
+ camel/utils/constants.py,sha256=ZIw5ILfOyJFyjEAYrbJMANeg1_EZI-zMK_xVrkwALbM,1105
162
+ camel/utils/token_counting.py,sha256=PI3I5J5nYqoLMjOHhW5vU33aQxYcksWtqOd_VcXtREk,20863
163
+ camel_ai-0.1.5.9.dist-info/METADATA,sha256=_mq5-Z-Us48bnzFb-efnZQNClByJclWXtvdYyrZ88iA,23786
164
+ camel_ai-0.1.5.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
165
+ camel_ai-0.1.5.9.dist-info/RECORD,,
@@ -1,51 +0,0 @@
1
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2
- # Licensed under the Apache License, Version 2.0 (the “License”);
3
- # you may not use this file except in compliance with the License.
4
- # You may obtain a copy of the License at
5
- #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
- #
8
- # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an “AS IS” BASIS,
10
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- # See the License for the specific language governing permissions and
12
- # limitations under the License.
13
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
14
- # ruff: noqa: I001
15
- from .openai_function import (
16
- OpenAIFunction,
17
- get_openai_function_schema,
18
- get_openai_tool_schema,
19
- )
20
- from .open_api_specs.security_config import openapi_security_config
21
-
22
- from .google_maps_function import MAP_FUNCS
23
- from .math_functions import MATH_FUNCS
24
- from .open_api_function import OPENAPI_FUNCS
25
- from .retrieval_functions import RETRIEVAL_FUNCS
26
- from .search_functions import SEARCH_FUNCS
27
- from .twitter_function import TWITTER_FUNCS
28
- from .weather_functions import WEATHER_FUNCS
29
- from .slack_functions import SLACK_FUNCS
30
-
31
- from .open_api_function import (
32
- apinames_filepaths_to_funs_schemas,
33
- generate_apinames_filepaths,
34
- )
35
-
36
- __all__ = [
37
- 'OpenAIFunction',
38
- 'get_openai_function_schema',
39
- 'get_openai_tool_schema',
40
- 'openapi_security_config',
41
- 'apinames_filepaths_to_funs_schemas',
42
- 'generate_apinames_filepaths',
43
- 'MAP_FUNCS',
44
- 'MATH_FUNCS',
45
- 'OPENAPI_FUNCS',
46
- 'RETRIEVAL_FUNCS',
47
- 'SEARCH_FUNCS',
48
- 'TWITTER_FUNCS',
49
- 'WEATHER_FUNCS',
50
- 'SLACK_FUNCS',
51
- ]
@@ -1,335 +0,0 @@
1
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2
- # Licensed under the Apache License, Version 2.0 (the “License”);
3
- # you may not use this file except in compliance with the License.
4
- # You may obtain a copy of the License at
5
- #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
- #
8
- # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an “AS IS” BASIS,
10
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- # See the License for the specific language governing permissions and
12
- # limitations under the License.
13
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
14
- import os
15
- from functools import wraps
16
- from typing import Any, Callable, List, Optional, Tuple, Union
17
-
18
- from camel.functions.openai_function import OpenAIFunction
19
-
20
-
21
- def import_googlemaps_or_raise() -> Any:
22
- r"""Attempts to import the `googlemaps` library and returns it.
23
-
24
- Returns:
25
- module: The `googlemaps` module if successfully imported.
26
-
27
- Raises:
28
- ImportError: If the `googlemaps` library is not installed, this error
29
- is raised with a message instructing how to install the
30
- library using pip.
31
- """
32
- try:
33
- import googlemaps
34
-
35
- return googlemaps
36
- except ImportError:
37
- raise ImportError(
38
- "Please install `googlemaps` first. You can install "
39
- "it by running `pip install googlemaps`."
40
- )
41
-
42
-
43
- def get_googlemap_api_key() -> str:
44
- r"""Retrieve the Google Maps API key from environment variables.
45
-
46
- Returns:
47
- str: The Google Maps API key.
48
-
49
- Raises:
50
- ValueError: If the API key is not found in the environment variables.
51
- """
52
- # Get `GOOGLEMAPS_API_KEY` here:
53
- # https://console.cloud.google.com/apis/credentials
54
- GOOGLEMAPS_API_KEY = os.environ.get('GOOGLEMAPS_API_KEY')
55
- if not GOOGLEMAPS_API_KEY:
56
- raise ValueError(
57
- "`GOOGLEMAPS_API_KEY` not found in environment "
58
- "variables. `GOOGLEMAPS_API_KEY` API keys are "
59
- "generated in the `Credentials` page of the "
60
- "`APIs & Services` tab of "
61
- "https://console.cloud.google.com/apis/credentials."
62
- )
63
- return GOOGLEMAPS_API_KEY
64
-
65
-
66
- def get_address_description(
67
- address: Union[str, List[str]],
68
- region_code: Optional[str] = None,
69
- locality: Optional[str] = None,
70
- ) -> str:
71
- r"""Validates an address via Google Maps API, returns a descriptive
72
- summary.
73
-
74
- Validates an address using Google Maps API, returning a summary that
75
- includes information on address completion, formatted address, location
76
- coordinates, and metadata types that are true for the given address.
77
-
78
- Args:
79
- address (Union[str, List[str]]): The address or components to validate.
80
- Can be a single string or a list representing different parts.
81
- region_code (str, optional): Country code for regional restriction,
82
- helps narrowing down results. (default: :obj:`None`)
83
- locality (str, optional): Restricts validation to a specific locality,
84
- e.g., "Mountain View". (default: :obj:`None`)
85
-
86
- Returns:
87
- str: Summary of the address validation results, including information
88
- on address completion, formatted address, geographical coordinates
89
- (latitude and longitude), and metadata types true for the address.
90
-
91
- Raises:
92
- ImportError: If the `googlemaps` library is not installed.
93
- Exception: For unexpected errors during the address validation.
94
- """
95
- googlemaps = import_googlemaps_or_raise()
96
- GOOGLEMAPS_API_KEY = get_googlemap_api_key()
97
- try:
98
- gmaps = googlemaps.Client(key=GOOGLEMAPS_API_KEY)
99
- except Exception as e:
100
- return f"Error: {e!s}"
101
-
102
- try:
103
- addressvalidation_result = gmaps.addressvalidation(
104
- [address],
105
- regionCode=region_code,
106
- locality=locality,
107
- enableUspsCass=False,
108
- ) # Always False as per requirements
109
-
110
- # Check if the result contains an error
111
- if 'error' in addressvalidation_result:
112
- error_info = addressvalidation_result['error']
113
- error_message = error_info.get(
114
- 'message', 'An unknown error occurred'
115
- )
116
- error_status = error_info.get('status', 'UNKNOWN_STATUS')
117
- error_code = error_info.get('code', 'UNKNOWN_CODE')
118
- return (
119
- f"Address validation failed with error: {error_message} "
120
- f"Status: {error_status}, Code: {error_code}"
121
- )
122
-
123
- # Assuming the successful response structure includes a 'result' key
124
- result = addressvalidation_result['result']
125
- verdict = result.get('verdict', {})
126
- address_info = result.get('address', {})
127
- geocode = result.get('geocode', {})
128
- metadata = result.get('metadata', {})
129
-
130
- # Construct the descriptive string
131
- address_complete = (
132
- "Yes" if verdict.get('addressComplete', False) else "No"
133
- )
134
- formatted_address = address_info.get(
135
- 'formattedAddress', 'Not available'
136
- )
137
- location = geocode.get('location', {})
138
- latitude = location.get('latitude', 'Not available')
139
- longitude = location.get('longitude', 'Not available')
140
- true_metadata_types = [key for key, value in metadata.items() if value]
141
- true_metadata_types_str = (
142
- ', '.join(true_metadata_types) if true_metadata_types else 'None'
143
- )
144
-
145
- description = (
146
- f"Address completion status: {address_complete}. "
147
- f"Formatted address: {formatted_address}. "
148
- f"Location (latitude, longitude): ({latitude}, {longitude}). "
149
- f"Metadata indicating true types: {true_metadata_types_str}."
150
- )
151
-
152
- return description
153
- except Exception as e:
154
- return f"An unexpected error occurred: {e!s}"
155
-
156
-
157
- def handle_googlemaps_exceptions(
158
- func: Callable[..., Any],
159
- ) -> Callable[..., Any]:
160
- r"""Decorator to catch and handle exceptions raised by Google Maps API
161
- calls.
162
-
163
- Args:
164
- func (Callable): The function to be wrapped by the decorator.
165
-
166
- Returns:
167
- Callable: A wrapper function that calls the wrapped function and
168
- handles exceptions.
169
- """
170
-
171
- @wraps(func)
172
- def wrapper(*args: Any, **kwargs: Any) -> Any:
173
- try:
174
- from googlemaps.exceptions import ( # type: ignore[import-untyped] # isort: skip
175
- ApiError,
176
- HTTPError,
177
- Timeout,
178
- TransportError,
179
- )
180
- except ImportError:
181
- raise ImportError(
182
- "Please install `googlemaps` first. You can install "
183
- "it by running `pip install googlemaps`."
184
- )
185
-
186
- try:
187
- return func(*args, **kwargs)
188
- except ApiError as e:
189
- return (
190
- 'An exception returned by the remote API. '
191
- f'Status: {e.status}, Message: {e.message}'
192
- )
193
- except HTTPError as e:
194
- return (
195
- 'An unexpected HTTP error occurred. '
196
- f'Status Code: {e.status_code}'
197
- )
198
- except Timeout:
199
- return 'The request timed out.'
200
- except TransportError as e:
201
- return (
202
- 'Something went wrong while trying to execute the '
203
- f'request. Details: {e.base_exception}'
204
- )
205
- except Exception as e:
206
- return f'An unexpected error occurred: {e}'
207
-
208
- return wrapper
209
-
210
-
211
- @handle_googlemaps_exceptions
212
- def get_elevation(lat_lng: Tuple) -> str:
213
- r"""Retrieves elevation data for a given latitude and longitude.
214
-
215
- Uses the Google Maps API to fetch elevation data for the specified latitude
216
- and longitude. It handles exceptions gracefully and returns a description
217
- of the elevation, including its value in meters and the data resolution.
218
-
219
- Args:
220
- lat_lng (Tuple[float, float]): The latitude and longitude for
221
- which to retrieve elevation data.
222
-
223
- Returns:
224
- str: A description of the elevation at the specified location(s),
225
- including the elevation in meters and the data resolution. If
226
- elevation data is not available, a message indicating this is
227
- returned.
228
- """
229
- googlemaps = import_googlemaps_or_raise()
230
- GOOGLEMAPS_API_KEY = get_googlemap_api_key()
231
- try:
232
- gmaps = googlemaps.Client(key=GOOGLEMAPS_API_KEY)
233
- except Exception as e:
234
- return f"Error: {e!s}"
235
-
236
- # Assuming gmaps is a configured Google Maps client instance
237
- elevation_result = gmaps.elevation(lat_lng)
238
-
239
- # Extract the elevation data from the first (and presumably only) result
240
- if elevation_result:
241
- elevation = elevation_result[0]['elevation']
242
- location = elevation_result[0]['location']
243
- resolution = elevation_result[0]['resolution']
244
-
245
- # Format the elevation data into a natural language description
246
- description = (
247
- f"The elevation at latitude {location['lat']}, "
248
- f"longitude {location['lng']} "
249
- f"is approximately {elevation:.2f} meters above sea level, "
250
- f"with a data resolution of {resolution:.2f} meters."
251
- )
252
- else:
253
- description = "Elevation data is not available for the given location."
254
-
255
- return description
256
-
257
-
258
- def format_offset_to_natural_language(offset: int) -> str:
259
- r"""Converts a time offset in seconds to a more natural language
260
- description using hours as the unit, with decimal places to represent
261
- minutes and seconds.
262
-
263
- Args:
264
- offset (int): The time offset in seconds. Can be positive, negative,
265
- or zero.
266
-
267
- Returns:
268
- str: A string representing the offset in hours, such as "+2.50 hours"
269
- or "-3.75 hours".
270
- """
271
- # Convert the offset to hours as a float
272
- hours = offset / 3600.0
273
- hours_str = f"{hours:+.2f} hour{'s' if abs(hours) != 1 else ''}"
274
- return hours_str
275
-
276
-
277
- @handle_googlemaps_exceptions
278
- def get_timezone(lat_lng: Tuple) -> str:
279
- r"""Retrieves timezone information for a given latitude and longitude.
280
-
281
- This function uses the Google Maps Timezone API to fetch timezone data for
282
- the specified latitude and longitude. It returns a natural language
283
- description of the timezone, including the timezone ID, name, standard
284
- time offset, daylight saving time offset, and the total offset from
285
- Coordinated Universal Time (UTC).
286
-
287
- Args:
288
- lat_lng (Tuple[float, float]): The latitude and longitude for
289
- which to retrieve elevation data.
290
-
291
- Returns:
292
- str: A descriptive string of the timezone information, including the
293
- timezone ID and name, standard time offset, daylight saving time
294
- offset, and total offset from UTC.
295
- """
296
- googlemaps = import_googlemaps_or_raise()
297
- GOOGLEMAPS_API_KEY = get_googlemap_api_key()
298
- try:
299
- gmaps = googlemaps.Client(key=GOOGLEMAPS_API_KEY)
300
- except Exception as e:
301
- return f"Error: {e!s}"
302
-
303
- # Get timezone information
304
- timezone_dict = gmaps.timezone(lat_lng)
305
-
306
- # Extract necessary information
307
- dst_offset = timezone_dict[
308
- 'dstOffset'
309
- ] # Daylight Saving Time offset in seconds
310
- raw_offset = timezone_dict['rawOffset'] # Standard time offset in seconds
311
- timezone_id = timezone_dict['timeZoneId']
312
- timezone_name = timezone_dict['timeZoneName']
313
-
314
- raw_offset_str = format_offset_to_natural_language(raw_offset)
315
- dst_offset_str = format_offset_to_natural_language(dst_offset)
316
- total_offset_seconds = dst_offset + raw_offset
317
- total_offset_str = format_offset_to_natural_language(total_offset_seconds)
318
-
319
- # Create a natural language description
320
- description = (
321
- f"Timezone ID is {timezone_id}, named {timezone_name}. "
322
- f"The standard time offset is {raw_offset_str}. "
323
- f"Daylight Saving Time offset is {dst_offset_str}. "
324
- f"The total offset from Coordinated Universal Time (UTC) is "
325
- f"{total_offset_str}, including any Daylight Saving Time adjustment "
326
- f"if applicable. "
327
- )
328
-
329
- return description
330
-
331
-
332
- MAP_FUNCS: List[OpenAIFunction] = [
333
- OpenAIFunction(func) # type: ignore[arg-type]
334
- for func in [get_address_description, get_elevation, get_timezone]
335
- ]