File tree Expand file tree Collapse file tree 3 files changed +18
-21
lines changed
frontend/components/textPlayground Expand file tree Collapse file tree 3 files changed +18
-21
lines changed Original file line number Diff line number Diff line change 1
1
from pydantic import BaseModel
2
2
3
- class ClaudeRequest (BaseModel ):
3
+ class TextRequest (BaseModel ):
4
+ prompt : str
5
+ temperature : float
6
+ maxTokens : int
7
+
8
+ class ClaudeRequest (TextRequest ):
4
9
prompt : str
5
10
# Randomness and diversity
6
11
# min: 0, max: 1, default: 0.5
@@ -9,14 +14,14 @@ class ClaudeRequest(BaseModel):
9
14
# min: 0, max: 4096, default: 200
10
15
maxTokens : int = 200
11
16
12
- class TextResponse (BaseModel ):
13
- completion : str
14
-
15
- class Jurassic2Request (BaseModel ):
17
+ class Jurassic2Request (TextRequest ):
16
18
prompt : str
17
19
# Randomness and diversity
18
20
# min: 0, max: 1, default: 0.5
19
21
temperature : float = 0.5
20
22
# Length
21
23
# min: 0, max: 8191, default: 200
22
- maxTokens : int = 200
24
+ maxTokens : int = 200
25
+
26
+ class TextResponse (BaseModel ):
27
+ completion : str
Original file line number Diff line number Diff line change 6
6
7
7
router = APIRouter ()
8
8
9
+ @router .post ("/foundation-models/model/text/{modelId}/invoke" )
10
+ def invoke (body : models .TextRequest , modelId : str ):
11
+ if modelId == "anthropic.claude-v2" :
12
+ completion = claude .invoke (body .prompt , body .temperature , body .maxTokens )
13
+ elif modelId == "ai21.j2-mid-v1" :
14
+ completion = jurassic2 .invoke (body .prompt , body .temperature , body .maxTokens )
9
15
10
- @router .post ("/foundation-models/model/text/anthropic.claude-v2/invoke" )
11
- def invoke (body : models .ClaudeRequest ):
12
- completion = claude .invoke (body .prompt , body .temperature , body .maxTokens )
13
-
14
16
return models .TextResponse (
15
17
completion = completion
16
- )
17
-
18
- @router .post ("/foundation-models/model/text/ai21.j2-mid-v1/invoke" )
19
- def new_route_function (request : models .Jurassic2Request ):
20
- completion = jurassic2 .invoke (request .prompt , request .temperature , request .maxTokens )
21
-
22
- return models .TextResponse (
23
- completion = completion
24
- )
18
+ )
Original file line number Diff line number Diff line change @@ -75,8 +75,6 @@ export default function TextContainer() {
75
75
maxTokens : payload . maxTokens . value
76
76
} ) ;
77
77
78
- console . log ( body ) ;
79
-
80
78
const response = await fetch ( api , {
81
79
method : 'POST' ,
82
80
headers : { 'Content-Type' : 'application/json' } ,
You can’t perform that action at this time.
0 commit comments