Skip to content

Commit

Permalink
Done
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisTraub committed Nov 8, 2023
1 parent 4477e7a commit bbfbf58
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
17 changes: 11 additions & 6 deletions backend/text_playground/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from pydantic import BaseModel

class ClaudeRequest(BaseModel):
class TextRequest(BaseModel):
prompt: str
temperature: float
maxTokens: int

class ClaudeRequest(TextRequest):
prompt: str
# Randomness and diversity
# min: 0, max: 1, default: 0.5
Expand All @@ -9,14 +14,14 @@ class ClaudeRequest(BaseModel):
# min: 0, max: 4096, default: 200
maxTokens: int = 200

class TextResponse(BaseModel):
completion: str

class Jurassic2Request(BaseModel):
class Jurassic2Request(TextRequest):
prompt: str
# Randomness and diversity
# min: 0, max: 1, default: 0.5
temperature: float = 0.5
# Length
# min: 0, max: 8191, default: 200
maxTokens: int = 200
maxTokens: int = 200

class TextResponse(BaseModel):
completion: str
20 changes: 7 additions & 13 deletions backend/text_playground/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,13 @@

router = APIRouter()

@router.post("/foundation-models/model/text/{modelId}/invoke")
def invoke(body: models.TextRequest, modelId: str):
if modelId == "anthropic.claude-v2":
completion = claude.invoke(body.prompt, body.temperature, body.maxTokens)
elif modelId == "ai21.j2-mid-v1":
completion = jurassic2.invoke(body.prompt, body.temperature, body.maxTokens)

@router.post("/foundation-models/model/text/anthropic.claude-v2/invoke")
def invoke(body: models.ClaudeRequest):
completion = claude.invoke(body.prompt, body.temperature, body.maxTokens)

return models.TextResponse(
completion=completion
)

@router.post("/foundation-models/model/text/ai21.j2-mid-v1/invoke")
def new_route_function(request: models.Jurassic2Request):
completion = jurassic2.invoke(request.prompt, request.temperature, request.maxTokens)

return models.TextResponse(
completion=completion
)
)
2 changes: 0 additions & 2 deletions frontend/components/textPlayground/TextComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ export default function TextContainer() {
maxTokens: payload.maxTokens.value
});

console.log(body);

const response = await fetch(api, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
Expand Down

0 comments on commit bbfbf58

Please sign in to comment.