@@ -80,63 +80,6 @@ func (wrapper InvokeModelWrapper) InvokeClaude(ctx context.Context, prompt strin
8080
8181// snippet-end:[gov2.bedrock-runtime.InvokeClaude]
8282
83- // snippet-start:[gov2.bedrock-runtime.InvokeJurassic2]
84-
85- // Each model provider has their own individual request and response formats.
86- // For the format, ranges, and default values for AI21 Labs Jurassic-2, refer to:
87- // https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-jurassic2.html
88-
89- type Jurassic2Request struct {
90- Prompt string `json:"prompt"`
91- MaxTokens int `json:"maxTokens,omitempty"`
92- Temperature float64 `json:"temperature,omitempty"`
93- }
94-
95- type Jurassic2Response struct {
96- Completions []Completion `json:"completions"`
97- }
98- type Completion struct {
99- Data Data `json:"data"`
100- }
101- type Data struct {
102- Text string `json:"text"`
103- }
104-
105- // Invokes AI21 Labs Jurassic-2 on Amazon Bedrock to run an inference using the input
106- // provided in the request body.
107- func (wrapper InvokeModelWrapper ) InvokeJurassic2 (ctx context.Context , prompt string ) (string , error ) {
108- modelId := "ai21.j2-mid-v1"
109-
110- body , err := json .Marshal (Jurassic2Request {
111- Prompt : prompt ,
112- MaxTokens : 200 ,
113- Temperature : 0.5 ,
114- })
115-
116- if err != nil {
117- log .Fatal ("failed to marshal" , err )
118- }
119-
120- output , err := wrapper .BedrockRuntimeClient .InvokeModel (ctx , & bedrockruntime.InvokeModelInput {
121- ModelId : aws .String (modelId ),
122- ContentType : aws .String ("application/json" ),
123- Body : body ,
124- })
125-
126- if err != nil {
127- ProcessError (err , modelId )
128- }
129-
130- var response Jurassic2Response
131- if err := json .Unmarshal (output .Body , & response ); err != nil {
132- log .Fatal ("failed to unmarshal" , err )
133- }
134-
135- return response .Completions [0 ].Data .Text , nil
136- }
137-
138- // snippet-end:[gov2.bedrock-runtime.InvokeJurassic2]
139-
14083// snippet-start:[gov2.bedrock-runtime.InvokeTitanImage]
14184
14285type TitanImageRequest struct {
@@ -207,70 +150,6 @@ func (wrapper InvokeModelWrapper) InvokeTitanImage(ctx context.Context, prompt s
207150
208151// snippet-end:[gov2.bedrock-runtime.InvokeTitanImage]
209152
210- // snippet-start:[gov2.bedrock-runtime.InvokeTitanText]
211-
212- // Each model provider has their own individual request and response formats.
213- // For the format, ranges, and default values for Amazon Titan Text, refer to:
214- // https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-titan-text.html
215- type TitanTextRequest struct {
216- InputText string `json:"inputText"`
217- TextGenerationConfig TextGenerationConfig `json:"textGenerationConfig"`
218- }
219-
220- type TextGenerationConfig struct {
221- Temperature float64 `json:"temperature"`
222- TopP float64 `json:"topP"`
223- MaxTokenCount int `json:"maxTokenCount"`
224- StopSequences []string `json:"stopSequences,omitempty"`
225- }
226-
227- type TitanTextResponse struct {
228- InputTextTokenCount int `json:"inputTextTokenCount"`
229- Results []Result `json:"results"`
230- }
231-
232- type Result struct {
233- TokenCount int `json:"tokenCount"`
234- OutputText string `json:"outputText"`
235- CompletionReason string `json:"completionReason"`
236- }
237-
238- func (wrapper InvokeModelWrapper ) InvokeTitanText (ctx context.Context , prompt string ) (string , error ) {
239- modelId := "amazon.titan-text-express-v1"
240-
241- body , err := json .Marshal (TitanTextRequest {
242- InputText : prompt ,
243- TextGenerationConfig : TextGenerationConfig {
244- Temperature : 0 ,
245- TopP : 1 ,
246- MaxTokenCount : 4096 ,
247- },
248- })
249-
250- if err != nil {
251- log .Fatal ("failed to marshal" , err )
252- }
253-
254- output , err := wrapper .BedrockRuntimeClient .InvokeModel (ctx , & bedrockruntime.InvokeModelInput {
255- ModelId : aws .String (modelId ),
256- ContentType : aws .String ("application/json" ),
257- Body : body ,
258- })
259-
260- if err != nil {
261- ProcessError (err , modelId )
262- }
263-
264- var response TitanTextResponse
265- if err := json .Unmarshal (output .Body , & response ); err != nil {
266- log .Fatal ("failed to unmarshal" , err )
267- }
268-
269- return response .Results [0 ].OutputText , nil
270- }
271-
272- // snippet-end:[gov2.bedrock-runtime.InvokeTitanText]
273-
274153func ProcessError (err error , modelId string ) {
275154 errMsg := err .Error ()
276155 if strings .Contains (errMsg , "no such host" ) {
0 commit comments