zyndai-agent 0.1.4__tar.gz → 0.1.5__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.4
2
2
  Name: zyndai-agent
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: A Langchain and Autogen wrapper that enables agents to communicate and establish identity on the Zynd AI Network. This SDK provides three core capabilities: Identity Management, Agent Discovery & Search, and MQTT-based Communication.
5
5
  Author-email: Swapnil Shinde <swapnilshinde9382@gmail.com>
6
6
  Requires-Python: >=3.12
@@ -8,9 +8,7 @@ Description-Content-Type: text/markdown
8
8
  Requires-Dist: base58>=2.1.1
9
9
  Requires-Dist: cryptography>=46.0.3
10
10
  Requires-Dist: eth-account>=0.13.7
11
- Requires-Dist: langchain<1.0.4
12
- Requires-Dist: langchain-core>=1.0.3
13
- Requires-Dist: langchain-openai>=1.0.2
11
+ Requires-Dist: langchain>=1.1.0
14
12
  Requires-Dist: paho-mqtt>=2.1.0
15
13
  Requires-Dist: x402>=0.2.1
16
14
 
@@ -46,18 +44,45 @@ pip install -r requirements.txt
46
44
 
47
45
  ### 1. Get Your Credentials
48
46
 
49
- 1. Visit the [ZyndAI Dashboard](https://dashboard.zynd.ai) and create an agent
50
- 2. Download your `identity_credential.json` file
51
- 3. Copy your `secret_seed` from the dashboard
47
+ Follow these steps to set up your agent credentials from the ZyndAI Dashboard:
48
+
49
+ 1. **Visit the Dashboard**
50
+ - Go to [dashboard.zynd.ai](https://dashboard.zynd.ai)
51
+ - Click "Get Started"
52
+
53
+ 2. **Connect Your Wallet**
54
+ - Connect your MetaMask wallet
55
+ - Ensure you're on the correct network
56
+
57
+ 3. **Create Your Agent**
58
+ - Navigate to the "Agents" section
59
+ - Click "Create New Agent"
60
+ - Fill in your agent's details (name, description, capabilities)
61
+ - Submit to create your agent
62
+
63
+ 4. **Get Your Agent Seed**
64
+ - After creating the agent, view your agent's details
65
+ - Copy the **Agent Seed** (secret seed phrase)
66
+ - Save this securely - you'll need it for your `.env` file
67
+
68
+ 5. **Download DID Credential Document**
69
+ - In your agent's view, go to the **Credentials** tab
70
+ - Copy or download the **DID Document Credential**
71
+ - Save this as `identity_credential.json` in your project directory
52
72
 
53
73
  ### 2. Environment Setup
54
74
 
55
- Create a `.env` file:
75
+ Create a `.env` file in your project root:
56
76
  ```env
57
- AGENT_SEED=your_secret_seed_here
77
+ AGENT_SEED=your_agent_seed_from_dashboard
58
78
  OPENAI_API_KEY=your_openai_api_key_here
59
79
  ```
60
80
 
81
+ **Important Notes:**
82
+ - Keep your `AGENT_SEED` and `identity_credential.json` secure and never commit them to version control
83
+ - The agent seed and DID credential must match - they are cryptographically linked
84
+ - Add both `.env` and `identity_credential.json` to your `.gitignore` file
85
+
61
86
  ### 3. Basic Agent Example
62
87
  ```python
63
88
  from zyndai_agent.agent import AgentConfig, ZyndAIAgent
@@ -206,7 +231,7 @@ Create LangChain tools that leverage x402-enabled paid APIs:
206
231
  ```python
207
232
  from langchain_core.tools import tool
208
233
  from langchain_openai import ChatOpenAI
209
- from langchain.agents import create_tool_calling_agent, AgentExecutor
234
+ from langchain_classic.agents import create_tool_calling_agent, AgentExecutor
210
235
  from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
211
236
  from zyndai_agent.agent import AgentConfig, ZyndAIAgent
212
237
  import os
@@ -442,9 +467,9 @@ from zyndai_agent.agent import AgentConfig, ZyndAIAgent
442
467
  from zyndai_agent.communication import MQTTMessage
443
468
  from langchain_openai import ChatOpenAI
444
469
  from langchain_core.tools import tool
445
- from langchain.agents import create_tool_calling_agent, AgentExecutor
470
+ from langchain_classic.agents import create_tool_calling_agent, AgentExecutor
446
471
  from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
447
- from langchain.memory import ConversationBufferMemory
472
+ from langchain_core.chat_history import InMemoryChatMessageHistory
448
473
  import json
449
474
 
450
475
  @tool
@@ -496,10 +521,12 @@ zyndai_agent = ZyndAIAgent(agent_config=agent_config)
496
521
  # Create LangChain agent with custom tool
497
522
  llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
498
523
  tools = [compare_stocks]
499
- memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
524
+
525
+ # Create message history store
526
+ message_history = InMemoryChatMessageHistory()
500
527
 
501
528
  prompt = ChatPromptTemplate.from_messages([
502
- ("system", """You are a Stock Comparison Agent.
529
+ ("system", """You are a Stock Comparison Agent.
503
530
  Use the compare_stocks tool to analyze stock data.
504
531
  Capabilities: stock_comparison, financial_analysis, investment_advice"""),
505
532
  MessagesPlaceholder(variable_name="chat_history"),
@@ -508,14 +535,25 @@ prompt = ChatPromptTemplate.from_messages([
508
535
  ])
509
536
 
510
537
  agent = create_tool_calling_agent(llm, tools, prompt)
511
- agent_executor = AgentExecutor(agent=agent, tools=tools, memory=memory, verbose=True)
538
+ agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
512
539
 
513
540
  zyndai_agent.set_agent_executor(agent_executor)
514
541
 
515
542
  # Message handler
516
543
  def message_handler(message: MQTTMessage, topic: str):
517
544
  print(f"Received: {message.content}")
518
- response = zyndai_agent.agent_executor.invoke({"input": message.content})
545
+
546
+ # Add user message to history
547
+ message_history.add_user_message(message.content)
548
+
549
+ response = zyndai_agent.agent_executor.invoke({
550
+ "input": message.content,
551
+ "chat_history": message_history.messages
552
+ })
553
+
554
+ # Add AI response to history
555
+ message_history.add_ai_message(response["output"])
556
+
519
557
  zyndai_agent.send_message(response["output"])
520
558
 
521
559
  zyndai_agent.add_message_handler(message_handler)
@@ -30,18 +30,45 @@ pip install -r requirements.txt
30
30
 
31
31
  ### 1. Get Your Credentials
32
32
 
33
- 1. Visit the [ZyndAI Dashboard](https://dashboard.zynd.ai) and create an agent
34
- 2. Download your `identity_credential.json` file
35
- 3. Copy your `secret_seed` from the dashboard
33
+ Follow these steps to set up your agent credentials from the ZyndAI Dashboard:
34
+
35
+ 1. **Visit the Dashboard**
36
+ - Go to [dashboard.zynd.ai](https://dashboard.zynd.ai)
37
+ - Click "Get Started"
38
+
39
+ 2. **Connect Your Wallet**
40
+ - Connect your MetaMask wallet
41
+ - Ensure you're on the correct network
42
+
43
+ 3. **Create Your Agent**
44
+ - Navigate to the "Agents" section
45
+ - Click "Create New Agent"
46
+ - Fill in your agent's details (name, description, capabilities)
47
+ - Submit to create your agent
48
+
49
+ 4. **Get Your Agent Seed**
50
+ - After creating the agent, view your agent's details
51
+ - Copy the **Agent Seed** (secret seed phrase)
52
+ - Save this securely - you'll need it for your `.env` file
53
+
54
+ 5. **Download DID Credential Document**
55
+ - In your agent's view, go to the **Credentials** tab
56
+ - Copy or download the **DID Document Credential**
57
+ - Save this as `identity_credential.json` in your project directory
36
58
 
37
59
  ### 2. Environment Setup
38
60
 
39
- Create a `.env` file:
61
+ Create a `.env` file in your project root:
40
62
  ```env
41
- AGENT_SEED=your_secret_seed_here
63
+ AGENT_SEED=your_agent_seed_from_dashboard
42
64
  OPENAI_API_KEY=your_openai_api_key_here
43
65
  ```
44
66
 
67
+ **Important Notes:**
68
+ - Keep your `AGENT_SEED` and `identity_credential.json` secure and never commit them to version control
69
+ - The agent seed and DID credential must match - they are cryptographically linked
70
+ - Add both `.env` and `identity_credential.json` to your `.gitignore` file
71
+
45
72
  ### 3. Basic Agent Example
46
73
  ```python
47
74
  from zyndai_agent.agent import AgentConfig, ZyndAIAgent
@@ -190,7 +217,7 @@ Create LangChain tools that leverage x402-enabled paid APIs:
190
217
  ```python
191
218
  from langchain_core.tools import tool
192
219
  from langchain_openai import ChatOpenAI
193
- from langchain.agents import create_tool_calling_agent, AgentExecutor
220
+ from langchain_classic.agents import create_tool_calling_agent, AgentExecutor
194
221
  from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
195
222
  from zyndai_agent.agent import AgentConfig, ZyndAIAgent
196
223
  import os
@@ -426,9 +453,9 @@ from zyndai_agent.agent import AgentConfig, ZyndAIAgent
426
453
  from zyndai_agent.communication import MQTTMessage
427
454
  from langchain_openai import ChatOpenAI
428
455
  from langchain_core.tools import tool
429
- from langchain.agents import create_tool_calling_agent, AgentExecutor
456
+ from langchain_classic.agents import create_tool_calling_agent, AgentExecutor
430
457
  from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
431
- from langchain.memory import ConversationBufferMemory
458
+ from langchain_core.chat_history import InMemoryChatMessageHistory
432
459
  import json
433
460
 
434
461
  @tool
@@ -480,10 +507,12 @@ zyndai_agent = ZyndAIAgent(agent_config=agent_config)
480
507
  # Create LangChain agent with custom tool
481
508
  llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
482
509
  tools = [compare_stocks]
483
- memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
510
+
511
+ # Create message history store
512
+ message_history = InMemoryChatMessageHistory()
484
513
 
485
514
  prompt = ChatPromptTemplate.from_messages([
486
- ("system", """You are a Stock Comparison Agent.
515
+ ("system", """You are a Stock Comparison Agent.
487
516
  Use the compare_stocks tool to analyze stock data.
488
517
  Capabilities: stock_comparison, financial_analysis, investment_advice"""),
489
518
  MessagesPlaceholder(variable_name="chat_history"),
@@ -492,14 +521,25 @@ prompt = ChatPromptTemplate.from_messages([
492
521
  ])
493
522
 
494
523
  agent = create_tool_calling_agent(llm, tools, prompt)
495
- agent_executor = AgentExecutor(agent=agent, tools=tools, memory=memory, verbose=True)
524
+ agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
496
525
 
497
526
  zyndai_agent.set_agent_executor(agent_executor)
498
527
 
499
528
  # Message handler
500
529
  def message_handler(message: MQTTMessage, topic: str):
501
530
  print(f"Received: {message.content}")
502
- response = zyndai_agent.agent_executor.invoke({"input": message.content})
531
+
532
+ # Add user message to history
533
+ message_history.add_user_message(message.content)
534
+
535
+ response = zyndai_agent.agent_executor.invoke({
536
+ "input": message.content,
537
+ "chat_history": message_history.messages
538
+ })
539
+
540
+ # Add AI response to history
541
+ message_history.add_ai_message(response["output"])
542
+
503
543
  zyndai_agent.send_message(response["output"])
504
544
 
505
545
  zyndai_agent.add_message_handler(message_handler)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "zyndai-agent"
3
- version = "0.1.4"
3
+ version = "0.1.5"
4
4
  description = "A Langchain and Autogen wrapper that enables agents to communicate and establish identity on the Zynd AI Network. This SDK provides three core capabilities: Identity Management, Agent Discovery & Search, and MQTT-based Communication."
5
5
  authors = [
6
6
  { name = "Swapnil Shinde", email = "swapnilshinde9382@gmail.com" }
@@ -11,9 +11,7 @@ dependencies = [
11
11
  "base58>=2.1.1",
12
12
  "cryptography>=46.0.3",
13
13
  "eth-account>=0.13.7",
14
- "langchain<1.0.4",
15
- "langchain-core>=1.0.3",
16
- "langchain-openai>=1.0.2",
14
+ "langchain>=1.1.0",
17
15
  "paho-mqtt>=2.1.0",
18
16
  "x402>=0.2.1",
19
17
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zyndai-agent
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: A Langchain and Autogen wrapper that enables agents to communicate and establish identity on the Zynd AI Network. This SDK provides three core capabilities: Identity Management, Agent Discovery & Search, and MQTT-based Communication.
5
5
  Author-email: Swapnil Shinde <swapnilshinde9382@gmail.com>
6
6
  Requires-Python: >=3.12
@@ -8,9 +8,7 @@ Description-Content-Type: text/markdown
8
8
  Requires-Dist: base58>=2.1.1
9
9
  Requires-Dist: cryptography>=46.0.3
10
10
  Requires-Dist: eth-account>=0.13.7
11
- Requires-Dist: langchain<1.0.4
12
- Requires-Dist: langchain-core>=1.0.3
13
- Requires-Dist: langchain-openai>=1.0.2
11
+ Requires-Dist: langchain>=1.1.0
14
12
  Requires-Dist: paho-mqtt>=2.1.0
15
13
  Requires-Dist: x402>=0.2.1
16
14
 
@@ -46,18 +44,45 @@ pip install -r requirements.txt
46
44
 
47
45
  ### 1. Get Your Credentials
48
46
 
49
- 1. Visit the [ZyndAI Dashboard](https://dashboard.zynd.ai) and create an agent
50
- 2. Download your `identity_credential.json` file
51
- 3. Copy your `secret_seed` from the dashboard
47
+ Follow these steps to set up your agent credentials from the ZyndAI Dashboard:
48
+
49
+ 1. **Visit the Dashboard**
50
+ - Go to [dashboard.zynd.ai](https://dashboard.zynd.ai)
51
+ - Click "Get Started"
52
+
53
+ 2. **Connect Your Wallet**
54
+ - Connect your MetaMask wallet
55
+ - Ensure you're on the correct network
56
+
57
+ 3. **Create Your Agent**
58
+ - Navigate to the "Agents" section
59
+ - Click "Create New Agent"
60
+ - Fill in your agent's details (name, description, capabilities)
61
+ - Submit to create your agent
62
+
63
+ 4. **Get Your Agent Seed**
64
+ - After creating the agent, view your agent's details
65
+ - Copy the **Agent Seed** (secret seed phrase)
66
+ - Save this securely - you'll need it for your `.env` file
67
+
68
+ 5. **Download DID Credential Document**
69
+ - In your agent's view, go to the **Credentials** tab
70
+ - Copy or download the **DID Document Credential**
71
+ - Save this as `identity_credential.json` in your project directory
52
72
 
53
73
  ### 2. Environment Setup
54
74
 
55
- Create a `.env` file:
75
+ Create a `.env` file in your project root:
56
76
  ```env
57
- AGENT_SEED=your_secret_seed_here
77
+ AGENT_SEED=your_agent_seed_from_dashboard
58
78
  OPENAI_API_KEY=your_openai_api_key_here
59
79
  ```
60
80
 
81
+ **Important Notes:**
82
+ - Keep your `AGENT_SEED` and `identity_credential.json` secure and never commit them to version control
83
+ - The agent seed and DID credential must match - they are cryptographically linked
84
+ - Add both `.env` and `identity_credential.json` to your `.gitignore` file
85
+
61
86
  ### 3. Basic Agent Example
62
87
  ```python
63
88
  from zyndai_agent.agent import AgentConfig, ZyndAIAgent
@@ -206,7 +231,7 @@ Create LangChain tools that leverage x402-enabled paid APIs:
206
231
  ```python
207
232
  from langchain_core.tools import tool
208
233
  from langchain_openai import ChatOpenAI
209
- from langchain.agents import create_tool_calling_agent, AgentExecutor
234
+ from langchain_classic.agents import create_tool_calling_agent, AgentExecutor
210
235
  from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
211
236
  from zyndai_agent.agent import AgentConfig, ZyndAIAgent
212
237
  import os
@@ -442,9 +467,9 @@ from zyndai_agent.agent import AgentConfig, ZyndAIAgent
442
467
  from zyndai_agent.communication import MQTTMessage
443
468
  from langchain_openai import ChatOpenAI
444
469
  from langchain_core.tools import tool
445
- from langchain.agents import create_tool_calling_agent, AgentExecutor
470
+ from langchain_classic.agents import create_tool_calling_agent, AgentExecutor
446
471
  from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
447
- from langchain.memory import ConversationBufferMemory
472
+ from langchain_core.chat_history import InMemoryChatMessageHistory
448
473
  import json
449
474
 
450
475
  @tool
@@ -496,10 +521,12 @@ zyndai_agent = ZyndAIAgent(agent_config=agent_config)
496
521
  # Create LangChain agent with custom tool
497
522
  llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
498
523
  tools = [compare_stocks]
499
- memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
524
+
525
+ # Create message history store
526
+ message_history = InMemoryChatMessageHistory()
500
527
 
501
528
  prompt = ChatPromptTemplate.from_messages([
502
- ("system", """You are a Stock Comparison Agent.
529
+ ("system", """You are a Stock Comparison Agent.
503
530
  Use the compare_stocks tool to analyze stock data.
504
531
  Capabilities: stock_comparison, financial_analysis, investment_advice"""),
505
532
  MessagesPlaceholder(variable_name="chat_history"),
@@ -508,14 +535,25 @@ prompt = ChatPromptTemplate.from_messages([
508
535
  ])
509
536
 
510
537
  agent = create_tool_calling_agent(llm, tools, prompt)
511
- agent_executor = AgentExecutor(agent=agent, tools=tools, memory=memory, verbose=True)
538
+ agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
512
539
 
513
540
  zyndai_agent.set_agent_executor(agent_executor)
514
541
 
515
542
  # Message handler
516
543
  def message_handler(message: MQTTMessage, topic: str):
517
544
  print(f"Received: {message.content}")
518
- response = zyndai_agent.agent_executor.invoke({"input": message.content})
545
+
546
+ # Add user message to history
547
+ message_history.add_user_message(message.content)
548
+
549
+ response = zyndai_agent.agent_executor.invoke({
550
+ "input": message.content,
551
+ "chat_history": message_history.messages
552
+ })
553
+
554
+ # Add AI response to history
555
+ message_history.add_ai_message(response["output"])
556
+
519
557
  zyndai_agent.send_message(response["output"])
520
558
 
521
559
  zyndai_agent.add_message_handler(message_handler)
@@ -1,8 +1,6 @@
1
1
  base58>=2.1.1
2
2
  cryptography>=46.0.3
3
3
  eth-account>=0.13.7
4
- langchain<1.0.4
5
- langchain-core>=1.0.3
6
- langchain-openai>=1.0.2
4
+ langchain>=1.1.0
7
5
  paho-mqtt>=2.1.0
8
6
  x402>=0.2.1
File without changes