Skip to content

Commit 89cdd03

Browse files
committed
feat: fix model output formatting
1 parent 0341d92 commit 89cdd03

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

infrastructure/cymbal-store-embeddings/data_model.py

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2024 Google LLC.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
import mesop as me
216
from dataclasses import dataclass, field
317
from enum import Enum

infrastructure/movie-search-app/gemini_model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def classify_intent(input: str) -> str:
3939
)
4040
json_resp = model.generate_content(input)
4141
logging.info(f"INTENT: {json_resp}")
42-
return json_resp.text
42+
return json_resp.text.replace("```", "").replace("json", "").strip()
4343

4444
def generate_embedding(input: str) -> list[float]:
4545
result = genai.embed_content(

infrastructure/movie-search-app/pinecone_model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def classify_intent(input: str) -> str:
4040
)
4141
json_resp = model.generate_content(input)
4242
logging.info(f"INTENT: {json_resp}")
43-
return json_resp.text
43+
return json_resp.text.replace("```", "").replace("json", "").strip()
4444

4545
def generate_embedding(input: str) -> list[float]:
4646
result = genai.embed_content(

0 commit comments

Comments
 (0)