Skip to content

Commit

Permalink
add model and temperature to ai_feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielburnworth committed Dec 3, 2024
1 parent 8f2f72f commit a75f5bb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
5 changes: 4 additions & 1 deletion app/controllers/api/ai_feedbacks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
module Api
class AiFeedbacksController < Api::AbstractController
def create
render json: AiFeedback.create!(update_params)
render json: AiFeedback.create!(update_params.merge(
model: ENV["OPENAI_MODEL_LUA"],
temperature: ENV["OPENAI_API_TEMPERATURE"]
))
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/ais_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def make_request(system_prompt, user_prompt, stream)
url = "https://api.openai.com/v1/chat/completions"
context_key = raw_json[:context_key]
lua_request = context_key == "lua"
model_lua = ENV["OPENAI_MODEL_LUA"] || "gpt-3.5-turbo-16k"
model_lua = ENV["OPENAI_MODEL_LUA"] || "gpt-3.5-turbo"
model_other = ENV["OPENAI_MODEL_OTHER"] || "gpt-3.5-turbo"
payload = {
"model" => lua_request ? model_lua : model_other,
Expand Down
11 changes: 11 additions & 0 deletions db/migrate/20241203211516_add_model_to_ai_feedbacks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class AddModelToAiFeedbacks < ActiveRecord::Migration[6.1]
def up
add_column :ai_feedbacks, :model, :string, limit: 30
add_column :ai_feedbacks, :temperature, :string, limit: 5
end

def down
remove_column :ai_feedbacks, :model
remove_column :ai_feedbacks, :temperature
end
end
26 changes: 7 additions & 19 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
--

-- *not* creating schema, since initdb creates it


--
-- Name: hstore; Type: EXTENSION; Schema: -; Owner: -
--
Expand Down Expand Up @@ -159,7 +152,9 @@ CREATE TABLE public.ai_feedbacks (
prompt character varying(500),
reaction character varying(25),
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL
updated_at timestamp(6) without time zone NOT NULL,
model character varying(30),
temperature character varying(5)
);


Expand Down Expand Up @@ -1540,7 +1535,7 @@ CREATE VIEW public.resource_update_steps AS
edge_nodes.kind,
edge_nodes.value
FROM public.edge_nodes
WHERE (((edge_nodes.kind)::text = 'resource_type'::text) AND ((edge_nodes.value)::text = ANY ((ARRAY['"GenericPointer"'::character varying, '"ToolSlot"'::character varying, '"Plant"'::character varying])::text[])))
WHERE (((edge_nodes.kind)::text = 'resource_type'::text) AND ((edge_nodes.value)::text = ANY (ARRAY[('"GenericPointer"'::character varying)::text, ('"ToolSlot"'::character varying)::text, ('"Plant"'::character varying)::text])))
), resource_id AS (
SELECT edge_nodes.primary_node_id,
edge_nodes.kind,
Expand Down Expand Up @@ -1715,7 +1710,7 @@ ALTER SEQUENCE public.sequence_publications_id_seq OWNED BY public.sequence_publ
--

CREATE VIEW public.sequence_usage_reports AS
SELECT sequences.id AS sequence_id,
SELECT id AS sequence_id,
( SELECT count(*) AS count
FROM public.edge_nodes
WHERE (((edge_nodes.kind)::text = 'sequence_id'::text) AND ((edge_nodes.value)::integer = sequences.id))) AS edge_node_count,
Expand Down Expand Up @@ -3709,14 +3704,6 @@ ALTER TABLE ONLY public.plant_templates
ADD CONSTRAINT plant_templates_device_id_fk FOREIGN KEY (device_id) REFERENCES public.devices(id);


--
-- Name: plant_templates plant_templates_saved_garden_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.plant_templates
ADD CONSTRAINT plant_templates_saved_garden_id_fk FOREIGN KEY (saved_garden_id) REFERENCES public.saved_gardens(id);


--
-- Name: point_group_items point_group_items_point_group_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: -
--
Expand Down Expand Up @@ -3991,6 +3978,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20240207234421'),
('20240405171128'),
('20240625195838'),
('20241203194030');
('20241203194030'),
('20241203211516');


0 comments on commit a75f5bb

Please sign in to comment.