solana-agent 2.1.2__py3-none-any.whl → 3.0.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.
solana_agent/ai.py CHANGED
@@ -9,6 +9,7 @@ from pydantic import BaseModel
9
9
  from pymongo import MongoClient
10
10
  from openai import OpenAI
11
11
  import inspect
12
+ import pytz
12
13
  import requests
13
14
  from zep_cloud.client import AsyncZep as AsyncZepCloud
14
15
  from zep_cloud.client import Zep as ZepCloud
@@ -69,7 +70,9 @@ class AI:
69
70
  pinecone_embed_model: Literal["llama-text-embed-v2"] = "llama-text-embed-v2",
70
71
  gemini_api_key: str = None,
71
72
  openai_base_url: str = None,
72
- openai_model: str = "gpt-4o-mini",
73
+ main_model: str = "o3-mini",
74
+ tool_formatting_model: str = "gpt-4o-mini",
75
+ tool_formatting_instructions: str = None,
73
76
  ):
74
77
  """Initialize a new AI assistant instance.
75
78
 
@@ -86,8 +89,9 @@ class AI:
86
89
  pinecone_embed_model (Literal["llama-text-embed-v2"], optional): Pinecone embedding model. Defaults to "llama-text-embed-v2"
87
90
  gemini_api_key (str, optional): API key for Gemini search. Defaults to None
88
91
  openai_base_url (str, optional): Base URL for OpenAI API. Defaults to None
89
- openai_model (str, optional): OpenAI model to use. Defaults to "gpt-4o-mini"
90
-
92
+ main_model (str, optional): Main OpenAI model for conversation. Defaults to "o3-mini"
93
+ tool_formatting_model (str, optional): OpenAI model for tool formatting. Defaults to "gpt-4o-mini"
94
+ tool_formatting_instructions (str, optional): Instructions for tool formatting
91
95
  Example:
92
96
  ```python
93
97
  ai = AI(
@@ -116,6 +120,7 @@ class AI:
116
120
  Always be concise and ensure that your response maintains coherence across the conversation while respecting the user's context and previous data.
117
121
  """
118
122
  self._instructions = instructions + " " + memory_instructions
123
+ self._tool_formatting_instructions = tool_formatting_instructions
119
124
  self._database: MongoDatabase = database
120
125
  self._accumulated_value_queue = asyncio.Queue()
121
126
  if zep_api_key and not zep_base_url:
@@ -140,7 +145,8 @@ class AI:
140
145
  self._pinecone_index_name) if self._pinecone else None
141
146
  )
142
147
  self._openai_base_url = openai_base_url
143
- self._openai_model = openai_model
148
+ self._main_model = main_model
149
+ self._tool_formatting_model = tool_formatting_model
144
150
  self._tools = []
145
151
 
146
152
  async def __aenter__(self):
@@ -431,16 +437,19 @@ class AI:
431
437
  self.kb.delete(ids=[id], namespace=user_id)
432
438
  self._database.kb.delete_one({"reference": id})
433
439
 
434
- def check_time(self) -> str:
440
+ def check_time(self, timezone: str) -> str:
435
441
  """Get current UTC time formatted as a string via Cloudflare's NTP service.
436
442
 
443
+ Args:
444
+ timezone (str): Timezone to convert the time to (e.g., "America/New_York")
445
+
437
446
  Returns:
438
- str: Current UTC time in format 'YYYY-MM-DD HH:MM:SS UTC'
447
+ str: Current time in the requested timezone in format 'YYYY-MM-DD HH:MM:SS'
439
448
 
440
449
  Example:
441
450
  ```python
442
- time = ai.check_time()
443
- # Returns: "2025-02-26 15:30:45 UTC"
451
+ time = ai.check_time("America/New_York")
452
+ # Returns: "The current time in America/New_York is 2025-02-26 10:30:45"
444
453
  ```
445
454
 
446
455
  Note:
@@ -448,14 +457,25 @@ class AI:
448
457
  Fetches time over NTP from Cloudflare's time server (time.cloudflare.com).
449
458
  """
450
459
  try:
460
+ # Request time from Cloudflare's NTP server
451
461
  client = ntplib.NTPClient()
452
- # Request time from Cloudflare's NTP server.
453
462
  response = client.request("time.cloudflare.com", version=3)
