solana-agent 12.0.0__tar.gz → 14.0.1__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.
Files changed (40) hide show
  1. solana_agent-14.0.1/PKG-INFO +126 -0
  2. solana_agent-14.0.1/README.md +102 -0
  3. {solana_agent-12.0.0 → solana_agent-14.0.1}/pyproject.toml +3 -9
  4. solana_agent-14.0.1/solana_agent/__init__.py +33 -0
  5. solana_agent-14.0.1/solana_agent/adapters/__init__.py +6 -0
  6. solana_agent-14.0.1/solana_agent/adapters/llm_adapter.py +123 -0
  7. solana_agent-14.0.1/solana_agent/adapters/mongodb_adapter.py +69 -0
  8. solana_agent-14.0.1/solana_agent/client/__init__.py +0 -0
  9. solana_agent-14.0.1/solana_agent/client/solana_agent.py +75 -0
  10. solana_agent-14.0.1/solana_agent/domains/__init__.py +6 -0
  11. solana_agent-14.0.1/solana_agent/domains/agents.py +80 -0
  12. solana_agent-14.0.1/solana_agent/domains/routing.py +14 -0
  13. solana_agent-14.0.1/solana_agent/factories/__init__.py +0 -0
  14. solana_agent-14.0.1/solana_agent/factories/agent_factory.py +148 -0
  15. solana_agent-14.0.1/solana_agent/interfaces/__init__.py +11 -0
  16. solana_agent-14.0.1/solana_agent/interfaces/plugins/plugins.py +118 -0
  17. solana_agent-14.0.1/solana_agent/interfaces/providers/data_storage.py +53 -0
  18. solana_agent-14.0.1/solana_agent/interfaces/providers/llm.py +34 -0
  19. solana_agent-14.0.1/solana_agent/interfaces/providers/memory.py +38 -0
  20. solana_agent-14.0.1/solana_agent/interfaces/repositories/agent.py +33 -0
  21. solana_agent-14.0.1/solana_agent/interfaces/services/agent.py +41 -0
  22. solana_agent-14.0.1/solana_agent/interfaces/services/query.py +11 -0
  23. solana_agent-14.0.1/solana_agent/interfaces/services/routing.py +19 -0
  24. solana_agent-14.0.1/solana_agent/plugins/__init__.py +6 -0
  25. solana_agent-14.0.1/solana_agent/plugins/manager.py +147 -0
  26. solana_agent-14.0.1/solana_agent/plugins/registry.py +64 -0
  27. solana_agent-14.0.1/solana_agent/plugins/tools/__init__.py +10 -0
  28. solana_agent-14.0.1/solana_agent/plugins/tools/auto_tool.py +47 -0
  29. solana_agent-14.0.1/solana_agent/repositories/__init__.py +6 -0
  30. solana_agent-14.0.1/solana_agent/repositories/agent.py +99 -0
  31. solana_agent-14.0.1/solana_agent/repositories/memory.py +134 -0
  32. solana_agent-14.0.1/solana_agent/services/__init__.py +6 -0
  33. solana_agent-14.0.1/solana_agent/services/agent.py +323 -0
  34. solana_agent-14.0.1/solana_agent/services/query.py +223 -0
  35. solana_agent-14.0.1/solana_agent/services/routing.py +149 -0
  36. solana_agent-12.0.0/PKG-INFO +0 -395
  37. solana_agent-12.0.0/README.md +0 -366
  38. solana_agent-12.0.0/solana_agent/__init__.py +0 -1
  39. solana_agent-12.0.0/solana_agent/ai.py +0 -8015
  40. {solana_agent-12.0.0 → solana_agent-14.0.1}/LICENSE +0 -0
