Skip to content

Commit

Permalink
EN-7354 rename openai_assistant_configuration to openai_assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-entourage committed Nov 28, 2024
1 parent c7b238b commit f295d99
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 103 deletions.

This file was deleted.

45 changes: 45 additions & 0 deletions app/controllers/admin/openai_assistants_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module Admin
class OpenaiAssistantsController < Admin::BaseController
layout 'admin_large'

before_action :set_openai_assistant, only: [:edit, :update]

def index
@openai_assistants = OpenaiAssistant.all
.order(:version)
.page(page)
.per(per)
end

def edit
end

def update
@openai_assistant.assign_attributes(openai_assistant_params)

if @openai_assistant.save
redirect_to edit_admin_openai_assistant_path(@openai_assistant)
else
render :edit
end
end

private

def set_openai_assistant
@openai_assistant = OpenaiAssistant.find(params[:id])
end

def openai_assistant_params
params.require(:openai_assistant).permit(:prompt, :days_for_actions, :days_for_outings, :poi_from_file, :resource_from_file)
end

def page
params[:page] || 1
end

def per
params[:per] || 25
end
end
end
2 changes: 2 additions & 0 deletions app/models/openai_assistant.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class OpenaiAssistant < ApplicationRecord
end
2 changes: 0 additions & 2 deletions app/models/openai_assistant_configuration.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/services/matching_services/connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class MatcherCallback < Callback
def initialize instance:
@callback = MatcherCallback.new

@configuration = OpenaiAssistantConfiguration.find_by_version(1)
@configuration = OpenaiAssistant.find_by_version(1)

@client = OpenAI::Client.new(access_token: @configuration.api_key)
@assistant_id = @configuration.assistant_id
Expand Down

This file was deleted.

36 changes: 0 additions & 36 deletions app/views/admin/openai_assistant_configurations/index.html.erb

This file was deleted.

13 changes: 13 additions & 0 deletions app/views/admin/openai_assistants/_edit_header.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="row">
<ol class="breadcrumb">
<li><%= link_to "openai_assistants", admin_openai_assistants_path %></li>
<li class="active">Modifier</li>
<li style="float: right;">
Version <%= @openai_assistant.version %>
</li>
</ol>

<h2>
<span class="text-muted"># Version <%= @openai_assistant.version %></span>
</h2>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
.field_with_errors { display: inline-block }
</style>

<%= render partial: 'common/errors', locals: { obj: @openai_assistant_configuration } %>
<%= render partial: 'common/errors', locals: { obj: @openai_assistant } %>

<%= form_for [:admin, @openai_assistant_configuration], html: { role: "form" } do |f| %>
<%= form_for [:admin, @openai_assistant], html: { role: "form" } do |f| %>
<div class="form-group">
<%= f.label :prompt %>
<div class="controls">
Expand Down Expand Up @@ -46,5 +46,5 @@
</div>

<%= f.submit 'Enregistrer', class: "btn btn-primary" %>
<%= link_to "Retour", admin_openai_assistant_configurations_path, class: "btn btn-default" %>
<%= link_to "Retour", admin_openai_assistants_path, class: "btn btn-default" %>
<% end %>
36 changes: 36 additions & 0 deletions app/views/admin/openai_assistants/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<div class="container">
<div style="margin: auto">
<h1>openai_assistant</h1>

<div class="row">
<% unless @openai_assistants.none? %>
<table class="table custom-table">
<thead>
<th>Version</th>
<th>Prompt</th>
<th>poi_from_file</th>
<th>resource_from_file</th>
<th>days_for_actions</th>
<th>days_for_outings</th>
</thead>
<% @openai_assistants.each_with_index do |openai_assistant, i| %>
<% parite = i.even? ? 'pair' : 'impair' %>

<tr class="above-row row-<%= parite %>">
<td><%= link_to openai_assistant.version, edit_admin_openai_assistant_path(openai_assistant) %></td>
<td><%= link_to openai_assistant.prompt, edit_admin_openai_assistant_path(openai_assistant) %></td>
<td><%= openai_assistant.poi_from_file %></td>
<td><%= openai_assistant.resource_from_file %></td>
<td><%= openai_assistant.days_for_actions %></td>
<td><%= openai_assistant.days_for_outings %></td>
<% end %>
</table>
<% end %>
</div>

<%= page_entries_info @openai_assistants, entry_name: 'openai_assistants' %>
<div class="container">
<%= paginate(@openai_assistants) %>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/layouts/_admin_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Superadmin
</a>
<ul class="dropdown-menu">
<li><%= link_to "openai_assistant_configurations", admin_openai_assistant_configurations_path %></li>
<li><%= link_to "openai_assistants", admin_openai_assistants_path %></li>
<li><%= link_to "Options", admin_options_path %></li>
<li><%= link_to "Soliguide", admin_super_admin_soliguide_path %></li>
<li><%= link_to "Sidekiq", sidekiq_web_path %></li>
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
end
end

resources :openai_assistant_configurations, only: [:index, :edit, :update]
resources :openai_assistants, only: [:index, :edit, :update]

resources :recommandations do
member do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RenameOpenaiAssistantConfigurationsToOpenaiAssistants < ActiveRecord::Migration[6.1]
def change
rename_table :openai_assistant_configurations, :openai_assistants
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@
t.index ["user_id"], name: "index_old_user_denorms_on_user_id"
end

create_table "openai_assistant_configurations", force: :cascade do |t|
create_table "openai_assistants", force: :cascade do |t|
t.integer "version"
t.string "api_key", null: false
t.string "assistant_id", null: false
Expand Down

0 comments on commit f295d99

Please sign in to comment.