Skip to content

Commit 4429095

Browse files
committed
Release v0.2.0: Refactor Store to use AgentForge.Store GenServer implementation
1 parent 1ce332c commit 4429095

File tree

7 files changed

+86
-46
lines changed

7 files changed

+86
-46
lines changed

CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.2.0] - 2025-03-30
11+
12+
### Changed
13+
- **BREAKING**: Refactored LLMAgent.Store to leverage AgentForge.Store's GenServer implementation
14+
- Store interface now returns :ok instead of updated state maps
15+
- Store now uses process names (atoms) instead of directly returning state maps
16+
- Removed unused sequence_flows function and its helper functions from flows.ex
17+
18+
### Fixed
19+
- Fixed warnings in the investment_portfolio.exs example
20+
- Fixed unused function parameters
21+
- Updated example code to use the correct Store interface
22+
23+
### Documentation
24+
- Updated documentation to reflect Store interface changes
25+
- Enhanced dynamic workflow documentation to better showcase complex scenarios
26+
1027
## [0.1.1] - 2025-03-29
1128

1229
### Added

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Add `llm_agent` to your list of dependencies in `mix.exs`:
2525
```elixir
2626
def deps do
2727
[
28-
{:llm_agent, "~> 0.1.1"},
28+
{:llm_agent, "~> 0.2.0"},
2929
# Optional LLM provider dependencies
3030
{:openai, "~> 0.5.0"}, # If using OpenAI
3131
{:anthropic, "~> 0.1.0"} # If using Anthropic

guides/architecture.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ graph TD
3333

3434
1. **Signals**: Represent events in the agent lifecycle
3535
2. **Handlers**: Process signals and update state
36-
3. **Store**: Manages conversation state and history
36+
3. **Store**: Manages conversation state and history using GenServer processes, providing a centralized state management system that leverages Elixir's OTP capabilities
3737
4. **Flows**: Combine handlers into coherent sequences
3838
5. **Providers**: Interface with LLM backends
3939
6. **Tools**: External capabilities the agent can use
@@ -76,11 +76,16 @@ classDiagram
7676
}
7777
7878
class LLMAgent.Store {
79-
+new(initial_state)
80-
+add_message(state, role, content)
81-
+add_thought(state, content)
82-
+add_tool_call(state, name, args, result)
83-
+prune_thoughts(state, max_thoughts)
79+
+start_link(options)
80+
+new(initial_state, options)
81+
+add_message(store_name, role, content)
82+
+add_thought(store_name, content)
83+
+add_tool_call(store_name, name, args, result)
84+
+get_llm_history(store_name)
85+
+get_thoughts(store_name)
86+
+get(store_name, key)
87+
+put(store_name, key, value)
88+
+delete(store_name, key)
8489
}
8590
8691
class LLMAgent.Flows {

guides/dynamic_workflows.md

+16-9
Original file line numberDiff line numberDiff line change
@@ -105,28 +105,35 @@ Below is a simplified implementation of this dynamic workflow:
105105

106106
```elixir
107107
defmodule InvestmentDemo do
108-
# Process a user message and update state
109-
def process_message(state, message) do
108+
# Start a new conversation store
109+
def start_conversation do
110+
store_name = __MODULE__.Store
111+
LLMAgent.Store.start_link(name: store_name)
112+
store_name
113+
end
114+
115+
# Process a user message using store
116+
def process_message(store_name, message) do
110117
# Simulate LLM analyzing message and deciding which tool to use
111-
{tool_name, tool_args, thinking} = simulate_llm_tool_selection(message, state)
118+
{tool_name, tool_args, thinking} = simulate_llm_tool_selection(message, store_name)
112119

113120
# Show the simulated thinking process
114121
IO.puts("Assistant thinking: #{thinking}")
115122

116123
# Execute the selected tool if applicable
117124
if tool_name do
118125
# Execute the tool
119-
tool_result = execute_tool(tool_name, tool_args, state)
126+
tool_result = execute_tool(tool_name, tool_args, store_name)
120127

121-
# Update state with tool results
122-
updated_state = update_state_with_tool_result(state, tool_name, tool_result)
128+
# Update store with tool results
129+
update_store_with_tool_result(store_name, tool_name, tool_result)
123130

