solana-agent 12.0.0__tar.gz → 14.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.
Files changed (40) hide show
  1. solana_agent-14.0.0/PKG-INFO +121 -0
  2. solana_agent-14.0.0/README.md +92 -0
  3. {solana_agent-12.0.0 → solana_agent-14.0.0}/pyproject.toml +4 -4
  4. solana_agent-14.0.0/solana_agent/__init__.py +33 -0
  5. solana_agent-14.0.0/solana_agent/adapters/__init__.py +6 -0
  6. solana_agent-14.0.0/solana_agent/adapters/llm_adapter.py +123 -0
  7. solana_agent-14.0.0/solana_agent/adapters/mongodb_adapter.py +69 -0
  8. solana_agent-14.0.0/solana_agent/client/__init__.py +0 -0
  9. solana_agent-14.0.0/solana_agent/client/solana_agent.py +75 -0
  10. solana_agent-14.0.0/solana_agent/domains/__init__.py +6 -0
  11. solana_agent-14.0.0/solana_agent/domains/agents.py +80 -0
  12. solana_agent-14.0.0/solana_agent/domains/routing.py +14 -0
  13. solana_agent-14.0.0/solana_agent/factories/__init__.py +0 -0
  14. solana_agent-14.0.0/solana_agent/factories/agent_factory.py +148 -0
  15. solana_agent-14.0.0/solana_agent/interfaces/__init__.py +11 -0
  16. solana_agent-14.0.0/solana_agent/interfaces/plugins/plugins.py +118 -0
  17. solana_agent-14.0.0/solana_agent/interfaces/providers/data_storage.py +53 -0
  18. solana_agent-14.0.0/solana_agent/interfaces/providers/llm.py +34 -0
  19. solana_agent-14.0.0/solana_agent/interfaces/providers/memory.py +38 -0
  20. solana_agent-14.0.0/solana_agent/interfaces/repositories/agent.py +33 -0
  21. solana_agent-14.0.0/solana_agent/interfaces/services/agent.py +41 -0
  22. solana_agent-14.0.0/solana_agent/interfaces/services/query.py +11 -0
  23. solana_agent-14.0.0/solana_agent/interfaces/services/routing.py +19 -0
  24. solana_agent-14.0.0/solana_agent/plugins/__init__.py +6 -0
  25. solana_agent-14.0.0/solana_agent/plugins/manager.py +147 -0
  26. solana_agent-14.0.0/solana_agent/plugins/registry.py +64 -0
  27. solana_agent-14.0.0/solana_agent/plugins/tools/__init__.py +10 -0
  28. solana_agent-14.0.0/solana_agent/plugins/tools/auto_tool.py +47 -0
  29. solana_agent-14.0.0/solana_agent/repositories/__init__.py +6 -0
  30. solana_agent-14.0.0/solana_agent/repositories/agent.py +99 -0
  31. solana_agent-14.0.0/solana_agent/repositories/memory.py +134 -0
  32. solana_agent-14.0.0/solana_agent/services/__init__.py +6 -0
  33. solana_agent-14.0.0/solana_agent/services/agent.py +320 -0
  34. solana_agent-14.0.0/solana_agent/services/query.py +223 -0
  35. solana_agent-14.0.0/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.0}/LICENSE +0 -0
