From cdd03738e12cc2e3819718bbd164345871cbd4fe Mon Sep 17 00:00:00 2001 From: John Wilger Date: Thu, 14 Dec 2023 21:59:20 -0800 Subject: [PATCH] GptAgent is a GenServer --- lib/gpt_agent.ex | 17 +++++++---------- test/gpt_agent_test.exs | 7 +++++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/gpt_agent.ex b/lib/gpt_agent.ex index e4ae4ef..e03565e 100644 --- a/lib/gpt_agent.ex +++ b/lib/gpt_agent.ex @@ -1,18 +1,15 @@ defmodule GptAgent do @moduledoc """ - Documentation for `GptAgent`. + Provides a GPT conversation agent """ - @doc """ - Hello world. + use GenServer - ## Examples - - iex> GptAgent.hello() - :world + def init(init_arg) do + {:ok, init_arg} + end - """ - def hello do - :world + def start_link do + GenServer.start_link(__MODULE__, nil) end end diff --git a/test/gpt_agent_test.exs b/test/gpt_agent_test.exs index b7111f1..a67a150 100644 --- a/test/gpt_agent_test.exs +++ b/test/gpt_agent_test.exs @@ -2,7 +2,10 @@ defmodule GptAgentTest do use ExUnit.Case doctest GptAgent - test "greets the world" do - assert GptAgent.hello() == :world + describe "start_link/0" do + test "starts the agent" do + assert {:ok, pid} = GptAgent.start_link() + assert Process.alive?(pid) + end end end