@@ -0,0 +1,126 @@
1
+ Metadata-Version: 2.3
2
+ Name: solana-agent
3
+ Version: 14.0.1
4
+ Summary: The Future of Work
5
+ License: MIT
6
+ Keywords: ai,openai,ai agents,agi
7
+ Author: Bevan Hunt
8
+ Author-email: bevan@bevanhunt.com
9
+ Requires-Python: >=3.12,<4.0
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Requires-Dist: openai (>=1.68.0,<2.0.0)
17
+ Requires-Dist: pydantic (>=2.10.6,<3.0.0)
18
+ Requires-Dist: pymongo (>=4.11.3,<5.0.0)
19
+ Requires-Dist: zep-cloud (>=2.7.0,<3.0.0)
20
+ Requires-Dist: zep-python (>=2.0.2,<3.0.0)
21
+ Project-URL: Repository, https://github.com/truemagic-coder/solana-agent
22
+ Description-Content-Type: text/markdown
23
+
24
+ # Solana Agent
25
+
26
+ [![PyPI - Version](https://img.shields.io/pypi/v/solana-agent)](https://pypi.org/project/solana-agent/)
27
+ [![PyPI - Downloads](https://img.shields.io/pypi/dm/solana-agent?color=yellow)](https://pypi.org/project/solana-agent/)
28
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
29
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-orange.svg)](https://www.python.org/downloads/)
30
+ [![codecov](https://img.shields.io/codecov/c/github/truemagic-coder/solana-agent/main.svg)](https://codecov.io/gh/truemagic-coder/solana-agent)
31
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/truemagic-coder/solana-agent/test.yml?branch=main)](https://github.com/truemagic-coder/solana-agent/actions/workflows/test.yml)
32
+
33
+ ![Solana Agent Logo](https://dl.walletbubbles.com/solana-agent-logo.png?width=200)
34
+
35
+ ## Features
36
+
37
+ * Text streaming messages by AI Agents
38
+ * Conversational memory per user shared by all AI Agents
39
+ * Routing based on AI Agent specializations
40
+ * Built-in Internet Search for all AI Agents
41
+ * Organizational mission, values, goals, and guidance for all AI Agents
42
+ * Robust AI Agent tool plugins based on standard python packages
43
+
44
+ ## Stack
45
+
46
+ * [Python](https://python.org) - programming language
47
+ * [OpenAI](https://openai.com) - LLMs
48
+ * [MongoDB](https://mongodb.com) - database
49
+ * [Zep](https://getzep.com) - conversational memory
50
+
51
+ ## Installation
52
+
53
+ You can install Solana Agent using pip:
54
+
55
+ `pip install solana-agent`
56
+
57
+ ## Documentation
58
+
59
+ Each public method has a docstring for real-time IDE hinting.
60
+
61
+ ## Example App
62
+
63
+ ```python
64
+ from solana_agent import SolanaAgent
65
+
66
+ config = {
67
+ "organization": {
68
+ "mission_statement": "To revolutionize knowledge work through AI-human collaboration that puts people first.",
69
+ "values": {
70
+ "Human-Centered": "Always prioritize human well-being and augmentation over replacement.",
71
+ "Transparency": "Provide clear explanations for decisions and never hide information.",
72
+ "Collective Intelligence": "Value diverse perspectives and combine human and AI strengths.",
73
+ "Continuous Learning": "Embrace feedback and continuously improve based on experience."
74
+ },
75
+ "goals": [
76
+ "Enable human experts to focus on high-value creative work",
77
+ "Reduce administrative overhead through intelligent automation",
78
+ "Create seamless knowledge flow across the organization"
79
+ ],
80
+ "guidance": "When making decisions, prioritize long-term user success over short-term efficiency."
81
+ },
82
+ "mongo": {
83
+ "connection_string": "mongodb://localhost:27017",
84
+ "database": "solana_agent"
85
+ },
86
+ "openai": {
87
+ "api_key": "your-openai-key",
88
+ "default_model": "gpt-4o-mini"
89
+ },
90
+ "agents": [
91
+ {
92
+ "name": "research_specialist",
93
+ "instructions": "You are an expert researcher who synthesizes complex information clearly.",
94
+ "specialization": "Research and knowledge synthesis",
95
+ "model": "o3-mini",
96
+ "tools": ["some_tool"]
97
+ },
98
+ {
99
+ "name": "customer_support",
100
+ "instructions": "You provide friendly, helpful customer support responses.",
101
+ "specialization": "Customer inquiries",
102
+ "model": "gpt-4o-mini"
103
+ }
104
+ ],
105
+ }
106
+
107
+ # Create agent with configuration
108
+ solana_agent = SolanaAgent(config=config)
109
+
110
+ # Process a query that can use tools
111
+ async for response in solana_agent.process("user123", "What are the latest AI developments?"):
112
+ print(response, end="")
113
+ ```
114
+
115
+ ## Solana Agent Kit
116
+
117
+ [Solana Agent Kit](https://github.com/truemagic-coder/solana-agent-kit)
118
+
119
+ ## Example App
120
+
121
+ [Solana Agent Example App](https://github.com/truemagic-coder/solana-agent-app)
122
+
123
+ ## License
124
+
125
+ This project is licensed under the MIT License - see the LICENSE file for details.
126
+
@@ -0,0 +1,102 @@
1
+ # Solana Agent
2
+
3
+ [![PyPI - Version](https://img.shields.io/pypi/v/solana-agent)](https://pypi.org/project/solana-agent/)
4
+ [![PyPI - Downloads](https://img.shields.io/pypi/dm/solana-agent?color=yellow)](https://pypi.org/project/solana-agent/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
6
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-orange.svg)](https://www.python.org/downloads/)
7
+ [![codecov](https://img.shields.io/codecov/c/github/truemagic-coder/solana-agent/main.svg)](https://codecov.io/gh/truemagic-coder/solana-agent)
8
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/truemagic-coder/solana-agent/test.yml?branch=main)](https://github.com/truemagic-coder/solana-agent/actions/workflows/test.yml)
9
+
10
+ ![Solana Agent Logo](https://dl.walletbubbles.com/solana-agent-logo.png?width=200)
11
+
12
+ ## Features
13
+
14
+ * Text streaming messages by AI Agents
15
+ * Conversational memory per user shared by all AI Agents
16
+ * Routing based on AI Agent specializations
17
+ * Built-in Internet Search for all AI Agents
18
+ * Organizational mission, values, goals, and guidance for all AI Agents
19
+ * Robust AI Agent tool plugins based on standard python packages
20
+
21
+ ## Stack
22
+
23
+ * [Python](https://python.org) - programming language
24
+ * [OpenAI](https://openai.com) - LLMs
25
+ * [MongoDB](https://mongodb.com) - database
26
+ * [Zep](https://getzep.com) - conversational memory
27
+
28
+ ## Installation
29
+
30
+ You can install Solana Agent using pip:
31
+
32
+ `pip install solana-agent`
33
+
34
+ ## Documentation
35
+
36
+ Each public method has a docstring for real-time IDE hinting.
37
+
38
+ ## Example App
39
+
40
+ ```python
41
+ from solana_agent import SolanaAgent
42
+
43
+ config = {
44
+ "organization": {
45
+ "mission_statement": "To revolutionize knowledge work through AI-human collaboration that puts people first.",
46
+ "values": {
47
+ "Human-Centered": "Always prioritize human well-being and augmentation over replacement.",
48
+ "Transparency": "Provide clear explanations for decisions and never hide information.",
49
+ "Collective Intelligence": "Value diverse perspectives and combine human and AI strengths.",
50
+ "Continuous Learning": "Embrace feedback and continuously improve based on experience."
51
+ },
52
+ "goals": [
53
+ "Enable human experts to focus on high-value creative work",
54
+ "Reduce administrative overhead through intelligent automation",
55
+ "Create seamless knowledge flow across the organization"
56
+ ],
57
+ "guidance": "When making decisions, prioritize long-term user success over short-term efficiency."
58
+ },
59
+ "mongo": {
60
+ "connection_string": "mongodb://localhost:27017",
61
+ "database": "solana_agent"
62
+ },
63
+ "openai": {
64
+ "api_key": "your-openai-key",
65
+ "default_model": "gpt-4o-mini"
66
+ },
67
+ "agents": [
68
+ {
69
+ "name": "research_specialist",
70
+ "instructions": "You are an expert researcher who synthesizes complex information clearly.",
71
+ "specialization": "Research and knowledge synthesis",
72
+ "model": "o3-mini",
73
+ "tools": ["some_tool"]
74
+ },
75
+ {
76
+ "name": "customer_support",
77
+ "instructions": "You provide friendly, helpful customer support responses.",
78
+ "specialization": "Customer inquiries",
79
+ "model": "gpt-4o-mini"
80
+ }
81
+ ],
82
+ }
83
+
84
+ # Create agent with configuration
85
+ solana_agent = SolanaAgent(config=config)
86
+
87
+ # Process a query that can use tools
88
+ async for response in solana_agent.process("user123", "What are the latest AI developments?"):
89
+ print(response, end="")
90
+ ```
91
+
92
+ ## Solana Agent Kit
93
+
94
+ [Solana Agent Kit](https://github.com/truemagic-coder/solana-agent-kit)
95
+
96
+ ## Example App
97
+
98
+ [Solana Agent Example App](https://github.com/truemagic-coder/solana-agent-app)
99
+
100
+ ## License
101
+
102
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "solana-agent"
3
- version = "12.0.0"
3
+ version = "14.0.1"
4
4
  description = "The Future of Work"
5
5
  authors = ["Bevan Hunt <bevan@bevanhunt.com>"]
6
6
  license = "MIT"
@@ -18,22 +18,16 @@ python_paths = [".", "tests"]
18
18
 
19
19
  [tool.poetry.dependencies]
20
20
  python = ">=3.12,<4.0"
21
- openai = "^1.66.3"
21
+ openai = "^1.68.0"
22
22
  pydantic = "^2.10.6"
23
- pymongo = "^4.11.2"
23
+ pymongo = "^4.11.3"
24
24
  zep-cloud = "^2.7.0"
25
25
  zep-python = "^2.0.2"
26
- requests = "^2.32.3"
27
- pinecone = "^6.0.2"
28
- pandas = "^2.2.3"
29
- ntplib = "^0.4.0"
30
- qdrant-client = "^1.13.3"
31
26
 
32
27
  [tool.poetry.dev-dependencies]
33
28
  pytest = "^8.3.5"
34
29
  pytest-cov = "^6.0.0"
35
30
  pytest-asyncio = "^0.25.3"
36
- uv = "^0.6.6"
37
31
 
38
32
  [build-system]
39
33
  requires = ["poetry-core>=1.0.0"]
@@ -0,0 +1,33 @@
1
+ """
2
+ Solana Agent - An AI agent framework with routing, memory, and specialized agents.
3
+
4
+ This package provides a modular framework for building AI agent systems with
5
+ multiple specialized agents, memory management, and conversation routing.
6
+ """
7
+
8
+ __version__ = "14.0.0" # Update with your actual version
9
+
10
+ # Client interface (main entry point)
11
+ from solana_agent.client.solana_agent import SolanaAgent
12
+
13
+ # Factory for creating agent systems
14
+ from solana_agent.factories.agent_factory import SolanaAgentFactory
15
+
16
+ # Useful tools and utilities
17
+ from solana_agent.plugins.manager import PluginManager
18
+ from solana_agent.plugins.registry import ToolRegistry
19
+ from solana_agent.plugins.tools import AutoTool
20
+
21
+ # Package metadata
22
+ __all__ = [
23
+ # Main client interfaces
24
+ "SolanaAgent",
25
+
26
+ # Factories
27
+ "SolanaAgentFactory",
28
+
29
+ # Tools
30
+ "PluginManager",
31
+ "ToolRegistry",
32
+ "AutoTool",
33
+ ]
@@ -0,0 +1,6 @@
1
+ """
2
+ Adapters for external systems and services.
3
+
4
+ These adapters implement the interfaces defined in solana_agent.interfaces
5
+ and provide concrete implementations for interacting with external systems.
6
+ """
@@ -0,0 +1,123 @@
1
+ """
2
+ LLM provider adapters for the Solana Agent system.
3
+
4
+ These adapters implement the LLMProvider interface for different LLM services.
5
+ """
6
+ from typing import AsyncGenerator, List, Type, TypeVar
7
+
8
+ from openai import OpenAI
9
+ from pydantic import BaseModel
10
+
11
+ from solana_agent.interfaces.providers.llm import LLMProvider
12
+
13
+ T = TypeVar('T', bound=BaseModel)
14
+
15
+
16
+ class OpenAIAdapter(LLMProvider):
17
+ """OpenAI implementation of LLMProvider with web search capabilities."""
18
+
19
+ def __init__(self, api_key: str, model: str = "gpt-4o-mini"):
20
+ self.client = OpenAI(api_key=api_key)
21
+ self.model = model
22
+ # Add search-enabled model variants
23
+ self.search_models = {
24
+ "gpt-4o": "gpt-4o-search-preview",
25
+ "gpt-4o-mini": "gpt-4o-mini-search-preview"
26
+ }
27
+
28
+ async def generate_text(
29
+ self,
30
+ prompt: str,
31
+ system_prompt: str = "",
32
+ needs_search: bool = False,
33
+ **kwargs,
34
+ ) -> AsyncGenerator[str, None]:
35
+ """Generate text from OpenAI models with web search capability."""
36
+ messages = []
37
+
38
+ if system_prompt:
39
+ messages.append({"role": "system", "content": system_prompt})
40
+
41
+ messages.append({"role": "user", "content": prompt})
42
+
43
+ # Prepare request parameters
44
+ request_params = {
45
+ "messages": messages,
46
+ "stream": kwargs.get("stream", True),
47
+ "response_format": kwargs.get("response_format", None),
48
+ }
49
+
50
+ # If search is needed, update model and add search options
51
+ if needs_search:
52
+ base_model = kwargs.get("model", self.model)
53
+ request_params["model"] = self.search_models.get(
54
+ base_model, "gpt-4o-mini-search-preview")
55
+ request_params["web_search_options"] = {
56
+ "search_context_size": "medium",
57
+ "user_location": {
58
+ "type": "approximate",
59
+ "approximate": {
60
+ "country": "US",
61
+ "timezone": "America/Los_Angeles"
62
+ }
63
+ }
64
+ }
65
+ else:
66
+ request_params["model"] = kwargs.get("model", self.model)
67
+
68
+ try:
69
+ response = self.client.chat.completions.create(**request_params)
70
+ current_text = ""
71
+
72
+ for chunk in response:
73
+ if chunk.choices:
74
+ # Handle content
75
+ if chunk.choices[0].delta.content:
76
+ text = chunk.choices[0].delta.content
77
+ current_text += text
78
+ yield text
79
+
80
+ except Exception as e:
81
+ print(f"Error in generate_text: {str(e)}")
82
+ import traceback
83
+ print(traceback.format_exc())
84
+ yield f"I apologize, but I encountered an error: {str(e)}"
85
+
86
+ def generate_embedding(self, text: str) -> List[float]:
87
+ """Generate embeddings for a given text using OpenAI's embedding model."""
88
+ try:
89
+ response = self.client.embeddings.create(
90
+ model="text-embedding-3-small",
91
+ input=text
92
+ )
93
+ return response.data[0].embedding
94
+ except Exception as e:
95
+ print(f"Error generating embedding: {e}")
96
+ # Return a zero vector as fallback (not ideal but prevents crashing)
97
+ return [0.0] * 1536 # Standard size for text-embedding-3-small
98
+
99
+ async def parse_structured_output(
100
+ self,
101
+ prompt: str,
102
+ system_prompt: str,
103
+ model_class: Type[T],
104
+ **kwargs
105
+ ) -> T:
106
+ """Generate structured output using Pydantic model parsing."""
107
+ messages = []
108
+ if system_prompt:
109
+ messages.append({"role": "system", "content": system_prompt})
110
+
111
+ messages.append({"role": "user", "content": prompt})
112
+
113
+ try:
114
+ # First try the beta parsing API
115
+ completion = self.client.beta.chat.completions.parse(
116
+ model=kwargs.get("model", self.model),
117
+ messages=messages,
118
+ response_format=model_class,
119
+ temperature=kwargs.get("temperature", 0.2),
120
+ )
121
+ return completion.choices[0].message.parsed
122
+ except Exception as e:
123
+ print(f"Error with beta.parse method: {e}")
@@ -0,0 +1,69 @@
1
+ """
2
+ MongoDB adapter for the Solana Agent system.
3
+
4
+ This adapter implements the DataStorageProvider interface for MongoDB.
5
+ """
6
+ import uuid
7
+ from typing import Dict, List, Tuple, Optional
8
+
9
+ from pymongo import MongoClient
10
+
11
+ from solana_agent.interfaces.providers.data_storage import DataStorageProvider
12
+
13
+
14
+ class MongoDBAdapter(DataStorageProvider):
15
+ """MongoDB implementation of DataStorageProvider."""
16
+
17
+ def __init__(self, connection_string: str, database_name: str):
18
+ self.client = MongoClient(connection_string)
19
+ self.db = self.client[database_name]
20
+
21
+ def create_collection(self, name: str) -> None:
22
+ if name not in self.db.list_collection_names():
23
+ self.db.create_collection(name)
24
+
25
+ def collection_exists(self, name: str) -> bool:
26
+ return name in self.db.list_collection_names()
27
+
28
+ def insert_one(self, collection: str, document: Dict) -> str:
29
+ if "_id" not in document:
30
+ document["_id"] = str(uuid.uuid4())
31
+ self.db[collection].insert_one(document)
32
+ return document["_id"]
33
+
34
+ def find_one(self, collection: str, query: Dict) -> Optional[Dict]:
35
+ return self.db[collection].find_one(query)
36
+
37
+ def find(
38
+ self,
39
+ collection: str,
40
+ query: Dict,
41
+ sort: Optional[List[Tuple]] = None,
42
+ limit: int = 0,
43
+ skip: int = 0
44
+ ) -> List[Dict]:
45
+ cursor = self.db[collection].find(query)
46
+ if sort:
47
+ cursor = cursor.sort(sort)
48
+ if limit > 0:
49
+ cursor = cursor.limit(limit)
50
+ if skip > 0:
51
+ cursor = cursor.skip(skip)
52
+ return list(cursor)
53
+
54
+ def update_one(self, collection: str, query: Dict, update: Dict, upsert: bool = False) -> bool:
55
+ result = self.db[collection].update_one(query, update, upsert=upsert)
56
+ return result.modified_count > 0 or (upsert and result.upserted_id is not None)
57
+
58
+ def delete_one(self, collection: str, query: Dict) -> bool:
59
+ result = self.db[collection].delete_one(query)
60
+ return result.deleted_count > 0
61
+
62
+ def count_documents(self, collection: str, query: Dict) -> int:
63
+ return self.db[collection].count_documents(query)
64
+
65
+ def aggregate(self, collection: str, pipeline: List[Dict]) -> List[Dict]:
66
+ return list(self.db[collection].aggregate(pipeline))
67
+
68
+ def create_index(self, collection: str, keys: List[Tuple], **kwargs) -> None:
69
+ self.db[collection].create_index(keys, **kwargs)
File without changes
@@ -0,0 +1,75 @@
1
+ """
2
+ Simplified client interface for interacting with the Solana Agent system.
3
+
4
+ This module provides a clean API for end users to interact with
5
+ the agent system without dealing with internal implementation details.
6
+ """
7
+ import json
8
+ import importlib.util
9
+ from typing import AsyncGenerator, Dict, Any
10
+
11
+ from solana_agent.factories.agent_factory import SolanaAgentFactory
12
+
13
+
14
+ class SolanaAgent:
15
+ """Simplified client interface for interacting with the agent system."""
16
+
17
+ def __init__(self, config_path: str = None, config: Dict[str, Any] = None):
18
+ """Initialize the agent system from config file or dictionary.
19
+
20
+ Args:
21
+ config_path: Path to configuration file (JSON or Python)
22
+ config: Configuration dictionary
23
+ """
24
+ if not config and not config_path:
25
+ raise ValueError("Either config or config_path must be provided")
26
+
27
+ if config_path:
28
+ with open(config_path, "r") as f:
29
+ if config_path.endswith(".json"):
30
+ config = json.load(f)
31
+ else:
32
+ # Assume it's a Python file
33
+ spec = importlib.util.spec_from_file_location(
34
+ "config", config_path)
35
+ config_module = importlib.util.module_from_spec(spec)
36
+ spec.loader.exec_module(config_module)
37
+ config = config_module.config
38
+
39
+ self.query_service = SolanaAgentFactory.create_from_config(config)
40
+
41
+ async def process(self, user_id: str, message: str) -> AsyncGenerator[str, None]:
42
+ """Process a user message and return the response stream.
43
+
44
+ Args:
45
+ user_id: User ID
46
+ message: User message
47
+
48
+ Returns:
49
+ Async generator yielding response chunks
50
+ """
51
+ async for chunk in self.query_service.process(user_id, message):
52
+ yield chunk
53
+
54
+ async def get_user_history(
55
+ self,
56
+ user_id: str,
57
+ page_num: int = 1,
58
+ page_size: int = 20,
59
+ sort_order: str = "asc" # "asc" for oldest-first, "desc" for newest-first
60
+ ) -> Dict[str, Any]:
61
+ """
62
+ Get paginated message history for a user.
63
+
64
+ Args:
65
+ user_id: User ID
66
+ page_num: Page number (starting from 1)
67
+ page_size: Number of messages per page
68
+ sort_order: Sort order ("asc" or "desc")
69
+
70
+ Returns:
71
+ Dictionary with paginated results and metadata
72
+ """
73
+ return await self.query_service.get_user_history(
74
+ user_id, page_num, page_size, sort_order
75
+ )
@@ -0,0 +1,6 @@
1
+ """
2
+ Domain models for the Solana Agent system.
3
+
4
+ This package contains all the core domain models that represent the
5
+ business objects and value types in the system.
6
+ """
@@ -0,0 +1,80 @@
1
+ """
2
+ Domain models for AI and human agents.
3
+
4
+ This module defines the core domain models for representing
5
+ AI agents, human agents, and organization mission/values.
6
+ """
7
+ from typing import List, Optional, Dict, Any, Union
8
+ # Import the class directly, not the module
9
+ from datetime import datetime
10
+ from pydantic import BaseModel, Field, field_validator
11
+
12
+
13
+ class OrganizationMission(BaseModel):
14
+ """Organization mission and values to guide agent behavior."""
15
+
16
+ mission_statement: str = Field(...,
17
+ description="Organization mission statement")
18
+ values: List[Dict[str, str]] = Field(
19
+ default_factory=list,
20
+ description="Organization values as name-description pairs"
21
+ )
22
+ goals: List[str] = Field(
23
+ default_factory=list,
24
+ description="Organization goals"
25
+ )
26
+ guidance: Optional[str] = Field(
27
+ None, description="Additional guidance for agents")
28
+
29
+ @field_validator("mission_statement")
30
+ @classmethod
31
+ def mission_statement_not_empty(cls, v: str) -> str:
32
+ """Validate that mission statement is not empty."""
33
+ if not v.strip():
34
+ raise ValueError("Mission statement cannot be empty")
35
+ return v
36
+
37
+ @field_validator("values")
38
+ @classmethod
39
+ def validate_values(cls, values: List[Dict[str, str]]) -> List[Dict[str, str]]:
40
+ """Validate that values have proper format."""
41
+ for value in values:
42
+ if "name" not in value or "description" not in value:
43
+ raise ValueError("Each value must have a name and description")
44
+ return values
45
+
46
+
47
+ class AIAgent(BaseModel):
48
+ """AI agent with specialized capabilities."""
49
+
50
+ model_config = {"arbitrary_types_allowed": True}
51
+
52
+ name: str = Field(..., description="Unique agent identifier name")
53
+ instructions: str = Field(...,
54
+ description="Base instructions for the agent")
55
+ specialization: str = Field(..., description="Agent's specialized domain")
56
+ model: str = Field("gpt-4o-mini", description="Language model to use")
57
+ created_at: datetime = Field(
58
+ default_factory=datetime.now, description="Creation timestamp")
59
+ updated_at: datetime = Field(
60
+ default_factory=datetime.now, description="Last update timestamp")
61
+ description: Optional[str] = Field(
62
+ None, description="Agent description or summary")
63
+
64
+ @field_validator("name", "specialization")
65
+ @classmethod
66
+ def not_empty(cls, v: str) -> str:
67
+ """Validate that string fields are not empty."""
68
+ if not v.strip():
69
+ raise ValueError("Field cannot be empty")
70
+ return v
71
+
72
+ @field_validator("instructions")
73
+ @classmethod
74
+ def instructions_not_empty(cls, v: str) -> str:
75
+ """Validate that instructions are not empty."""
76
+ if not v.strip():
77
+ raise ValueError("Instructions cannot be empty")
78
+ if len(v) < 10:
79
+ raise ValueError("Instructions must be at least 10 characters")
80
+ return v
@@ -0,0 +1,14 @@
1
+ from typing import List
2
+ from pydantic import BaseModel, Field
3
+
4
+
5
+ class QueryAnalysis(BaseModel):
6
+ """Analysis of a user query for routing purposes."""
7
+ primary_specialization: str = Field(...,
8
+ description="Main specialization needed")
9
+ secondary_specializations: List[str] = Field(
10
+ ..., description="Other helpful specializations")
11
+ complexity_level: int = Field(...,
12
+ description="Complexity level (1-5)")
13
+ topics: List[str] = Field(..., description="Key topics in the query")
14
+ confidence: float = Field(..., description="Confidence in the analysis")
File without changes