454
- dt = datetime.datetime.fromtimestamp(
463
+
464
+ # Get UTC time from NTP response
465
+ utc_dt = datetime.datetime.fromtimestamp(
455
466
  response.tx_time, datetime.timezone.utc)
456
- return dt.strftime("%Y-%m-%d %H:%M:%S UTC")
467
+
468
+ # Convert to requested timezone
469
+ try:
470
+ tz = pytz.timezone(timezone)
471
+ local_dt = utc_dt.astimezone(tz)
472
+ formatted_time = local_dt.strftime("%Y-%m-%d %H:%M:%S")
473
+ return f"The current time in {timezone} is {formatted_time}"
474
+ except pytz.exceptions.UnknownTimeZoneError:
475
+ return f"Error: Unknown timezone '{timezone}'. Please use a valid timezone like 'America/New_York'."
476
+
457
477
  except Exception as e:
458
- return f"Error: {e}"
478
+ return f"Error getting the current time: {e}"
459
479
 
460
480
  # has to be sync for tool
461
481
  def get_memory_context(
@@ -788,7 +808,7 @@ class AI:
788
808
  async def stream_processor():
789
809
  memory = self.get_memory_context(user_id)
790
810
  response = self._client.chat.completions.create(
791
- model=self._openai_model,
811
+ model=self._main_model,
792
812
  messages=[
793
813
  {
794
814
  "role": "system",
@@ -828,11 +848,11 @@ class AI:
828
848
  # Execute the tool call (synchronously; adjust if async is needed)
829
849
  result = func(**args)
830
850
  response = self._client.chat.completions.create(
831
- model=self._openai_model,
851
+ model=self._tool_formatting_model,
832
852
  messages=[
833
853
  {
834
854
  "role": "system",
835
- "content": self._instructions,
855
+ "content": self._tool_formatting_instructions,
836
856
  },
837
857
  {
838
858
  "role": "user",
@@ -988,11 +1008,11 @@ class AI:
988
1008
  # Execute the tool call (synchronously; adjust if async is needed)
989
1009
  result = func(**args)
990
1010
  response = self._client.chat.completions.create(
991
- model=self._openai_model,
1011
+ model=self._tool_formatting_model,
992
1012
  messages=[
993
1013
  {
994
1014
  "role": "system",
995
- "content": self._instructions,
1015
+ "content": self._tool_formatting_instructions,
996
1016
  },
997
1017
  {
998
1018
  "role": "user",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: solana-agent
3
- Version: 2.1.2
3
+ Version: 3.0.0
4
4
  Summary: Build self-learning AI Agents
5
5
  License: MIT
6
6
  Keywords: ai,openai,ai agents
@@ -0,0 +1,6 @@
1
+ solana_agent/__init__.py,sha256=zpfnWqANd3OHGWm7NCF5Y6m01BWG4NkNk8SK9Ex48nA,18
2
+ solana_agent/ai.py,sha256=nPUsnlaTH6lkXmk0lBay3XHbQu2znBuFNvmbmGvU2gE,45399
3
+ solana_agent-3.0.0.dist-info/LICENSE,sha256=BnSRc-NSFuyF2s496l_4EyrwAP6YimvxWcjPiJ0J7g4,1057
4
+ solana_agent-3.0.0.dist-info/METADATA,sha256=fRspzSg3YAhHY0f52SgrDAfGG9j66E_KLFktbt8praM,4808
5
+ solana_agent-3.0.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
6
+ solana_agent-3.0.0.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- solana_agent/__init__.py,sha256=zpfnWqANd3OHGWm7NCF5Y6m01BWG4NkNk8SK9Ex48nA,18
2
- solana_agent/ai.py,sha256=UdAsO1t3JBeW8UQBYSJjUcT4NUyrMJuAHf-yI2nzT0I,44216
3
- solana_agent-2.1.2.dist-info/LICENSE,sha256=BnSRc-NSFuyF2s496l_4EyrwAP6YimvxWcjPiJ0J7g4,1057
4
- solana_agent-2.1.2.dist-info/METADATA,sha256=wbK_aB2WBqNvGAoVt1eRn6dLWO3DYlqS7pvBGP0j0Qw,4808
5
- solana_agent-2.1.2.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
6
- solana_agent-2.1.2.dist-info/RECORD,,