|
5 | 5 | RSpec.describe ProblemCheck::AiLlmStatus do |
6 | 6 | subject(:check) { described_class.new } |
7 | 7 |
|
| 8 | + # let(:spec_model) do |
| 9 | + # LlmModel.new( |
| 10 | + # id: 50, |
| 11 | + # display_name: "GPT-4 Turbo", |
| 12 | + # name: "gpt-4-turbo", |
| 13 | + # provider: "open_ai", |
| 14 | + # tokenizer: "DiscourseAi::Tokenizer::OpenAiTokenizer", |
| 15 | + # max_prompt_tokens: 131_072, |
| 16 | + # api_key: "invalid", |
| 17 | + # url: "https://api.openai.com/v1/chat/completions", |
| 18 | + # ) |
| 19 | + # end |
| 20 | + |
| 21 | + fab!(:llm_model) |
| 22 | + |
8 | 23 | before do |
9 | | - assign_fake_provider_to(:ai_summarization_model) |
| 24 | + pp "Spec model: #{llm_model.inspect}" |
| 25 | + SiteSetting.ai_summarization_model = "custom:#{llm_model.id}" |
| 26 | + # assign_fake_provider_to(:ai_summarization_model) |
10 | 27 | SiteSetting.ai_summarization_enabled = true |
11 | 28 | end |
12 | 29 |
|
|
17 | 34 | end |
18 | 35 |
|
19 | 36 | context "with discourse-ai plugin enabled for the site" do |
20 | | - let(:llm_model) { LlmModel.in_use.first } |
| 37 | + # let(:llm_model) { LlmModel.in_use.first } |
21 | 38 |
|
22 | 39 | before { SiteSetting.discourse_ai_enabled = true } |
23 | 40 |
|
24 | 41 | it "returns a problem with an LLM model" do |
| 42 | + stub_request(:post, "https://api.openai.com/v1/chat/completions").with( |
| 43 | + body: |
| 44 | + "{\"model\":\"gpt-4-turbo\",\"messages\":[{\"role\":\"system\",\"content\":\"You are a helpful bot\"},{\"role\":\"user\",\"content\":\"How much is 1 + 1?\"}]}", |
| 45 | + headers: { |
| 46 | + "Accept" => "*/*", |
| 47 | + "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3", |
| 48 | + "Authorization" => "Bearer 123", |
| 49 | + "Content-Type" => "application/json", |
| 50 | + "Host" => "api.openai.com", |
| 51 | + "User-Agent" => "Ruby", |
| 52 | + }, |
| 53 | + ).to_return(status: 200, body: "", headers: {}) |
25 | 54 | message = |
26 | 55 | "#{I18n.t("dashboard.problem.ai_llm_status", { model_name: llm_model.display_name, model_id: llm_model.id })}" |
27 | 56 |
|
|
0 commit comments