124131
# Process the result (may trigger another tool or generate response)
125-
process_tool_result(updated_state, tool_name, tool_result)
132+
process_tool_result(store_name, tool_name, tool_result)
126133
else
127134
# No tool selected, generate direct response
128-
generate_final_response(state, message)
129-
state
135+
generate_final_response(store_name, message)
136+
:ok
130137
end
131138
end
132139

guides/getting_started.md

+15-4
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,20 @@ config :llm_agent, :anthropic,
3939
Creating a basic question-answering agent requires only a few lines of code:
4040

4141
```elixir
42+
# Create a store for our conversation
43+
store_name = MyApp.ConversationStore
44+
LLMAgent.Store.start_link(name: store_name)
45+
4246
# Create a simple Q&A agent with a system prompt
4347
{flow, state} = LLMAgent.Flows.conversation(
44-
"You are a helpful assistant that answers questions concisely."
48+
"You are a helpful assistant that answers questions concisely.",
49+
[],
50+
store_name: store_name
4551
)
4652

4753
# Process a user message
4854
message = "What is Elixir?"
49-
{:ok, result, new_state} = AgentForge.process(flow, state, LLMAgent.Signals.user_message(message))
55+
{:ok, result, new_state} = LLMAgent.process(flow, state, message)
5056

5157
# Extract the assistant response
5258
response = result.data
@@ -78,15 +84,20 @@ tools = [
7884
}
7985
]
8086

87+
# Create a store for our conversation
88+
store_name = MyApp.ToolsConversationStore
89+
LLMAgent.Store.start_link(name: store_name)
90+
8191
# Create an agent with tools
8292
{flow, state} = LLMAgent.Flows.conversation(
8393
"You are a helpful assistant that can perform calculations and tell the time.",
84-
tools
94+
tools,
95+
store_name: store_name
8596
)
8697

8798
# Process a message that might require a tool
8899
message = "What's 22 + 20?"
89-
{:ok, result, new_state} = AgentForge.process(flow, state, LLMAgent.Signals.user_message(message))
100+
{:ok, result, new_state} = LLMAgent.process(flow, state, message)
90101
```
91102

92103
## Next Steps

lib/llm_agent/flows.ex

+25-25
Original file line numberDiff line numberDiff line change
@@ -450,29 +450,29 @@ defmodule LLMAgent.Flows do
450450

451451
# Create a flow that combines flows together in sequence
452452
# This function is currently unused but kept for future use
453-
defp sequence_flows(flows) do
454-
fn signal, state ->
455-
Enum.reduce_while(flows, {signal, state}, &process_flow_result/2)
456-
end
457-
end
458-
459-
# Helper function to process flow results and determine continuation
460-
defp process_flow_result(flow, {current_signal, current_state}) do
461-
case flow.(current_signal, current_state) do
462-
{:emit, new_signal, new_state} ->
463-
{:cont, {new_signal, new_state}}
464-
465-
{:skip, new_state} ->
466-
{:cont, {current_signal, new_state}}
467-
468-
{:halt, result, new_state} ->
469-
{:halt, {:halt, result, new_state}}
470-
471-
{:error, reason, new_state} ->
472-
{:halt, {:error, reason, new_state}}
473-
474-
other ->
475-
{:halt, other}
476-
end
477-
end
453+
# defp sequence_flows(flows) do
454+
# fn signal, state ->
455+
# Enum.reduce_while(flows, {signal, state}, &process_flow_result/2)
456+
# end
457+
# end
458+
459+
# # Helper function to process flow results and determine continuation
460+
# defp process_flow_result(flow, {current_signal, current_state}) do
461+
# case flow.(current_signal, current_state) do
462+
# {:emit, new_signal, new_state} ->
463+
# {:cont, {new_signal, new_state}}
464+
465+
# {:skip, new_state} ->
466+
# {:cont, {current_signal, new_state}}
467+
468+
# {:halt, result, new_state} ->
469+
# {:halt, {:halt, result, new_state}}
470+
471+
# {:error, reason, new_state} ->
472+
# {:halt, {:error, reason, new_state}}
473+
474+
# other ->
475+
# {:halt, other}
476+
# end
477+
# end
478478
end

mix.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule LLMAgent.MixProject do
22
use Mix.Project
33

44
@source_url "https://github.com/i365dev/llm_agent"
5-
@version "0.1.1"
5+
@version "0.2.0"
66

77
def project do
88
[

0 commit comments

Comments
 (0)