Skip to content

Commit

Permalink
Models reponse for RaaG
Browse files Browse the repository at this point in the history
  • Loading branch information
amengus87 committed Jun 6, 2024
1 parent 9572c5a commit 50a288a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -18,6 +19,8 @@
import ai.dragon.dto.openai.completion.OpenAiCompletionRequest;
import ai.dragon.dto.openai.completion.OpenAiCompletionResponse;
import ai.dragon.dto.openai.completion.OpenAiCompletionUsage;
import ai.dragon.dto.openai.model.OpenAiModel;
import ai.dragon.dto.openai.model.OpenAiModelsReponse;
import ai.dragon.service.SseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand All @@ -30,6 +33,19 @@ public class OpenAiCompatibleV1ApiController {
@Autowired
private SseService sseService;

@GetMapping("/models")
@Operation(summary = "List models", description = "Lists available models.")
public OpenAiModelsReponse models() {
return OpenAiModelsReponse.builder()
.data(List.of(OpenAiModel
.builder()
.created(System.currentTimeMillis() / 1000)
.id("dragon-ppx")
.owned_by("dRAGon")
.build()))
.build();
}

@PostMapping("/completions")
@Operation(summary = "Creates a completion", description = "Creates a completion for the provided prompt and parameters.")
public Object completions(@Valid @RequestBody OpenAiCompletionRequest request)
Expand Down
15 changes: 15 additions & 0 deletions backend/src/main/java/ai/dragon/dto/openai/model/OpenAiModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ai.dragon.dto.openai.model;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class OpenAiModel {
private String id;
private Long created;
private String owned_by;

@Builder.Default
private String object = "model";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ai.dragon.dto.openai.model;

import java.util.List;

import lombok.Builder;
import lombok.Data;

@Builder
@Data
public class OpenAiModelsReponse {
@Builder.Default
private String object = "list";

private List<OpenAiModel> data;
}

0 comments on commit 50a288a

Please sign in to comment.