solana-agent 2.1.3__tar.gz → 3.0.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: solana-agent
3
- Version: 2.1.3
3
+ Version: 3.0.0
4
4
  Summary: Build self-learning AI Agents
5
5
  License: MIT
6
6
  Keywords: ai,openai,ai agents
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "solana-agent"
3
- version = "2.1.3"
3
+ version = "3.0.0"
4
4
  description = "Build self-learning AI Agents"
5
5
  authors = ["Bevan Hunt <bevan@bevanhunt.com>"]
6
6
  license = "MIT"
@@ -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,23 @@ 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
- # convert time based on location
457
- the_time = dt.strftime("%Y-%m-%d %H:%M:%S UTC")
458
- return f"The current time is {the_time}"
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
+
459
477
  except Exception as e:
460
478
  return f"Error getting the current time: {e}"
461
479
 
@@ -790,7 +808,7 @@ class AI:
790
808
  async def stream_processor():
791
809
  memory = self.get_memory_context(user_id)
792
810
  response = self._client.chat.completions.create(
793
- model=self._openai_model,
811
+ model=self._main_model,
794
812
  messages=[
795
813
  {
796
814
  "role": "system",
@@ -830,11 +848,11 @@ class AI:
830
848
  # Execute the tool call (synchronously; adjust if async is needed)
831
849
  result = func(**args)
832
850
  response = self._client.chat.completions.create(
833
- model=self._openai_model,
851
+ model=self._tool_formatting_model,
834
852
  messages=[
835
853
  {
836
854
  "role": "system",
837
- "content": self._instructions,
855
+ "content": self._tool_formatting_instructions,
838
856
  },
839
857
  {
840
858
  "role": "user",
@@ -990,11 +1008,11 @@ class AI:
990
1008
  # Execute the tool call (synchronously; adjust if async is needed)
991
1009
  result = func(**args)
992
1010
  response = self._client.chat.completions.create(
993
- model=self._openai_model,
1011
+ model=self._tool_formatting_model,
994
1012
  messages=[
995
1013
  {
996
1014
  "role": "system",
997
- "content": self._instructions,
1015
+ "content": self._tool_formatting_instructions,
998
1016
  },
999
1017
  {
1000
1018
  "role": "user",
File without changes
File without changes