@@ -0,0 +1,121 @@
1
+ Metadata-Version: 2.3
2
+ Name: solana-agent
3
+ Version: 14.0.0
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: ntplib (>=0.4.0,<0.5.0)
17
+ Requires-Dist: openai (>=1.67.0,<2.0.0)
18
+ Requires-Dist: pandas (>=2.2.3,<3.0.0)
19
+ Requires-Dist: pinecone (>=6.0.2,<7.0.0)
20
+ Requires-Dist: pydantic (>=2.10.6,<3.0.0)
21
+ Requires-Dist: pymongo (>=4.11.3,<5.0.0)
22
+ Requires-Dist: qdrant-client (>=1.13.3,<2.0.0)
23
+ Requires-Dist: requests (>=2.32.3,<3.0.0)
24
+ Requires-Dist: zep-cloud (>=2.7.0,<3.0.0)
25
+ Requires-Dist: zep-python (>=2.0.2,<3.0.0)
26
+ Project-URL: Repository, https://github.com/truemagic-coder/solana-agent
27
+ Description-Content-Type: text/markdown
28
+
29
+ # Solana Agent
30
+
31
+ [![PyPI - Version](https://img.shields.io/pypi/v/solana-agent)](https://pypi.org/project/solana-agent/)
32
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
33
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-orange.svg)](https://www.python.org/downloads/)
34
+ [![codecov](https://img.shields.io/codecov/c/github/truemagic-coder/solana-agent/main.svg)](https://codecov.io/gh/truemagic-coder/solana-agent)
35
+ [![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)
36
+
37
+ ![Solana Agent Logo](https://dl.walletbubbles.com/solana-agent-logo.png?width=200)
38
+
39
+ ## Technical Features
40
+
41
+ * Text streaming messages by AI Agents
42
+ * Routing based on AI Agent specializations
43
+ * Built-in default Internet Search for AI Agents
44
+ * Robust AI Agent tool plugins based on standard python packages
45
+
46
+ ## Installation
47
+
48
+ You can install Solana Agent using pip:
49
+
50
+ `pip install solana-agent`
51
+
52
+ ## Documentation
53
+
54
+ Each public method has a docstring for real-time IDE hinting.
55
+
56
+ ## Example App
57
+
58
+ ```python
59
+ from solana_agent import SolanaAgent
60
+
61
+ config = {
62
+ "organization": {
63
+ "mission_statement": "To revolutionize knowledge work through AI-human collaboration that puts people first.",
64
+ "values": {
65
+ "Human-Centered": "Always prioritize human well-being and augmentation over replacement.",
66
+ "Transparency": "Provide clear explanations for decisions and never hide information.",
67
+ "Collective Intelligence": "Value diverse perspectives and combine human and AI strengths.",
68
+ "Continuous Learning": "Embrace feedback and continuously improve based on experience."
69
+ },
70
+ "goals": [
71
+ "Enable human experts to focus on high-value creative work",
72
+ "Reduce administrative overhead through intelligent automation",
73
+ "Create seamless knowledge flow across the organization"
74
+ ],
75
+ "guidance": "When making decisions, prioritize long-term user success over short-term efficiency."
76
+ },
77
+ "mongo": {
78
+ "connection_string": "mongodb://localhost:27017",
79
+ "database": "solana_agent"
80
+ },
81
+ "openai": {
82
+ "api_key": "your-openai-key",
83
+ "default_model": "gpt-4o-mini"
84
+ },
85
+ "agents": [
86
+ {
87
+ "name": "research_specialist",
88
+ "instructions": "You are an expert researcher who synthesizes complex information clearly.",
89
+ "specialization": "Research and knowledge synthesis",
90
+ "model": "o3-mini",
91
+ "tools": ["some_tool"]
92
+ },
93
+ {
94
+ "name": "customer_support",
95
+ "instructions": "You provide friendly, helpful customer support responses.",
96
+ "specialization": "Customer inquiries",
97
+ "model": "gpt-4o-mini"
98
+ }
99
+ ],
100
+ }
101
+
102
+ # Create agent with configuration
103
+ solana_agent = SolanaAgent(config=config)
104
+
105
+ # Process a query that can use tools
106
+ async for response in solana_agent.process("user123", "What are the latest AI developments?"):
107
+ print(response, end="")
108
+ ```
109
+
110
+ ## Solana Agent Kit (plugins collection)
111
+
112
+ [Solana Agent Kit](https://github.com/truemagic-coder/solana-agent-kit)
113
+
114
+ ## Example App
115
+
116
+ [Solana Agent Example App](https://github.com/truemagic-coder/solana-agent-app)
117
+
118
+ ## License
119
+
120
+ This project is licensed under the MIT License - see the LICENSE file for details.
121
+
@@ -0,0 +1,92 @@
1
+ # Solana Agent
2
+
3
+ [![PyPI - Version](https://img.shields.io/pypi/v/solana-agent)](https://pypi.org/project/solana-agent/)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
5
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-orange.svg)](https://www.python.org/downloads/)
6
+ [![codecov](https://img.shields.io/codecov/c/github/truemagic-coder/solana-agent/main.svg)](https://codecov.io/gh/truemagic-coder/solana-agent)
7
+ [![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)
8
+
9
+ ![Solana Agent Logo](https://dl.walletbubbles.com/solana-agent-logo.png?width=200)
10
+
11
+ ## Technical Features
12
+
13
+ * Text streaming messages by AI Agents
14
+ * Routing based on AI Agent specializations
15
+ * Built-in default Internet Search for AI Agents
16
+ * Robust AI Agent tool plugins based on standard python packages
17
+
18
+ ## Installation
19
+
20
+ You can install Solana Agent using pip:
21
+
22
+ `pip install solana-agent`
23
+
24
+ ## Documentation
25
+
26
+ Each public method has a docstring for real-time IDE hinting.
27
+
28
+ ## Example App
29
+
30
+ ```python
31
+ from solana_agent import SolanaAgent
32
+
33
+ config = {
34
+ "organization": {
35
+ "mission_statement": "To revolutionize knowledge work through AI-human collaboration that puts people first.",
36
+ "values": {
37
+ "Human-Centered": "Always prioritize human well-being and augmentation over replacement.",
38
+ "Transparency": "Provide clear explanations for decisions and never hide information.",
39
+ "Collective Intelligence": "Value diverse perspectives and combine human and AI strengths.",
40
+ "Continuous Learning": "Embrace feedback and continuously improve based on experience."
41
+ },
42
+ "goals": [
43
+ "Enable human experts to focus on high-value creative work",
44
+ "Reduce administrative overhead through intelligent automation",
45
+ "Create seamless knowledge flow across the organization"
46
+ ],
47
+ "guidance": "When making decisions, prioritize long-term user success over short-term efficiency."
48
+ },
49
+ "mongo": {
50
+ "connection_string": "mongodb://localhost:27017",
51
+ "database": "solana_agent"
52
+ },
53
+ "openai": {
54
+ "api_key": "your-openai-key",
55
+ "default_model": "gpt-4o-mini"
56
+ },
57
+ "agents": [
58
+ {
59
+ "name": "research_specialist",
60
+ "instructions": "You are an expert researcher who synthesizes complex information clearly.",
61
+ "specialization": "Research and knowledge synthesis",
62
+ "model": "o3-mini",
63
+ "tools": ["some_tool"]
64
+ },
65
+ {
66
+ "name": "customer_support",
67
+ "instructions": "You provide friendly, helpful customer support responses.",
68
+ "specialization": "Customer inquiries",
69
+ "model": "gpt-4o-mini"
70
+ }
71
+ ],
72
+ }
73
+
74
+ # Create agent with configuration
75
+ solana_agent = SolanaAgent(config=config)
76
+
77
+ # Process a query that can use tools
78
+ async for response in solana_agent.process("user123", "What are the latest AI developments?"):
79
+ print(response, end="")
80
+ ```
81
+
82
+ ## Solana Agent Kit (plugins collection)
83
+
84
+ [Solana Agent Kit](https://github.com/truemagic-coder/solana-agent-kit)
85
+
86
+ ## Example App
87
+
88
+ [Solana Agent Example App](https://github.com/truemagic-coder/solana-agent-app)
89
+
90
+ ## License
91
+
92
+ 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.0"
4
4
  description = "The Future of Work"
5
5
  authors = ["Bevan Hunt <bevan@bevanhunt.com>"]
6
6
  license = "MIT"
@@ -18,9 +18,9 @@ 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.67.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
26
  requests = "^2.32.3"
@@ -33,7 +33,7 @@ qdrant-client = "^1.13.3"
33
33
  pytest = "^8.3.5"
34
34
  pytest-cov = "^6.0.0"
35
35
  pytest-asyncio = "^0.25.3"
36
- uv = "^0.6.6"
36
+ hypothesis = "^6.129.4"
37
37
 
38
38
  [build-system]
39
39
  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